Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add set filter #724

Merged
merged 10 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Enhancements

* 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.
Expand Down
5 changes: 4 additions & 1 deletion R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
#' )
Expand Down
6 changes: 6 additions & 0 deletions R/module_tabs_with_filters.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ 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 = ' ') }."
)

# 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)

active_datanames <- eventReactive(
Expand Down
7 changes: 5 additions & 2 deletions man/init.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/srv_tabs_with_filters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/srv_teal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/srv_teal_with_splash.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.