From a9ae7621fd62ebe7d114811487efd896319b9179 Mon Sep 17 00:00:00 2001 From: Pawel Rucki Date: Tue, 10 Jan 2023 14:19:48 +0100 Subject: [PATCH 1/8] convert check to assert --- R/get_rcode.R | 2 +- R/init.R | 3 +-- R/module_nested_tabs.R | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/R/get_rcode.R b/R/get_rcode.R index ffe48a32e9..d32c726005 100644 --- a/R/get_rcode.R +++ b/R/get_rcode.R @@ -208,7 +208,7 @@ get_rcode_srv <- function(id, modal_title = "R Code", code_header = "Automatically generated R code", disable_buttons = reactiveVal(FALSE)) { - checkmate::check_class(disable_buttons, c("reactive", "function")) + checkmate::assert_class(disable_buttons, c("reactive", "function")) lifecycle::deprecate_warn( when = "0.12.1", diff --git a/R/init.R b/R/init.R index e455f0ada3..1091b691ce 100644 --- a/R/init.R +++ b/R/init.R @@ -161,8 +161,7 @@ init <- function(data, checkmate::assert_string(title, null.ok = TRUE) checkmate::assert_class(data, "TealData") - checkmate::check_list(modules) - checkmate::check_class(modules, "teal_modules") + checkmate::assert_multi_class(modules, c("list", "teal_modules")) checkmate::assert_list(filter, min.len = 0, names = "unique") checkmate::assert_subset(names(filter), choices = teal.data::get_dataname(data)) checkmate::assert_character(id, max.len = 1, any.missing = FALSE) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 96576ad81c..d09c7dadbd 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -88,7 +88,7 @@ ui_nested_tabs.teal_modules <- function(id, modules, datasets, depth = 0L) { #' @export #' @keywords internal ui_nested_tabs.teal_module <- function(id, modules, datasets, depth = 0L) { - checkmate::check_class(datasets, "FilteredData") + checkmate::assert_class(datasets, "FilteredData") args <- isolate(teal.transform::resolve_delayed(modules$ui_args, datasets)) args <- c(list(id = id), args) From e31d0f74c46c7f5a68a8df7fcbf3148489438e31 Mon Sep 17 00:00:00 2001 From: Pawel Rucki Date: Wed, 11 Jan 2023 11:39:41 +0100 Subject: [PATCH 2/8] accept `teal_module` type of objects --- NEWS.md | 3 +- R/example_module.R | 2 +- R/init.R | 5 +++- R/modules_debugging.R | 4 +-- man/example_module.Rd | 2 +- man/filter_calls_module.Rd | 4 +-- man/init.Rd | 30 +++++++------------- man/module.Rd | 11 ++----- man/srv_nested_tabs.Rd | 6 ++-- man/srv_tabs_with_filters.Rd | 30 +++++++------------- man/srv_teal.Rd | 30 +++++++------------- man/srv_teal_with_splash.Rd | 30 +++++++------------- tests/testthat/test-init.R | 15 ++++++++++ vignettes/adding-support-for-reporting.Rmd | 10 +++---- vignettes/creating-custom-modules.Rmd | 14 ++++----- vignettes/including-adam-data-in-teal.Rmd | 2 +- vignettes/including-general-data-in-teal.Rmd | 4 +-- vignettes/including-mae-data-in-teal.Rmd | 4 +-- vignettes/preprocessing-data.Rmd | 4 +-- vignettes/teal-bs-themes.Rmd | 4 +-- vignettes/teal.Rmd | 2 +- 21 files changed, 90 insertions(+), 126 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0cead9df67..bf541d8dab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ ### Major breaking changes -* The use of `datasets` argument in `teal` `modules` has been deprecated and will be removed in a future release. Please use `data` argument instead. `data` is of type `tdata`; see "Creating custom modules" vignettes and function documentation of `teal::new_tdata` for further details. +* The use of `datasets` argument in `modules` has been deprecated and will be removed in a future release. Please use `data` argument instead. `data` is of type `tdata`; see "Creating custom modules" vignettes and function documentation of `teal::new_tdata` for further details. ### Breaking changes @@ -11,6 +11,7 @@ ### New features * Added the `validate_inputs` and `validate_inputs_segregated` functions that transfer input validation messages to app output. +* `modules` argument of `init` accepts `teal_module` type of object. There is no need to wrap up a single module in `modules()` or `list()`. ### Miscellaneous diff --git a/R/example_module.R b/R/example_module.R index b3cb8b7bcc..dcc5a0c73e 100644 --- a/R/example_module.R +++ b/R/example_module.R @@ -9,7 +9,7 @@ #' dataset("IRIS", iris), #' dataset("MTCARS", mtcars) #' ), -#' modules = modules(example_module()) +#' modules = example_module() #' ) #' if (interactive()) { #' shinyApp(app$ui, app$server) diff --git a/R/init.R b/R/init.R index 1091b691ce..c953d414cf 100644 --- a/R/init.R +++ b/R/init.R @@ -161,13 +161,16 @@ init <- function(data, checkmate::assert_string(title, null.ok = TRUE) checkmate::assert_class(data, "TealData") - checkmate::assert_multi_class(modules, c("list", "teal_modules")) + checkmate::assert_multi_class(modules, c("teal_module", "list", "teal_modules")) checkmate::assert_list(filter, min.len = 0, names = "unique") checkmate::assert_subset(names(filter), choices = teal.data::get_dataname(data)) checkmate::assert_character(id, max.len = 1, any.missing = FALSE) teal.logger::log_system_info() + if (is(modules, "teal_module")) { + modules <- teal::modules(modules) + } if (is(modules, "list")) { modules <- do.call(teal::modules, modules) } diff --git a/R/modules_debugging.R b/R/modules_debugging.R index 91e60e354c..0f590d0479 100644 --- a/R/modules_debugging.R +++ b/R/modules_debugging.R @@ -27,9 +27,7 @@ #' ), #' code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl" #' ), -#' modules = modules( -#' teal:::filter_calls_module() -#' ), +#' modules = teal:::filter_calls_module(), #' header = "Simple teal app" #' ) #' if (interactive()) { diff --git a/man/example_module.Rd b/man/example_module.Rd index 19d6c718c6..ff276f1b4c 100644 --- a/man/example_module.Rd +++ b/man/example_module.Rd @@ -21,7 +21,7 @@ app <- init( dataset("IRIS", iris), dataset("MTCARS", mtcars) ), - modules = modules(example_module()) + modules = example_module() ) if (interactive()) { shinyApp(app$ui, app$server) diff --git a/man/filter_calls_module.Rd b/man/filter_calls_module.Rd index dc49091cb8..85889fac4d 100644 --- a/man/filter_calls_module.Rd +++ b/man/filter_calls_module.Rd @@ -29,9 +29,7 @@ app <- init( ), code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl" ), - modules = modules( - teal:::filter_calls_module() - ), + modules = teal:::filter_calls_module(), header = "Simple teal app" ) if (interactive()) { diff --git a/man/init.Rd b/man/init.Rd index 14f55d42db..ff336b8d2b 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -35,34 +35,26 @@ The browser window title (defaults to the host URL of the page).} \item{filter}{(\code{list})\cr You can define filters that show when the app starts. List names should be named according to datanames passed to the \code{data} argument. -In case of data.frame` the list should be composed as follows: - -\if{html}{\out{
}}\preformatted{list( = list( = ..., = ...), +In case of data.frame` the list should be composed as follows:\preformatted{list( = list( = ..., = ...), = list(...), ...) -}\if{html}{\out{
}} +} For example, filters for variable \code{Sepal.Length} in \code{iris} can be specified as -follows: - -\if{html}{\out{
}}\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) +follows:\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0))) -}\if{html}{\out{
}} +} In case developer would like to include \code{NA} and \code{Inf} values in the -filtered dataset. - -\if{html}{\out{
}}\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) +filtered dataset.\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf)) -}\if{html}{\out{
}} +} To initialize with specific variable filter with all values on start, one -can use - -\if{html}{\out{
}}\preformatted{list(Species = list()) -}\if{html}{\out{
}} +can use\preformatted{list(Species = list()) +} \code{filter} should be set with respect to the class of the column: \itemize{ @@ -79,9 +71,7 @@ defining initial values selected to filter. different way. Since it contains patient data with list of experiments, \code{filter} list should be created as follows: \cr -} - -\if{html}{\out{
}}\preformatted{list( +}\preformatted{list( = list( subjects = list( = ..., = ...), = list( @@ -92,7 +82,7 @@ different way. Since it contains patient data with list of experiments, ) ) ) -}\if{html}{\out{
}} +} By adding the \code{filterable} attribute it is possible to control which variables can be filtered for each dataset. See the example below where \code{ADSL} can only be filtered by \code{AGE}, \code{SEX} or \code{RACE}.} diff --git a/man/module.Rd b/man/module.Rd index 9565154f30..a184b686a4 100644 --- a/man/module.Rd +++ b/man/module.Rd @@ -8,14 +8,9 @@ \usage{ module( label = "module", - server = function(id, ...) { - moduleServer(id, function(input, output, session) { - - }) - }, - ui = function(id, ...) { - tags$p(paste0("This module has no UI (id: ", id, " )")) - + server = function(id, ...) { moduleServer(id, function(input, output, session) { + }) }, + ui = function(id, ...) { tags$p(paste0("This module has no UI (id: ", id, " )")) }, filters = "all", server_args = NULL, diff --git a/man/srv_nested_tabs.Rd b/man/srv_nested_tabs.Rd index 89ae7bdd3e..ce215ebda1 100644 --- a/man/srv_nested_tabs.Rd +++ b/man/srv_nested_tabs.Rd @@ -48,15 +48,13 @@ This module calls recursively all elements of the \code{modules} returns one whi is currently active. To determine which module is active see the diagram. \if{html}{\figure{uml_nested_tabs.jpg}{options: width="75\%" alt="Figure: uml_nested_tabs.jpg"}} \if{latex}{\figure{uml_nested_tabs.jpg}{options: width=7cm}} -Above depicts hypothetical situation in which one has module structure defined in following way: - -\if{html}{\out{
}}\preformatted{+ root +Above depicts hypothetical situation in which one has module structure defined in following way:\preformatted{+ root + tab1 + test1 + test2 + tab2 + test3 -}\if{html}{\out{
}} +} \itemize{ \item \code{teal_module} returns self as a active module \item \code{teal_modules} returns module active within self which is determined by the \code{input$active_tab}. diff --git a/man/srv_tabs_with_filters.Rd b/man/srv_tabs_with_filters.Rd index 5a3695ef37..b324f37a9d 100644 --- a/man/srv_tabs_with_filters.Rd +++ b/man/srv_tabs_with_filters.Rd @@ -32,34 +32,26 @@ more details.} \item{filter}{(\code{list})\cr You can define filters that show when the app starts. List names should be named according to datanames passed to the \code{data} argument. -In case of data.frame` the list should be composed as follows: - -\if{html}{\out{
}}\preformatted{list( = list( = ..., = ...), +In case of data.frame` the list should be composed as follows:\preformatted{list( = list( = ..., = ...), = list(...), ...) -}\if{html}{\out{
}} +} For example, filters for variable \code{Sepal.Length} in \code{iris} can be specified as -follows: - -\if{html}{\out{
}}\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) +follows:\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0))) -}\if{html}{\out{
}} +} In case developer would like to include \code{NA} and \code{Inf} values in the -filtered dataset. - -\if{html}{\out{
}}\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) +filtered dataset.\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf)) -}\if{html}{\out{
}} +} To initialize with specific variable filter with all values on start, one -can use - -\if{html}{\out{
}}\preformatted{list(Species = list()) -}\if{html}{\out{
}} +can use\preformatted{list(Species = list()) +} \code{filter} should be set with respect to the class of the column: \itemize{ @@ -76,9 +68,7 @@ defining initial values selected to filter. different way. Since it contains patient data with list of experiments, \code{filter} list should be created as follows: \cr -} - -\if{html}{\out{
}}\preformatted{list( +}\preformatted{list( = list( subjects = list( = ..., = ...), = list( @@ -89,7 +79,7 @@ different way. Since it contains patient data with list of experiments, ) ) ) -}\if{html}{\out{
}} +} By adding the \code{filterable} attribute it is possible to control which variables can be filtered for each dataset. See the example below where \code{ADSL} can only be filtered by \code{AGE}, \code{SEX} or \code{RACE}.} diff --git a/man/srv_teal.Rd b/man/srv_teal.Rd index b1cd99094d..f32fa6c2e8 100644 --- a/man/srv_teal.Rd +++ b/man/srv_teal.Rd @@ -23,34 +23,26 @@ returns the \code{TealData}, only evaluated once, \code{NULL} value is ignored} \item{filter}{(\code{list})\cr You can define filters that show when the app starts. List names should be named according to datanames passed to the \code{data} argument. -In case of data.frame` the list should be composed as follows: - -\if{html}{\out{
}}\preformatted{list( = list( = ..., = ...), +In case of data.frame` the list should be composed as follows:\preformatted{list( = list( = ..., = ...), = list(...), ...) -}\if{html}{\out{
}} +} For example, filters for variable \code{Sepal.Length} in \code{iris} can be specified as -follows: - -\if{html}{\out{
}}\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) +follows:\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0))) -}\if{html}{\out{
}} +} In case developer would like to include \code{NA} and \code{Inf} values in the -filtered dataset. - -\if{html}{\out{
}}\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) +filtered dataset.\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf)) -}\if{html}{\out{
}} +} To initialize with specific variable filter with all values on start, one -can use - -\if{html}{\out{
}}\preformatted{list(Species = list()) -}\if{html}{\out{
}} +can use\preformatted{list(Species = list()) +} \code{filter} should be set with respect to the class of the column: \itemize{ @@ -67,9 +59,7 @@ defining initial values selected to filter. different way. Since it contains patient data with list of experiments, \code{filter} list should be created as follows: \cr -} - -\if{html}{\out{
}}\preformatted{list( +}\preformatted{list( = list( subjects = list( = ..., = ...), = list( @@ -80,7 +70,7 @@ different way. Since it contains patient data with list of experiments, ) ) ) -}\if{html}{\out{
}} +} By adding the \code{filterable} attribute it is possible to control which variables can be filtered for each dataset. See the example below where \code{ADSL} can only be filtered by \code{AGE}, \code{SEX} or \code{RACE}.} diff --git a/man/srv_teal_with_splash.Rd b/man/srv_teal_with_splash.Rd index 2b76b6ca1b..4a9d2fd640 100644 --- a/man/srv_teal_with_splash.Rd +++ b/man/srv_teal_with_splash.Rd @@ -31,34 +31,26 @@ more details.} \item{filter}{(\code{list})\cr You can define filters that show when the app starts. List names should be named according to datanames passed to the \code{data} argument. -In case of data.frame` the list should be composed as follows: - -\if{html}{\out{
}}\preformatted{list( = list( = ..., = ...), +In case of data.frame` the list should be composed as follows:\preformatted{list( = list( = ..., = ...), = list(...), ...) -}\if{html}{\out{
}} +} For example, filters for variable \code{Sepal.Length} in \code{iris} can be specified as -follows: - -\if{html}{\out{
}}\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) +follows:\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0))) -}\if{html}{\out{
}} +} In case developer would like to include \code{NA} and \code{Inf} values in the -filtered dataset. - -\if{html}{\out{
}}\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) +filtered dataset.\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf)) -}\if{html}{\out{
}} +} To initialize with specific variable filter with all values on start, one -can use - -\if{html}{\out{
}}\preformatted{list(Species = list()) -}\if{html}{\out{
}} +can use\preformatted{list(Species = list()) +} \code{filter} should be set with respect to the class of the column: \itemize{ @@ -75,9 +67,7 @@ defining initial values selected to filter. different way. Since it contains patient data with list of experiments, \code{filter} list should be created as follows: \cr -} - -\if{html}{\out{
}}\preformatted{list( +}\preformatted{list( = list( subjects = list( = ..., = ...), = list( @@ -88,7 +78,7 @@ different way. Since it contains patient data with list of experiments, ) ) ) -}\if{html}{\out{
}} +} By adding the \code{filterable} attribute it is possible to control which variables can be filtered for each dataset. See the example below where \code{ADSL} can only be filtered by \code{AGE}, \code{SEX} or \code{RACE}.} diff --git a/tests/testthat/test-init.R b/tests/testthat/test-init.R index e5f30ee060..90e4b36eef 100644 --- a/tests/testthat/test-init.R +++ b/tests/testthat/test-init.R @@ -129,3 +129,18 @@ testthat::test_that("init data accepts a list of TealDatasetConnector object", { NA ) }) + +testthat::test_that("init modules accepts a teal_modules object", { + mods <- modules(example_module(), example_module()) + testthat::expect_error(init(data = iris, modules = mods), NA) +}) + +testthat::test_that("init modules accepts a list of teal_module elements", { + mods <- list(example_module(), example_module()) + testthat::expect_error(init(data = iris, modules = mods), NA) +}) + +testthat::test_that("init modules accepts a teal_module object", { + mods <- example_module() + testthat::expect_error(init(data = iris, modules = mods), NA) +}) diff --git a/vignettes/adding-support-for-reporting.Rmd b/vignettes/adding-support-for-reporting.Rmd index af5695bfc7..8030594415 100644 --- a/vignettes/adding-support-for-reporting.Rmd +++ b/vignettes/adding-support-for-reporting.Rmd @@ -58,7 +58,7 @@ app <- init( dataset("IRIS", iris), dataset("MTCARS", mtcars) ), - modules = modules(teal_example_module()) + modules = teal_example_module() ) if (interactive()) shinyApp(app$ui, app$server) @@ -97,7 +97,7 @@ app <- init( dataset("IRIS", iris), dataset("MTCARS", mtcars) ), - modules = modules(example_module_with_reporting()) + modules = example_module_with_reporting() ) if (interactive()) shinyApp(app$ui, app$server) @@ -148,7 +148,7 @@ app <- init( dataset("IRIS", iris), dataset("MTCARS", mtcars) ), - modules = modules(example_module_with_reporting()) + modules = example_module_with_reporting() ) if (interactive()) shinyApp(app$ui, app$server) @@ -206,7 +206,7 @@ app <- init( dataset("IRIS", iris), dataset("MTCARS", mtcars) ), - modules = modules(example_module_with_reporting()) + modules = example_module_with_reporting() ) if (interactive()) shinyApp(app$ui, app$server) @@ -327,7 +327,7 @@ app <- init( dataset("IRIS", iris, code = "data(iris); IRIS <- iris"), check = FALSE ), - modules = modules( + modules = list( example_reporter_module(label = "with Reporter"), example_module(label = "without Reporter") ), diff --git a/vignettes/creating-custom-modules.Rmd b/vignettes/creating-custom-modules.Rmd index 381a311267..32f640b26b 100644 --- a/vignettes/creating-custom-modules.Rmd +++ b/vignettes/creating-custom-modules.Rmd @@ -190,14 +190,12 @@ app <- init( dataset("IRIS", iris, code = "IRIS <- iris"), check = TRUE ), - modules = modules( - tm_histogram_example( - label = "Simple Module", - histogram_var = data_extract_spec( - dataname = "IRIS", - select = select_spec( - choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width") - ) + modules = tm_histogram_example( + label = "Simple Module", + histogram_var = data_extract_spec( + dataname = "IRIS", + select = select_spec( + choices = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width") ) ) ), diff --git a/vignettes/including-adam-data-in-teal.Rmd b/vignettes/including-adam-data-in-teal.Rmd index a5dbb7a517..e5ed82db8d 100644 --- a/vignettes/including-adam-data-in-teal.Rmd +++ b/vignettes/including-adam-data-in-teal.Rmd @@ -83,7 +83,7 @@ example_data <- cdisc_data( app <- init( data = example_data, - modules = modules(example_module()) + modules = example_module() ) if (interactive()) { diff --git a/vignettes/including-general-data-in-teal.Rmd b/vignettes/including-general-data-in-teal.Rmd index 38d9a318be..793ef74b68 100644 --- a/vignettes/including-general-data-in-teal.Rmd +++ b/vignettes/including-general-data-in-teal.Rmd @@ -23,7 +23,7 @@ app <- init( dataset("IRIS", iris, code = "IRIS <- iris"), dataset("CARS", mtcars, code = "CARS <- mtcars") ), - modules = modules(example_module()) + modules = example_module() ) if (interactive()) { @@ -69,7 +69,7 @@ app <- init( fun_dataset_connector("PETS", fun = pet_generator, keys = "ID") ) %>% mutate_join_keys("PERSON", "PETS", c("ID" = "PERSON_ID")), - modules = modules(example_module()) + modules = example_module() ) if (interactive()) { diff --git a/vignettes/including-mae-data-in-teal.Rmd b/vignettes/including-mae-data-in-teal.Rmd index 2566801b6e..81e4432f3e 100644 --- a/vignettes/including-mae-data-in-teal.Rmd +++ b/vignettes/including-mae-data-in-teal.Rmd @@ -26,9 +26,7 @@ mae_d <- dataset("MAE", miniACC, metadata = list(type = "example")) app <- init( data = teal_data(mae_d), - modules = modules( - example_module() - ) + modules = example_module() ) if (interactive()) { diff --git a/vignettes/preprocessing-data.Rmd b/vignettes/preprocessing-data.Rmd index 4b0b6830bd..acbb5f1a96 100644 --- a/vignettes/preprocessing-data.Rmd +++ b/vignettes/preprocessing-data.Rmd @@ -41,7 +41,7 @@ cs_arm <- choices_selected(c("ACTARMCD", "ARMCD"), "ACTARMCD") app <- init( data = cdisc_data(cdisc_dataset("ADSL", adsl), code = get_code(file = "app.R")), - modules = modules(example_module()) + modules = example_module() ) shinyApp(app$ui, app$server) @@ -72,7 +72,7 @@ x <- init( code = get_code("app.R", exclude_comments = TRUE, read_sources = TRUE), check = TRUE ), - modules = modules(example_module()), + modules = example_module(), header = "Simple app with preprocessing", footer = tags$p(class = "text-muted", "Source: agile-R website") ) diff --git a/vignettes/teal-bs-themes.Rmd b/vignettes/teal-bs-themes.Rmd index 0483676b53..2c65fe1b0b 100644 --- a/vignettes/teal-bs-themes.Rmd +++ b/vignettes/teal-bs-themes.Rmd @@ -120,7 +120,7 @@ app <- init( dataset("IRIS", iris), dataset("MTCARS", mtcars) ), - modules = modules(example_module(), example_module()), + modules = list(example_module(), example_module()), header = "My first teal application" ) @@ -142,7 +142,7 @@ app <- init( dataset("IRIS", iris), dataset("MTCARS", mtcars) ), - modules = modules(example_module(), example_module()), + modules = list(example_module(), example_module()), header = "My first teal application" ) diff --git a/vignettes/teal.Rmd b/vignettes/teal.Rmd index 023f6ba5d4..33f1501ba6 100644 --- a/vignettes/teal.Rmd +++ b/vignettes/teal.Rmd @@ -41,7 +41,7 @@ app <- init( dataset("IRIS", iris), dataset("MTCARS", mtcars) ), - modules = modules(example_module()), + modules = example_module(), header = "My first teal application" ) From d8995026d7eda50dd9471e94284729bdb09ed0b7 Mon Sep 17 00:00:00 2001 From: Pawel Rucki Date: Wed, 11 Jan 2023 11:46:19 +0100 Subject: [PATCH 3/8] docs --- man/init.Rd | 30 ++++++++++++++++++++---------- man/module.Rd | 11 ++++++++--- man/srv_nested_tabs.Rd | 6 ++++-- man/srv_tabs_with_filters.Rd | 30 ++++++++++++++++++++---------- man/srv_teal.Rd | 30 ++++++++++++++++++++---------- man/srv_teal_with_splash.Rd | 30 ++++++++++++++++++++---------- 6 files changed, 92 insertions(+), 45 deletions(-) diff --git a/man/init.Rd b/man/init.Rd index ff336b8d2b..14f55d42db 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -35,26 +35,34 @@ The browser window title (defaults to the host URL of the page).} \item{filter}{(\code{list})\cr You can define filters that show when the app starts. List names should be named according to datanames passed to the \code{data} argument. -In case of data.frame` the list should be composed as follows:\preformatted{list( = list( = ..., = ...), +In case of data.frame` the list should be composed as follows: + +\if{html}{\out{
}}\preformatted{list( = list( = ..., = ...), = list(...), ...) -} +}\if{html}{\out{
}} For example, filters for variable \code{Sepal.Length} in \code{iris} can be specified as -follows:\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) +follows: + +\if{html}{\out{
}}\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0))) -} +}\if{html}{\out{
}} In case developer would like to include \code{NA} and \code{Inf} values in the -filtered dataset.\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) +filtered dataset. + +\if{html}{\out{
}}\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf)) -} +}\if{html}{\out{
}} To initialize with specific variable filter with all values on start, one -can use\preformatted{list(Species = list()) -} +can use + +\if{html}{\out{
}}\preformatted{list(Species = list()) +}\if{html}{\out{
}} \code{filter} should be set with respect to the class of the column: \itemize{ @@ -71,7 +79,9 @@ defining initial values selected to filter. different way. Since it contains patient data with list of experiments, \code{filter} list should be created as follows: \cr -}\preformatted{list( +} + +\if{html}{\out{
}}\preformatted{list( = list( subjects = list( = ..., = ...), = list( @@ -82,7 +92,7 @@ different way. Since it contains patient data with list of experiments, ) ) ) -} +}\if{html}{\out{
}} By adding the \code{filterable} attribute it is possible to control which variables can be filtered for each dataset. See the example below where \code{ADSL} can only be filtered by \code{AGE}, \code{SEX} or \code{RACE}.} diff --git a/man/module.Rd b/man/module.Rd index a184b686a4..9565154f30 100644 --- a/man/module.Rd +++ b/man/module.Rd @@ -8,9 +8,14 @@ \usage{ module( label = "module", - server = function(id, ...) { moduleServer(id, function(input, output, session) { - }) }, - ui = function(id, ...) { tags$p(paste0("This module has no UI (id: ", id, " )")) + server = function(id, ...) { + moduleServer(id, function(input, output, session) { + + }) + }, + ui = function(id, ...) { + tags$p(paste0("This module has no UI (id: ", id, " )")) + }, filters = "all", server_args = NULL, diff --git a/man/srv_nested_tabs.Rd b/man/srv_nested_tabs.Rd index ce215ebda1..89ae7bdd3e 100644 --- a/man/srv_nested_tabs.Rd +++ b/man/srv_nested_tabs.Rd @@ -48,13 +48,15 @@ This module calls recursively all elements of the \code{modules} returns one whi is currently active. To determine which module is active see the diagram. \if{html}{\figure{uml_nested_tabs.jpg}{options: width="75\%" alt="Figure: uml_nested_tabs.jpg"}} \if{latex}{\figure{uml_nested_tabs.jpg}{options: width=7cm}} -Above depicts hypothetical situation in which one has module structure defined in following way:\preformatted{+ root +Above depicts hypothetical situation in which one has module structure defined in following way: + +\if{html}{\out{
}}\preformatted{+ root + tab1 + test1 + test2 + tab2 + test3 -} +}\if{html}{\out{
}} \itemize{ \item \code{teal_module} returns self as a active module \item \code{teal_modules} returns module active within self which is determined by the \code{input$active_tab}. diff --git a/man/srv_tabs_with_filters.Rd b/man/srv_tabs_with_filters.Rd index b324f37a9d..5a3695ef37 100644 --- a/man/srv_tabs_with_filters.Rd +++ b/man/srv_tabs_with_filters.Rd @@ -32,26 +32,34 @@ more details.} \item{filter}{(\code{list})\cr You can define filters that show when the app starts. List names should be named according to datanames passed to the \code{data} argument. -In case of data.frame` the list should be composed as follows:\preformatted{list( = list( = ..., = ...), +In case of data.frame` the list should be composed as follows: + +\if{html}{\out{
}}\preformatted{list( = list( = ..., = ...), = list(...), ...) -} +}\if{html}{\out{
}} For example, filters for variable \code{Sepal.Length} in \code{iris} can be specified as -follows:\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) +follows: + +\if{html}{\out{
}}\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0))) -} +}\if{html}{\out{
}} In case developer would like to include \code{NA} and \code{Inf} values in the -filtered dataset.\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) +filtered dataset. + +\if{html}{\out{
}}\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf)) -} +}\if{html}{\out{
}} To initialize with specific variable filter with all values on start, one -can use\preformatted{list(Species = list()) -} +can use + +\if{html}{\out{
}}\preformatted{list(Species = list()) +}\if{html}{\out{
}} \code{filter} should be set with respect to the class of the column: \itemize{ @@ -68,7 +76,9 @@ defining initial values selected to filter. different way. Since it contains patient data with list of experiments, \code{filter} list should be created as follows: \cr -}\preformatted{list( +} + +\if{html}{\out{
}}\preformatted{list( = list( subjects = list( = ..., = ...), = list( @@ -79,7 +89,7 @@ different way. Since it contains patient data with list of experiments, ) ) ) -} +}\if{html}{\out{
}} By adding the \code{filterable} attribute it is possible to control which variables can be filtered for each dataset. See the example below where \code{ADSL} can only be filtered by \code{AGE}, \code{SEX} or \code{RACE}.} diff --git a/man/srv_teal.Rd b/man/srv_teal.Rd index f32fa6c2e8..b1cd99094d 100644 --- a/man/srv_teal.Rd +++ b/man/srv_teal.Rd @@ -23,26 +23,34 @@ returns the \code{TealData}, only evaluated once, \code{NULL} value is ignored} \item{filter}{(\code{list})\cr You can define filters that show when the app starts. List names should be named according to datanames passed to the \code{data} argument. -In case of data.frame` the list should be composed as follows:\preformatted{list( = list( = ..., = ...), +In case of data.frame` the list should be composed as follows: + +\if{html}{\out{
}}\preformatted{list( = list( = ..., = ...), = list(...), ...) -} +}\if{html}{\out{
}} For example, filters for variable \code{Sepal.Length} in \code{iris} can be specified as -follows:\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) +follows: + +\if{html}{\out{
}}\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0))) -} +}\if{html}{\out{
}} In case developer would like to include \code{NA} and \code{Inf} values in the -filtered dataset.\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) +filtered dataset. + +\if{html}{\out{
}}\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf)) -} +}\if{html}{\out{
}} To initialize with specific variable filter with all values on start, one -can use\preformatted{list(Species = list()) -} +can use + +\if{html}{\out{
}}\preformatted{list(Species = list()) +}\if{html}{\out{
}} \code{filter} should be set with respect to the class of the column: \itemize{ @@ -59,7 +67,9 @@ defining initial values selected to filter. different way. Since it contains patient data with list of experiments, \code{filter} list should be created as follows: \cr -}\preformatted{list( +} + +\if{html}{\out{
}}\preformatted{list( = list( subjects = list( = ..., = ...), = list( @@ -70,7 +80,7 @@ different way. Since it contains patient data with list of experiments, ) ) ) -} +}\if{html}{\out{
}} By adding the \code{filterable} attribute it is possible to control which variables can be filtered for each dataset. See the example below where \code{ADSL} can only be filtered by \code{AGE}, \code{SEX} or \code{RACE}.} diff --git a/man/srv_teal_with_splash.Rd b/man/srv_teal_with_splash.Rd index 4a9d2fd640..2b76b6ca1b 100644 --- a/man/srv_teal_with_splash.Rd +++ b/man/srv_teal_with_splash.Rd @@ -31,26 +31,34 @@ more details.} \item{filter}{(\code{list})\cr You can define filters that show when the app starts. List names should be named according to datanames passed to the \code{data} argument. -In case of data.frame` the list should be composed as follows:\preformatted{list( = list( = ..., = ...), +In case of data.frame` the list should be composed as follows: + +\if{html}{\out{
}}\preformatted{list( = list( = ..., = ...), = list(...), ...) -} +}\if{html}{\out{
}} For example, filters for variable \code{Sepal.Length} in \code{iris} can be specified as -follows:\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) +follows: + +\if{html}{\out{
}}\preformatted{list(iris = list(Sepal.Length = list(selected = c(5.0, 7.0)))) # or list(iris = list(Sepal.Length = c(5.0, 7.0))) -} +}\if{html}{\out{
}} In case developer would like to include \code{NA} and \code{Inf} values in the -filtered dataset.\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) +filtered dataset. + +\if{html}{\out{
}}\preformatted{list(Species = list(selected = c(5.0, 7.0), keep_na = TRUE, keep_inf = TRUE)) list(Species = c(c(5.0, 7.0), NA, Inf)) -} +}\if{html}{\out{
}} To initialize with specific variable filter with all values on start, one -can use\preformatted{list(Species = list()) -} +can use + +\if{html}{\out{
}}\preformatted{list(Species = list()) +}\if{html}{\out{
}} \code{filter} should be set with respect to the class of the column: \itemize{ @@ -67,7 +75,9 @@ defining initial values selected to filter. different way. Since it contains patient data with list of experiments, \code{filter} list should be created as follows: \cr -}\preformatted{list( +} + +\if{html}{\out{
}}\preformatted{list( = list( subjects = list( = ..., = ...), = list( @@ -78,7 +88,7 @@ different way. Since it contains patient data with list of experiments, ) ) ) -} +}\if{html}{\out{
}} By adding the \code{filterable} attribute it is possible to control which variables can be filtered for each dataset. See the example below where \code{ADSL} can only be filtered by \code{AGE}, \code{SEX} or \code{RACE}.} From 453b36a9892d733c792442d60eedf96d517739cb Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Wed, 11 Jan 2023 13:10:30 +0000 Subject: [PATCH 4/8] update man pages --- R/init.R | 12 ++++++------ R/module_teal_with_splash.R | 3 +++ man/init.Rd | 6 ++++-- man/modules_depth.Rd | 6 ++++-- man/srv_nested_tabs.Rd | 4 ++-- man/srv_tabs_with_filters.Rd | 4 ++-- man/srv_teal.Rd | 6 ++++-- man/srv_teal_with_splash.Rd | 4 ++-- man/ui_nested_tabs.Rd | 6 ++++-- man/ui_tabs_with_filters.Rd | 6 ++++-- 10 files changed, 35 insertions(+), 22 deletions(-) diff --git a/R/init.R b/R/init.R index c953d414cf..8b4b9bd161 100644 --- a/R/init.R +++ b/R/init.R @@ -23,8 +23,10 @@ #' NOTE: teal does not guarantee reproducibility of the code when names of the list elements #' do not match the original object names. To ensure reproducibility please use [teal.data::teal_data()] #' or [teal.data::cdisc_data()] with `check = TRUE` enabled. -#' @param modules (`list` or `teal_modules`)\cr -#' nested list of `teal_modules` or `module` objects. See [modules()] and [module()] for +#' @param modules (`list`, `teal_modules` or `teal_module`)\cr +#' nested list of `teal_modules` or `teal_module` objects or a single +#' `teal_modules` or `teal_module` object. These are the specific output modules which +#' will be displayed in the teal application. See [modules()] and [module()] for #' more details. #' @param title (`NULL` or `character`)\cr #' The browser window title (defaults to the host URL of the page). @@ -161,16 +163,14 @@ init <- function(data, checkmate::assert_string(title, null.ok = TRUE) checkmate::assert_class(data, "TealData") - checkmate::assert_multi_class(modules, c("teal_module", "list", "teal_modules")) + checkmate::check_list(modules) + checkmate::check_class(modules, "teal_modules") checkmate::assert_list(filter, min.len = 0, names = "unique") checkmate::assert_subset(names(filter), choices = teal.data::get_dataname(data)) checkmate::assert_character(id, max.len = 1, any.missing = FALSE) teal.logger::log_system_info() - if (is(modules, "teal_module")) { - modules <- teal::modules(modules) - } if (is(modules, "list")) { modules <- do.call(teal::modules, modules) } diff --git a/R/module_teal_with_splash.R b/R/module_teal_with_splash.R index ae40a5d838..0171cee56b 100644 --- a/R/module_teal_with_splash.R +++ b/R/module_teal_with_splash.R @@ -48,6 +48,9 @@ ui_teal_with_splash <- function(id, #' Please also refer to the doc of [init()]. #' #' @inheritParams init +#' @param modules `teal_modules` object containing the output modules which +#' will be displayed in the teal application. See [modules()] and [module()] for +#' more details. #' @inheritParams shiny::moduleServer #' @return `reactive`, return value of [srv_teal()] #' @export diff --git a/man/init.Rd b/man/init.Rd index 14f55d42db..f233171851 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -25,8 +25,10 @@ NOTE: teal does not guarantee reproducibility of the code when names of the list do not match the original object names. To ensure reproducibility please use \code{\link[teal.data:teal_data]{teal.data::teal_data()}} or \code{\link[teal.data:cdisc_data]{teal.data::cdisc_data()}} with \code{check = TRUE} enabled.} -\item{modules}{(\code{list} or \code{teal_modules})\cr -nested list of \code{teal_modules} or \code{module} objects. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for +\item{modules}{(\code{list}, \code{teal_modules} or \code{teal_module})\cr +nested list of \code{teal_modules} or \code{teal_module} objects or a single +\code{teal_modules} or \code{teal_module} object. These are the specific output modules which +will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{title}{(\code{NULL} or \code{character})\cr diff --git a/man/modules_depth.Rd b/man/modules_depth.Rd index 85cfb7be75..d945fa439c 100644 --- a/man/modules_depth.Rd +++ b/man/modules_depth.Rd @@ -7,8 +7,10 @@ modules_depth(modules, depth = 0L) } \arguments{ -\item{modules}{(\code{list} or \code{teal_modules})\cr -nested list of \code{teal_modules} or \code{module} objects. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for +\item{modules}{(\code{list}, \code{teal_modules} or \code{teal_module})\cr +nested list of \code{teal_modules} or \code{teal_module} objects or a single +\code{teal_modules} or \code{teal_module} object. These are the specific output modules which +will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{depth}{optional, integer determining current depth level} diff --git a/man/srv_nested_tabs.Rd b/man/srv_nested_tabs.Rd index 89ae7bdd3e..6d9e4e83af 100644 --- a/man/srv_nested_tabs.Rd +++ b/man/srv_nested_tabs.Rd @@ -31,8 +31,8 @@ is then preferred to this function.} object to store filter state and filtered datasets, shared across modules. For more details see \code{\link[teal.slice:FilteredData]{teal.slice::FilteredData}}.} -\item{modules}{(\code{list} or \code{teal_modules})\cr -nested list of \code{teal_modules} or \code{module} objects. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for +\item{modules}{\code{teal_modules} object containing the output modules which +will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{reporter}{(\code{Reporter}) object from \code{teal.reporter}} diff --git a/man/srv_tabs_with_filters.Rd b/man/srv_tabs_with_filters.Rd index 5a3695ef37..e50098efea 100644 --- a/man/srv_tabs_with_filters.Rd +++ b/man/srv_tabs_with_filters.Rd @@ -23,8 +23,8 @@ is then preferred to this function.} object to store filter state and filtered datasets, shared across modules. For more details see \code{\link[teal.slice:FilteredData]{teal.slice::FilteredData}}.} -\item{modules}{(\code{list} or \code{teal_modules})\cr -nested list of \code{teal_modules} or \code{module} objects. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for +\item{modules}{\code{teal_modules} object containing the output modules which +will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{reporter}{(\code{Reporter}) object from \code{teal.reporter}} diff --git a/man/srv_teal.Rd b/man/srv_teal.Rd index b1cd99094d..a6d631f181 100644 --- a/man/srv_teal.Rd +++ b/man/srv_teal.Rd @@ -13,8 +13,10 @@ the server function must be called with \code{\link[shiny:moduleServer]{shiny::m See the vignette for an example. However, \code{\link[=ui_teal_with_splash]{ui_teal_with_splash()}} is then preferred to this function.} -\item{modules}{(\code{list} or \code{teal_modules})\cr -nested list of \code{teal_modules} or \code{module} objects. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for +\item{modules}{(\code{list}, \code{teal_modules} or \code{teal_module})\cr +nested list of \code{teal_modules} or \code{teal_module} objects or a single +\code{teal_modules} or \code{teal_module} object. These are the specific output modules which +will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{raw_data}{(\code{reactive})\cr diff --git a/man/srv_teal_with_splash.Rd b/man/srv_teal_with_splash.Rd index 2b76b6ca1b..f2701cb2fd 100644 --- a/man/srv_teal_with_splash.Rd +++ b/man/srv_teal_with_splash.Rd @@ -24,8 +24,8 @@ NOTE: teal does not guarantee reproducibility of the code when names of the list do not match the original object names. To ensure reproducibility please use \code{\link[teal.data:teal_data]{teal.data::teal_data()}} or \code{\link[teal.data:cdisc_data]{teal.data::cdisc_data()}} with \code{check = TRUE} enabled.} -\item{modules}{(\code{list} or \code{teal_modules})\cr -nested list of \code{teal_modules} or \code{module} objects. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for +\item{modules}{\code{teal_modules} object containing the output modules which +will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{filter}{(\code{list})\cr diff --git a/man/ui_nested_tabs.Rd b/man/ui_nested_tabs.Rd index 49ce7d22de..4d26e5e3d6 100644 --- a/man/ui_nested_tabs.Rd +++ b/man/ui_nested_tabs.Rd @@ -19,8 +19,10 @@ ui_nested_tabs(id, modules, datasets, depth = 0L) \item{id}{(\code{character(1)})\cr module id} -\item{modules}{(\code{list} or \code{teal_modules})\cr -nested list of \code{teal_modules} or \code{module} objects. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for +\item{modules}{(\code{list}, \code{teal_modules} or \code{teal_module})\cr +nested list of \code{teal_modules} or \code{teal_module} objects or a single +\code{teal_modules} or \code{teal_module} object. These are the specific output modules which +will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{datasets}{(\code{FilteredData})\cr diff --git a/man/ui_tabs_with_filters.Rd b/man/ui_tabs_with_filters.Rd index 9b49723580..3b74370656 100644 --- a/man/ui_tabs_with_filters.Rd +++ b/man/ui_tabs_with_filters.Rd @@ -10,8 +10,10 @@ ui_tabs_with_filters(id, modules, datasets) \item{id}{(\code{character(1)})\cr module id} -\item{modules}{(\code{list} or \code{teal_modules})\cr -nested list of \code{teal_modules} or \code{module} objects. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for +\item{modules}{(\code{list}, \code{teal_modules} or \code{teal_module})\cr +nested list of \code{teal_modules} or \code{teal_module} objects or a single +\code{teal_modules} or \code{teal_module} object. These are the specific output modules which +will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{datasets}{(\code{FilteredData})\cr From 4e9fcd477ff17a0e95c497d47ee365b26d89956a Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Wed, 11 Jan 2023 13:13:20 +0000 Subject: [PATCH 5/8] more docs --- R/module_tabs_with_filters.R | 2 ++ man/ui_nested_tabs.Rd | 7 ++----- man/ui_tabs_with_filters.Rd | 7 ++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/R/module_tabs_with_filters.R b/R/module_tabs_with_filters.R index bc1ca784ad..81132bf2c0 100644 --- a/R/module_tabs_with_filters.R +++ b/R/module_tabs_with_filters.R @@ -14,6 +14,8 @@ #' panel is inserted at the right of the modules at depth 1 and not at the leaves. #' #' @inheritParams ui_teal_with_splash +#' @param modules (`teal_modules`) the modules which will be displayed in the teal application. +#' See [modules()] and [module()] for more details. #' @inheritParams init #' @param datasets (`FilteredData`)\cr #' object to store filter state and filtered datasets, shared across modules. For more diff --git a/man/ui_nested_tabs.Rd b/man/ui_nested_tabs.Rd index 4d26e5e3d6..9c86fcf67b 100644 --- a/man/ui_nested_tabs.Rd +++ b/man/ui_nested_tabs.Rd @@ -19,11 +19,8 @@ ui_nested_tabs(id, modules, datasets, depth = 0L) \item{id}{(\code{character(1)})\cr module id} -\item{modules}{(\code{list}, \code{teal_modules} or \code{teal_module})\cr -nested list of \code{teal_modules} or \code{teal_module} objects or a single -\code{teal_modules} or \code{teal_module} object. These are the specific output modules which -will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for -more details.} +\item{modules}{(\code{teal_modules}) the modules which will be displayed in the teal application. +See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{datasets}{(\code{FilteredData})\cr object to store filter state and filtered datasets, shared across modules. For more diff --git a/man/ui_tabs_with_filters.Rd b/man/ui_tabs_with_filters.Rd index 3b74370656..f0641913d5 100644 --- a/man/ui_tabs_with_filters.Rd +++ b/man/ui_tabs_with_filters.Rd @@ -10,11 +10,8 @@ ui_tabs_with_filters(id, modules, datasets) \item{id}{(\code{character(1)})\cr module id} -\item{modules}{(\code{list}, \code{teal_modules} or \code{teal_module})\cr -nested list of \code{teal_modules} or \code{teal_module} objects or a single -\code{teal_modules} or \code{teal_module} object. These are the specific output modules which -will be displayed in the teal application. See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for -more details.} +\item{modules}{(\code{teal_modules}) the modules which will be displayed in the teal application. +See \code{\link[=modules]{modules()}} and \code{\link[=module]{module()}} for more details.} \item{datasets}{(\code{FilteredData})\cr object to store filter state and filtered datasets, shared across modules. For more From 2a4a75621483908aa8a68cb3dd9dd92b9b75050c Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Thu, 12 Jan 2023 08:09:20 +0000 Subject: [PATCH 6/8] revert changes --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index 8b4b9bd161..aa8e3230c7 100644 --- a/R/init.R +++ b/R/init.R @@ -171,7 +171,7 @@ init <- function(data, teal.logger::log_system_info() - if (is(modules, "list")) { + if (is(modules, "teal_module")) { modules <- do.call(teal::modules, modules) } From a12813eb28e6163e222c00bebb7593208e21e4b6 Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Thu, 12 Jan 2023 08:13:47 +0000 Subject: [PATCH 7/8] Apply suggestions from code review Signed-off-by: Nikolas Burkoff --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index aa8e3230c7..ff6e262fdf 100644 --- a/R/init.R +++ b/R/init.R @@ -171,7 +171,7 @@ init <- function(data, teal.logger::log_system_info() - if (is(modules, "teal_module")) { + if (is(modules, "teal_module") || is(modules, "list")) { modules <- do.call(teal::modules, modules) } From a9cdc6efb1ab5dbac256fc60910db0ad83890b52 Mon Sep 17 00:00:00 2001 From: Pawel Rucki Date: Thu, 12 Jan 2023 09:48:14 +0100 Subject: [PATCH 8/8] revert Nik's changes --- R/init.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/init.R b/R/init.R index ff6e262fdf..497c22d05e 100644 --- a/R/init.R +++ b/R/init.R @@ -163,15 +163,17 @@ init <- function(data, checkmate::assert_string(title, null.ok = TRUE) checkmate::assert_class(data, "TealData") - checkmate::check_list(modules) - checkmate::check_class(modules, "teal_modules") + checkmate::assert_multi_class(modules, c("teal_module", "list", "teal_modules")) checkmate::assert_list(filter, min.len = 0, names = "unique") checkmate::assert_subset(names(filter), choices = teal.data::get_dataname(data)) checkmate::assert_character(id, max.len = 1, any.missing = FALSE) teal.logger::log_system_info() - if (is(modules, "teal_module") || is(modules, "list")) { + if (is(modules, "teal_module")) { + modules <- list(modules) + } + if (is(modules, "list")) { modules <- do.call(teal::modules, modules) }