From c29df689dcf8115897e0c83f7c1dc1180668a10a Mon Sep 17 00:00:00 2001 From: Jens Preussner <jens.preussner@mpi-bn.mpg.de> Date: Thu, 2 Apr 2020 10:40:39 +0000 Subject: [PATCH] Updated ANY signature of add_component --- DESCRIPTION | 4 ++-- R/vis_objects.R | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4a36729..f638530 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,9 +21,9 @@ Imports: rmarkdown, stringr, glue, - ymlthis, - switchr + ymlthis Suggests: + switchr, highcharter, plotly, crosstalk, diff --git a/R/vis_objects.R b/R/vis_objects.R index 5cc3917..3f2c244 100644 --- a/R/vis_objects.R +++ b/R/vis_objects.R @@ -64,14 +64,20 @@ setMethod("add_component", setMethod("add_component", signature = signature(dashboard = "i2dashboard", component = "ANY"), definition = function(dashboard, component, page = "default", title = NULL, ...) { - if(!inherits(component, "htmlwidget")) { - warning("The object has to inherit from the class 'htmlwidget'.") - return(dashboard) - } - package <- packageSlot(component) - if(is.null(package)) { - warning("The package name of this HTML widget could not be determined. The component was not added to the dashboard.") - return(dashboard) + + # HTMLWIDGETS + if(inherits(component, "htmlwidget")) { + package <- packageSlot(component) + + if(is.null(package)) { + warning("No component added, since the package name of the HTML widget could not be determined.") + return(dashboard) + } + + return(add_vis_object(dashboard, component, package, page, title, ...)) } - add_vis_object(dashboard, component, package, page, title, ...) + + # OTHER + warning("The component did not inherit from any of the currently supported classes ('htmlwidget').") + return(dashboard) }) -- GitLab