diff --git a/R/tm_data_table.R b/R/tm_data_table.R index f18c5d05b..4e3c64c2f 100644 --- a/R/tm_data_table.R +++ b/R/tm_data_table.R @@ -136,7 +136,7 @@ tm_data_table <- function(label = "Data Table", ui = ui_page_data_table, datanames = datanames, server_args = list( - datanames = datanames, + datanames = if (is.null(datanames)) "all" else datanames, variables_selected = variables_selected, dt_args = dt_args, dt_options = dt_options, @@ -201,7 +201,8 @@ srv_page_data_table <- function(id, datanames <- Filter(function(name) { is.data.frame(isolate(data())[[name]]) - }, datanames) + }, if (identical(datanames, "all")) names(isolate(data())) else datanames) + output$dataset_table <- renderUI({ do.call( diff --git a/R/tm_front_page.R b/R/tm_front_page.R index 6e3bd4c7b..4a5f21a14 100644 --- a/R/tm_front_page.R +++ b/R/tm_front_page.R @@ -72,7 +72,7 @@ tm_front_page <- function(label = "Front page", additional_tags = tagList(), footnotes = character(0), show_metadata = deprecated(), - datanames = if (missing(show_metadata)) "all" else NULL) { + datanames = if (missing(show_metadata)) NULL else "all") { message("Initializing tm_front_page") # Start of assertions diff --git a/R/tm_missing_data.R b/R/tm_missing_data.R index 6b20c4325..06ca7466a 100644 --- a/R/tm_missing_data.R +++ b/R/tm_missing_data.R @@ -152,11 +152,18 @@ tm_missing_data <- function(label = "Missing data", assert_decorators(decorators, names = available_decorators) # End of assertions + datanames_module <- if (identical(datanames, "all") || is.null(datanames)) { + datanames + } else { + union(datanames, parent_dataname) + } + ans <- module( label, server = srv_page_missing_data, - datanames = if (identical(datanames, "all")) union(datanames, parent_dataname) else "all", + datanames = datanames_module, server_args = list( + datanames = if (is.null(datanames)) "all" else datanames, parent_dataname = parent_dataname, plot_height = plot_height, plot_width = plot_width, @@ -198,18 +205,17 @@ ui_page_missing_data <- function(id, pre_output = NULL, post_output = NULL) { } # Server function for the missing data module (all datasets) -srv_page_missing_data <- function(id, data, reporter, filter_panel_api, parent_dataname, +srv_page_missing_data <- function(id, data, reporter, filter_panel_api, datanames, parent_dataname, plot_height, plot_width, ggplot2_args, ggtheme, decorators) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") moduleServer(id, function(input, output, session) { teal.logger::log_shiny_input_changes(input, namespace = "teal.modules.general") - datanames <- isolate(names(data())) - datanames <- Filter( - function(name) is.data.frame(isolate(data())[[name]]), - datanames - ) + datanames <- Filter(function(name) { + is.data.frame(isolate(data())[[name]]) + }, if (identical(datanames, "all")) names(isolate(data())) else datanames) + if_subject_plot <- length(parent_dataname) > 0 && parent_dataname %in% datanames ns <- session$ns diff --git a/R/tm_variable_browser.R b/R/tm_variable_browser.R index 74ab4e012..412d4b634 100644 --- a/R/tm_variable_browser.R +++ b/R/tm_variable_browser.R @@ -107,8 +107,8 @@ tm_variable_browser <- function(label = "Variable Browser", checkmate::assert_class(ggplot2_args, "ggplot2_args") # End of assertions - datanames <- if (identical(datanames, "all")) { - "all" + datanames_module <- if (identical(datanames, "all") || is.null(datanames)) { + datanames } else { union(datanames, parent_dataname) } @@ -117,9 +117,9 @@ tm_variable_browser <- function(label = "Variable Browser", label, server = srv_variable_browser, ui = ui_variable_browser, - datanames = datanames, + datanames = datanames_module, server_args = list( - datanames = datanames, + datanames = if (is.null(datanames)) "all" else datanames, parent_dataname = parent_dataname, ggplot2_args = ggplot2_args ), @@ -228,7 +228,7 @@ srv_variable_browser <- function(id, datanames <- Filter(function(name) { is.data.frame(isolate(data())[[name]]) - }, datanames) + }, if (identical(datanames, "all")) names(isolate(data())) else datanames) output$ui_variable_browser <- renderUI({ ns <- session$ns diff --git a/man/tm_front_page.Rd b/man/tm_front_page.Rd index b21ead3ac..e045fdbf1 100644 --- a/man/tm_front_page.Rd +++ b/man/tm_front_page.Rd @@ -11,7 +11,7 @@ tm_front_page( additional_tags = tagList(), footnotes = character(0), show_metadata = deprecated(), - datanames = if (missing(show_metadata)) "all" else NULL + datanames = if (missing(show_metadata)) NULL else "all" ) } \arguments{ diff --git a/tests/testthat/test-shinytest2-tm_front_page.R b/tests/testthat/test-shinytest2-tm_front_page.R index febb35638..fb1803e49 100644 --- a/tests/testthat/test-shinytest2-tm_front_page.R +++ b/tests/testthat/test-shinytest2-tm_front_page.R @@ -8,6 +8,7 @@ app_driver_tm_front_page <- function() { data = data, modules = tm_front_page( label = "Front page", + datanames = "all", header_text = c( "Important information" = "It can go here.", "Other information" = "Can go here." diff --git a/tests/testthat/test-shinytest2-tm_misssing_data.R b/tests/testthat/test-shinytest2-tm_misssing_data.R index 96d151bd3..d1eba587a 100644 --- a/tests/testthat/test-shinytest2-tm_misssing_data.R +++ b/tests/testthat/test-shinytest2-tm_misssing_data.R @@ -19,7 +19,7 @@ app_driver_tm_missing_data <- function() { label = "Missing data", plot_height = c(600, 400, 5000), plot_width = NULL, - datanames = "mtcars", + datanames = "all", ggtheme = "gray", ggplot2_args = list( "Combinations Hist" = teal.widgets::ggplot2_args(