From c134d2fd34bc8b1284f25f1afd0375e436e7038e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Tue, 21 Jan 2025 15:56:30 +0100 Subject: [PATCH 1/7] Fix corner cases "all" and NULL --- R/tm_data_table.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/tm_data_table.R b/R/tm_data_table.R index f18c5d05b..3ce3f7e48 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, @@ -199,9 +199,10 @@ srv_page_data_table <- function(id, if_filtered <- reactive(as.logical(input$if_filtered)) if_distinct <- reactive(as.logical(input$if_distinct)) - datanames <- Filter(function(name) { + 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( From ff47c939f91383cbeafaf8f7aa731c60cc477331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 22 Jan 2025 09:23:01 +0100 Subject: [PATCH 2/7] Invert the default to NULL instead of "all" --- R/tm_front_page.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 91e686e656dc0c141268f26428e7bbb02de7e656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 22 Jan 2025 12:02:18 +0100 Subject: [PATCH 3/7] Work with datanames boundaries: "all" and NULL --- R/tm_data_table.R | 2 +- R/tm_missing_data.R | 20 +++++++++++++------- R/tm_variable_browser.R | 10 +++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/R/tm_data_table.R b/R/tm_data_table.R index 3ce3f7e48..4e3c64c2f 100644 --- a/R/tm_data_table.R +++ b/R/tm_data_table.R @@ -199,7 +199,7 @@ srv_page_data_table <- function(id, if_filtered <- reactive(as.logical(input$if_filtered)) if_distinct <- reactive(as.logical(input$if_distinct)) - datanames <- Filter(function(name) { + datanames <- Filter(function(name) { is.data.frame(isolate(data())[[name]]) }, if (identical(datanames, "all")) names(isolate(data())) else datanames) diff --git a/R/tm_missing_data.R b/R/tm_missing_data.R index 6b20c4325..c05575296 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 From 96ee564a3b705973213d06bee44dd1fcbfacc6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Wed, 22 Jan 2025 12:02:30 +0100 Subject: [PATCH 4/7] Update documentation --- man/tm_front_page.Rd | 2 +- man/tm_g_distribution.Rd | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/man/tm_g_distribution.Rd b/man/tm_g_distribution.Rd index 8b1d9ca59..81c33fe0d 100644 --- a/man/tm_g_distribution.Rd +++ b/man/tm_g_distribution.Rd @@ -59,10 +59,10 @@ Defaults to \code{c(30L, 1L, 100L)}. \item{plot_width}{(\code{numeric}) optional, specifies the plot width as a three-element vector of \code{value}, \code{min}, and \code{max} for a slider encoding the plot width.} -\item{pre_output}{(\code{shiny.tag}, optional)\cr +\item{pre_output}{(\code{shiny.tag}) optional,\cr with text placed before the output to put the output into context. For example a title.} -\item{post_output}{(\code{shiny.tag}, optional) with text placed after the output to put the output +\item{post_output}{(\code{shiny.tag}) optional, with text placed after the output to put the output into context. For example the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} \item{transformators}{(\code{list} of \code{teal_transform_module}) that will be applied to transform module's data input. From 8bebda084adf742fbac6e0a4bbb6cca37cb8bac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 24 Jan 2025 14:30:14 +0100 Subject: [PATCH 5/7] Modify the app driver to match the previous behavior on test. --- tests/testthat/test-shinytest2-tm_front_page.R | 1 + tests/testthat/test-shinytest2-tm_misssing_data.R | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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( From ef074dadb2a1f2d9806d214794aee439e1074335 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:45:50 +0000 Subject: [PATCH 6/7] [skip style] [skip vbump] Restyle files --- R/tm_missing_data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tm_missing_data.R b/R/tm_missing_data.R index c05575296..06ca7466a 100644 --- a/R/tm_missing_data.R +++ b/R/tm_missing_data.R @@ -163,7 +163,7 @@ tm_missing_data <- function(label = "Missing data", server = srv_page_missing_data, datanames = datanames_module, server_args = list( - datanames = if (is.null(datanames)) "all" else datanames, + datanames = if (is.null(datanames)) "all" else datanames, parent_dataname = parent_dataname, plot_height = plot_height, plot_width = plot_width, From 9e6e609bb89019203799afdf98826c247c0cc9e5 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:53:31 +0000 Subject: [PATCH 7/7] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/tm_g_distribution.Rd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/tm_g_distribution.Rd b/man/tm_g_distribution.Rd index 81c33fe0d..8b1d9ca59 100644 --- a/man/tm_g_distribution.Rd +++ b/man/tm_g_distribution.Rd @@ -59,10 +59,10 @@ Defaults to \code{c(30L, 1L, 100L)}. \item{plot_width}{(\code{numeric}) optional, specifies the plot width as a three-element vector of \code{value}, \code{min}, and \code{max} for a slider encoding the plot width.} -\item{pre_output}{(\code{shiny.tag}) optional,\cr +\item{pre_output}{(\code{shiny.tag}, optional)\cr with text placed before the output to put the output into context. For example a title.} -\item{post_output}{(\code{shiny.tag}) optional, with text placed after the output to put the output +\item{post_output}{(\code{shiny.tag}, optional) with text placed after the output to put the output into context. For example the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} \item{transformators}{(\code{list} of \code{teal_transform_module}) that will be applied to transform module's data input.