From 9b817f98f4b805229bd89b904a2e9f3b123aeefe Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Tue, 23 Aug 2022 14:24:08 +0100 Subject: [PATCH 1/7] add set filter --- NEWS.md | 1 + R/init.R | 5 ++++- R/module_tabs_with_filters.R | 5 +++++ man/init.Rd | 7 +++++-- man/srv_tabs_with_filters.Rd | 5 ++++- man/srv_teal.Rd | 5 ++++- man/srv_teal_with_splash.Rd | 5 ++++- 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9e665f1113..e88bf5b33b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ ### Enhancements +* Added option to choose which variables can be filtered in the filter panel by using the `filterable` attributes of the lists of the `filter` argument of `init`. * `teal_module` having `data` argument in its arguments will receive a list of reactive filter data with `"code"` and `"join_keys"` attributes. * Updated the internals of `module_teal` to reflect changes in `teal.slice`. * `teal_module` having `filter_panel_api` argument in its arguments will receive a `FilterPanelAPI` object. diff --git a/R/init.R b/R/init.R index e36f1426f8..c49b05a9f6 100644 --- a/R/init.R +++ b/R/init.R @@ -86,6 +86,9 @@ #' ) #' ) #' ``` +#' By adding the `filterable` attribute it is possible to control which variables can be filtered for each +#' dataset. See the example below where `ADSL` can only be filtered by `AGE`, `SEX` or `RACE`. +#' #' @param header (`character` or `shiny.tag`) \cr #' the header of the app. Note shiny code placed here (and in the footer #' argument) will be placed in the app's `ui` function so code which needs to be placed in the `ui` function @@ -137,7 +140,7 @@ #' ) #' ), #' title = "App title", -#' filter = list(ADSL = list(AGE = list())), +#' filter = list(ADSL = structure(list(AGE = list()), "filterable" = c("AGE", "SEX", "RACE"))), #' header = tags$h1("Sample App"), #' footer = tags$p("Copyright 2017 - 2020") #' ) diff --git a/R/module_tabs_with_filters.R b/R/module_tabs_with_filters.R index 02ee21acba..29efb717c1 100644 --- a/R/module_tabs_with_filters.R +++ b/R/module_tabs_with_filters.R @@ -153,6 +153,11 @@ srv_tabs_with_filters <- function(id, datasets, modules, reporter = teal.reporte logger::log_trace( "srv_tabs_with_filters initializing the module with datasets { paste(datasets$datanames(), collapse = ' ') }." ) + + lapply(names(filter), function(filter_dataname) { + datasets$set_filterable_varnames(filter_dataname, attr(filter[[filter_dataname]], "filterable")) + }) + active_module <- srv_nested_tabs(id = "root", datasets = datasets, modules = modules, reporter = reporter) active_datanames <- eventReactive( diff --git a/man/init.Rd b/man/init.Rd index 8ae40b59d4..02426a54a1 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -91,7 +91,10 @@ different way. Since it contains patient data with list of experiments, ) ) ) -}\if{html}{\out{}}} +}\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}.} \item{header}{(\code{character} or \code{shiny.tag}) \cr the header of the app. Note shiny code placed here (and in the footer @@ -152,7 +155,7 @@ app <- init( ) ), title = "App title", - filter = list(ADSL = list(AGE = list())), + filter = list(ADSL = structure(list(AGE = list()), "filterable" = c("AGE", "SEX", "RACE"))), header = tags$h1("Sample App"), footer = tags$p("Copyright 2017 - 2020") ) diff --git a/man/srv_tabs_with_filters.Rd b/man/srv_tabs_with_filters.Rd index a2b1cc1348..5a3695ef37 100644 --- a/man/srv_tabs_with_filters.Rd +++ b/man/srv_tabs_with_filters.Rd @@ -89,7 +89,10 @@ different way. Since it contains patient data with list of experiments, ) ) ) -}\if{html}{\out{}}} +}\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}.} } \value{ \code{reactive} currently selected active_module diff --git a/man/srv_teal.Rd b/man/srv_teal.Rd index 9cfd14ba0f..b1cd99094d 100644 --- a/man/srv_teal.Rd +++ b/man/srv_teal.Rd @@ -80,7 +80,10 @@ different way. Since it contains patient data with list of experiments, ) ) ) -}\if{html}{\out{}}} +}\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}.} } \value{ \code{reactive} which returns the currently active module diff --git a/man/srv_teal_with_splash.Rd b/man/srv_teal_with_splash.Rd index 81297b9c6e..ee726529f9 100644 --- a/man/srv_teal_with_splash.Rd +++ b/man/srv_teal_with_splash.Rd @@ -87,7 +87,10 @@ different way. Since it contains patient data with list of experiments, ) ) ) -}\if{html}{\out{}}} +}\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}.} } \value{ \code{reactive}, return value of \code{\link[=srv_teal]{srv_teal()}} From 993e28f388bb06d27c145a721313a10f5ecf0c4b Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Wed, 24 Aug 2022 13:46:18 +0100 Subject: [PATCH 2/7] Update NEWS.md Co-authored-by: Maciej Nasinski --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e88bf5b33b..83230460b9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ ### Enhancements -* Added option to choose which variables can be filtered in the filter panel by using the `filterable` attributes of the lists of the `filter` argument of `init`. +* Added option to choose which variables can be filtered in the filter panel by using the `filterable` attributes for the per-dataset lists in the `filter` argument of `init`. * `teal_module` having `data` argument in its arguments will receive a list of reactive filter data with `"code"` and `"join_keys"` attributes. * Updated the internals of `module_teal` to reflect changes in `teal.slice`. * `teal_module` having `filter_panel_api` argument in its arguments will receive a `FilterPanelAPI` object. From f7baa0d8e6e801c3ad951dac9e5069b8d14fd074 Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Wed, 24 Aug 2022 13:46:33 +0100 Subject: [PATCH 3/7] Update R/module_tabs_with_filters.R Co-authored-by: Maciej Nasinski --- R/module_tabs_with_filters.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/module_tabs_with_filters.R b/R/module_tabs_with_filters.R index 29efb717c1..70238e3eaa 100644 --- a/R/module_tabs_with_filters.R +++ b/R/module_tabs_with_filters.R @@ -154,9 +154,10 @@ srv_tabs_with_filters <- function(id, datasets, modules, reporter = teal.reporte "srv_tabs_with_filters initializing the module with datasets { paste(datasets$datanames(), collapse = ' ') }." ) - lapply(names(filter), function(filter_dataname) { - datasets$set_filterable_varnames(filter_dataname, attr(filter[[filter_dataname]], "filterable")) - }) + # set filterable variables for each dataset + for (filter_dataname in names(filter)) { + datasets$set_filterable_varnames(filter_dataname, attr(filter[[filter_dataname]], "filterable")) + } active_module <- srv_nested_tabs(id = "root", datasets = datasets, modules = modules, reporter = reporter) From 2239b9d2581dc5aec406a515367f56f956f6837d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Aug 2022 12:49:06 +0000 Subject: [PATCH 4/7] [skip actions] Restyle files --- R/module_tabs_with_filters.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/module_tabs_with_filters.R b/R/module_tabs_with_filters.R index 70238e3eaa..6b8855f1a8 100644 --- a/R/module_tabs_with_filters.R +++ b/R/module_tabs_with_filters.R @@ -154,10 +154,10 @@ srv_tabs_with_filters <- function(id, datasets, modules, reporter = teal.reporte "srv_tabs_with_filters initializing the module with datasets { paste(datasets$datanames(), collapse = ' ') }." ) - # set filterable variables for each dataset - for (filter_dataname in names(filter)) { - datasets$set_filterable_varnames(filter_dataname, attr(filter[[filter_dataname]], "filterable")) - } + # set filterable variables for each dataset + for (filter_dataname in names(filter)) { + datasets$set_filterable_varnames(filter_dataname, attr(filter[[filter_dataname]], "filterable")) + } active_module <- srv_nested_tabs(id = "root", datasets = datasets, modules = modules, reporter = reporter) From 717b2d25de3db99e483132f7aec92ad86bc4f8a6 Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Wed, 24 Aug 2022 14:25:27 +0100 Subject: [PATCH 5/7] trigger From 617c3b3150824371f2f1c69272a655b14582f840 Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Fri, 2 Sep 2022 13:12:24 +0100 Subject: [PATCH 6/7] Update R/init.R Co-authored-by: Pawel Rucki --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index c49b05a9f6..283218f23b 100644 --- a/R/init.R +++ b/R/init.R @@ -140,7 +140,7 @@ #' ) #' ), #' title = "App title", -#' filter = list(ADSL = structure(list(AGE = list()), "filterable" = c("AGE", "SEX", "RACE"))), +#' filter = list(ADSL = structure(list(AGE = list()), filterable = c("AGE", "SEX", "RACE"))), #' header = tags$h1("Sample App"), #' footer = tags$p("Copyright 2017 - 2020") #' ) From 055279d15352e001746ed5a0c0f7f9ca7868b2b9 Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Fri, 2 Sep 2022 13:13:37 +0100 Subject: [PATCH 7/7] roxygen --- man/init.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/init.Rd b/man/init.Rd index 02426a54a1..b3d191be5e 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -155,7 +155,7 @@ app <- init( ) ), title = "App title", - filter = list(ADSL = structure(list(AGE = list()), "filterable" = c("AGE", "SEX", "RACE"))), + filter = list(ADSL = structure(list(AGE = list()), filterable = c("AGE", "SEX", "RACE"))), header = tags$h1("Sample App"), footer = tags$p("Copyright 2017 - 2020") )