From bd44f709298057bc31c2b1f69cb9fe16adbbef0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Revilla?= Date: Fri, 10 Jan 2025 13:36:42 +0100 Subject: [PATCH] Prevent breaking user code and simplify code --- R/tm_data_table.R | 5 +++-- R/tm_front_page.R | 9 +++++---- R/tm_variable_browser.R | 5 +++-- man/tm_front_page.Rd | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/R/tm_data_table.R b/R/tm_data_table.R index c36270ea7..c7a499868 100644 --- a/R/tm_data_table.R +++ b/R/tm_data_table.R @@ -115,7 +115,8 @@ tm_data_table <- function(label = "Data Table", if (!is.null(datasets_selected)) { lifecycle::deprecate_soft( when = "0.4.0", - what = "tm_data_table(datasets_selected = 'is deprecated, use `datanames`')" + what = "tm_data_table(datasets_selected", + with = "tm_data_table(datanames)" ) } checkmate::assert_character(datanames, min.len = 0, min.chars = 1, null.ok = TRUE) @@ -134,7 +135,7 @@ tm_data_table <- function(label = "Data Table", label, server = srv_page_data_table, ui = ui_page_data_table, - datanames = if (length(datanames) == 0) "all" else datanames, + datanames = datanames, server_args = list( variables_selected = variables_selected, datanames = datanames, diff --git a/R/tm_front_page.R b/R/tm_front_page.R index 1f4b85006..81b24037e 100644 --- a/R/tm_front_page.R +++ b/R/tm_front_page.R @@ -71,8 +71,8 @@ tm_front_page <- function(label = "Front page", tables = list(), additional_tags = tagList(), footnotes = character(0), - show_metadata = NULL, - datanames = NULL) { + show_metadata = TRUE, + datanames = if(isTRUE(show_metadata)) "all" else NULL) { message("Initializing tm_front_page") # Start of assertions @@ -84,7 +84,8 @@ tm_front_page <- function(label = "Front page", if (!is.null(show_metadata)) { lifecycle::deprecate_soft( when = "0.4.0", - what = "tm_front_page(show_metadata = 'is deprecated, use `datanames`')" + what = "tm_front_page(show_metadata)", + with = "tm_front_page(datanames)" ) } checkmate::assert_character(datanames, @@ -103,7 +104,7 @@ tm_front_page <- function(label = "Front page", ui = ui_front_page, ui_args = args, server_args = list(tables = tables), - datanames = datanames + datanames = unique(datanames) ) attr(ans, "teal_bookmarkable") <- TRUE ans diff --git a/R/tm_variable_browser.R b/R/tm_variable_browser.R index 072ab9087..eaf85a4ca 100644 --- a/R/tm_variable_browser.R +++ b/R/tm_variable_browser.R @@ -105,7 +105,8 @@ tm_variable_browser <- function(label = "Variable Browser", if (!is.null(datasets_selected)) { lifecycle::deprecate_soft( when = "0.4.0", - what = "tm_variable_browser(datasets_selected = 'is deprecated, use `datanames`')" + what = "tm_variable_browser(datasets_selected", + with = "tm_variable_browser(datanames)" ) } checkmate::assert_character(datanames, min.len = 0, min.chars = 1, null.ok = TRUE) @@ -121,7 +122,7 @@ tm_variable_browser <- function(label = "Variable Browser", label, server = srv_variable_browser, ui = ui_variable_browser, - datanames = if (length(datanames) == 0) "all" else datanames, + datanames = datanames, server_args = list( datanames = datanames, parent_dataname = parent_dataname, diff --git a/man/tm_front_page.Rd b/man/tm_front_page.Rd index dfd141666..8d1e2fdbf 100644 --- a/man/tm_front_page.Rd +++ b/man/tm_front_page.Rd @@ -10,8 +10,8 @@ tm_front_page( tables = list(), additional_tags = tagList(), footnotes = character(0), - show_metadata = NULL, - datanames = NULL + show_metadata = TRUE, + datanames = if (isTRUE(show_metadata)) "all" else NULL ) } \arguments{