diff --git a/R/tm_t_pp_basic_info.R b/R/tm_t_pp_basic_info.R index 7f61d4148..7a6f2bcfa 100644 --- a/R/tm_t_pp_basic_info.R +++ b/R/tm_t_pp_basic_info.R @@ -36,13 +36,11 @@ template_basic_info <- function(dataname = "ANL", dplyr::select(var, key, value) %>% dplyr::rename(` ` = var, ` ` = key, ` ` = value) - result <- rlistings::as_listing( + table <- rlistings::as_listing( result, default_formatting = list(all = fmt_config(align = "left")) ) - main_title(result) <- paste("Patient ID:", patient_id) - - result + main_title(table) <- paste("Patient ID:", patient_id) }, env = list( dataname = as.name(dataname), vars = vars, @@ -66,6 +64,14 @@ template_basic_info <- function(dataname = "ANL", #' #' @inherit module_arguments return #' +#' @section Decorating Module: +#' +#' This module generates the following objects, which can be modified in place using decorators: +#' - `table` (`listing_df` - output of `rlistings::as_listing`) +#' +#' For additional details and examples of decorators, refer to the vignette +#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' #' @examplesShinylive #' library(teal.modules.clinical) #' interactive <- function() TRUE @@ -104,7 +110,8 @@ tm_t_pp_basic_info <- function(label, patient_col = "USUBJID", vars = NULL, pre_output = NULL, - post_output = NULL) { + post_output = NULL, + decorators = NULL) { message("Initializing tm_t_pp_basic_info") checkmate::assert_string(label) checkmate::assert_string(dataname) @@ -112,6 +119,8 @@ tm_t_pp_basic_info <- function(label, checkmate::assert_class(vars, "choices_selected", null.ok = TRUE) checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) + decorators <- normalize_decorators(decorators) + assert_decorators(decorators, null.ok = TRUE, "table") args <- as.list(environment()) data_extract_list <- list( @@ -128,7 +137,8 @@ tm_t_pp_basic_info <- function(label, list( dataname = dataname, label = label, - patient_col = patient_col + patient_col = patient_col, + decorators = decorators ) ), datanames = dataname @@ -163,7 +173,8 @@ ui_t_basic_info <- function(id, ...) { label = "Select variable:", data_extract_spec = ui_args$vars, is_single_dataset = is_single_dataset_value - ) + ), + ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(ui_args$decorators, "table")), ), forms = tagList( teal.widgets::verbatim_popup_ui(ns("rcode"), button_label = "Show R code") @@ -181,7 +192,8 @@ srv_t_basic_info <- function(id, dataname, patient_col, vars, - label) { + label, + decorators) { with_reporter <- !missing(reporter) && inherits(reporter, "Reporter") with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI") checkmate::assert_class(data, "reactive") @@ -265,11 +277,18 @@ srv_t_basic_info <- function(id, teal.code::eval_code(as.expression(unlist(my_calls))) }) + decorated_table_q <- srv_decorate_teal_data( + id = "decorator", + data = all_q, + decorators = select_decorators(decorators, "table"), + expr = table + ) + output$title <- renderText({ paste("