From 6f21eeaee37cf5aa2bb698b5ceca6f06af78d3c0 Mon Sep 17 00:00:00 2001 From: vedhav Date: Tue, 8 Oct 2024 18:07:31 +0530 Subject: [PATCH 1/5] fix: pass the datanames of `teal_data` to the filter panel if provided. --- R/utils.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index e5830bf0ca..9afd0f0ef2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -74,10 +74,13 @@ get_teal_bs_theme <- function() { #' @param datanames (`character`) vector of data set names to include; must be subset of `datanames(x)` #' @return A `FilteredData` object. #' @keywords internal -teal_data_to_filtered_data <- function(x, datanames = ls(teal.code::get_env(x))) { +teal_data_to_filtered_data <- function(x, datanames = teal.data::datanames(data)) { checkmate::assert_class(x, "teal_data") checkmate::assert_character(datanames, min.chars = 1L, any.missing = FALSE) # Otherwise, FilteredData will be created in the modules' scope later + if (!length(datanames)) { + datanames <- ls(teal.code::get_env(x)) + } teal.slice::init_filtered_data( x = Filter( length, From 7ecde7609ce909b8ed20551fdb10fa349c8798dd Mon Sep 17 00:00:00 2001 From: vedhav Date: Tue, 8 Oct 2024 18:37:20 +0530 Subject: [PATCH 2/5] fix: propagate the datanames to the active filter summary and modules --- R/module_init_data.R | 3 +++ R/module_nested_tabs.R | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/R/module_init_data.R b/R/module_init_data.R index 8c09936a75..fe28a574ff 100644 --- a/R/module_init_data.R +++ b/R/module_init_data.R @@ -111,6 +111,9 @@ srv_init_data <- function(id, data) { ) tdata@verified <- data@verified + if (length(datanames(data))) { + datanames(tdata) <- datanames(data) + } tdata } diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index cae7d9acca..351767236c 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -359,7 +359,9 @@ srv_teal_module.teal_module <- function(id, .resolve_module_datanames <- function(data, modules) { stopifnot("data_rv must be teal_data object." = inherits(data, "teal_data")) - if (is.null(modules$datanames) || identical(modules$datanames, "all")) { + if (length(datanames(data))) { + .topologically_sort_datanames(datanames(data), teal.data::join_keys(data)) + } else if (is.null(modules$datanames) || identical(modules$datanames, "all")) { .topologically_sort_datanames(ls(teal.code::get_env(data)), teal.data::join_keys(data)) } else { intersect( From 99006282bcdc4c5ecb50916b44eb6a5d34e2595f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:14:12 +0000 Subject: [PATCH 3/5] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/teal_data_to_filtered_data.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/teal_data_to_filtered_data.Rd b/man/teal_data_to_filtered_data.Rd index d6eecd90cd..be4e1c9a91 100644 --- a/man/teal_data_to_filtered_data.Rd +++ b/man/teal_data_to_filtered_data.Rd @@ -4,7 +4,7 @@ \alias{teal_data_to_filtered_data} \title{Create a \code{FilteredData}} \usage{ -teal_data_to_filtered_data(x, datanames = ls(teal.code::get_env(x))) +teal_data_to_filtered_data(x, datanames = teal.data::datanames(data)) } \arguments{ \item{x}{(\code{teal_data}) object} From 1d367ac96f977dacc417c3ae90383ab9dca9ecad Mon Sep 17 00:00:00 2001 From: vedhav Date: Tue, 8 Oct 2024 19:02:27 +0530 Subject: [PATCH 4/5] chore: fix typo --- R/utils.R | 2 +- man/teal_data_to_filtered_data.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index 9afd0f0ef2..7399885afb 100644 --- a/R/utils.R +++ b/R/utils.R @@ -74,7 +74,7 @@ get_teal_bs_theme <- function() { #' @param datanames (`character`) vector of data set names to include; must be subset of `datanames(x)` #' @return A `FilteredData` object. #' @keywords internal -teal_data_to_filtered_data <- function(x, datanames = teal.data::datanames(data)) { +teal_data_to_filtered_data <- function(x, datanames = teal.data::datanames(x)) { checkmate::assert_class(x, "teal_data") checkmate::assert_character(datanames, min.chars = 1L, any.missing = FALSE) # Otherwise, FilteredData will be created in the modules' scope later diff --git a/man/teal_data_to_filtered_data.Rd b/man/teal_data_to_filtered_data.Rd index be4e1c9a91..cd649f4a35 100644 --- a/man/teal_data_to_filtered_data.Rd +++ b/man/teal_data_to_filtered_data.Rd @@ -4,7 +4,7 @@ \alias{teal_data_to_filtered_data} \title{Create a \code{FilteredData}} \usage{ -teal_data_to_filtered_data(x, datanames = teal.data::datanames(data)) +teal_data_to_filtered_data(x, datanames = teal.data::datanames(x)) } \arguments{ \item{x}{(\code{teal_data}) object} From 01441765cf231ff168fdc06e4891355f408d718b Mon Sep 17 00:00:00 2001 From: vedhav Date: Tue, 8 Oct 2024 19:06:05 +0530 Subject: [PATCH 5/5] chore: add a test to check if FilterData object is created for limited datasets --- tests/testthat/test-utils.R | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 4904c46461..f83b0319ca 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -45,6 +45,20 @@ test_that("teal_data_to_filtered_data return FilteredData class", { testthat::expect_s3_class(teal_data_to_filtered_data(teal_data), "FilteredData") }) +test_that("teal_data_to_filtered_data creates FilterData class with datanames that are passed", { + teal_data <- within( + teal.data::teal_data(), + { + iris <- head(iris) + mtcars <- head(mtcars) + } + ) + teal.data::datanames(teal_data) <- "iris" + + fd <- teal_data_to_filtered_data(teal_data) + testthat::expect_equal(fd$datanames(), "iris") +}) + test_that("validate_app_title_tag works on validating the title tag", { valid_title <- tags$head( tags$title("title"),