Skip to content

Commit 1764c3e

Browse files
authored
Merge branch 'main' into 1441_transformators@main
2 parents fff168d + 8ce4546 commit 1764c3e

17 files changed

+143
-80
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Type: Package
22
Package: teal.modules.general
33
Title: General Modules for 'teal' Applications
4-
Version: 0.3.0.9064
5-
Date: 2025-01-17
4+
Version: 0.3.0.9065
5+
Date: 2025-01-20
66
Authors@R: c(
77
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre")),
88
person("Pawel", "Rucki", , "[email protected]", role = "aut"),
@@ -46,6 +46,7 @@ Imports:
4646
htmlwidgets (>= 1.6.4),
4747
jsonlite (>= 1.8.9),
4848
lattice (>= 0.18-4),
49+
lifecycle (>= 0.2.0),
4950
MASS (>= 7.3-61),
5051
rlistings (>= 0.2.8),
5152
rtables (>= 0.6.8),
@@ -69,7 +70,6 @@ Imports:
6970
utils
7071
Suggests:
7172
knitr (>= 1.42),
72-
lifecycle (>= 0.2.0),
7373
logger (>= 0.2.0),
7474
nestcolor (>= 0.1.0),
7575
pkgload,

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ import(shiny)
3131
import(teal)
3232
import(teal.transform)
3333
importFrom(dplyr,"%>%")
34+
importFrom(lifecycle,deprecated)

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# teal.modules.general 0.3.0.9064
1+
# teal.modules.general 0.3.0.9065
22

33
* Removed `Show Warnings` modals from modules.
4+
* Soft deprecated `datasets_selected` argument of modules in favor of `datanames`.
5+
* Soft deprecated `show_metadata` argument of `tm_front_page()` in favor of `datanames`.
46

57
### Enhancements
8+
69
* Added `teal.logger` functionality for logging changes in shiny inputs in all modules.
710

811
### Bug fixes

R/tm_data_table.R

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
#' Names of list elements should correspond to the names of the datasets available in the app.
1717
#' If no entry is specified for a dataset, the first six variables from that
1818
#' dataset will initially be shown.
19-
#' @param datasets_selected (`character`) A vector of datasets which should be
20-
#' shown and in what order. Names in the vector have to correspond with datasets names.
21-
#' If vector of `length == 0` (default) then all datasets are shown.
22-
#' Note: Only datasets of the `data.frame` class are compatible.
19+
#' @param datasets_selected (`character`) `r lifecycle::badge("deprecated")` A vector of datasets which should be
20+
#' shown and in what order. Use `datanames` instead.
2321
#' @param dt_args (`named list`) Additional arguments to be passed to [DT::datatable()]
2422
#' (must not include `data` or `options`).
2523
#' @param dt_options (`named list`) The `options` argument to `DT::datatable`. By default
@@ -86,7 +84,8 @@
8684
#'
8785
tm_data_table <- function(label = "Data Table",
8886
variables_selected = list(),
89-
datasets_selected = character(0),
87+
datasets_selected = deprecated(),
88+
datanames = if (missing(datasets_selected)) "all" else datasets_selected,
9089
dt_args = list(),
9190
dt_options = list(
9291
searching = FALSE,
@@ -111,8 +110,15 @@ tm_data_table <- function(label = "Data Table",
111110
}
112111
})
113112
}
114-
115-
checkmate::assert_character(datasets_selected, min.len = 0, min.chars = 1)
113+
if (!missing(datasets_selected)) {
114+
lifecycle::deprecate_soft(
115+
when = "0.4.0",
116+
what = "tm_data_table(datasets_selected)",
117+
with = "tm_data_table(datanames)",
118+
details = 'Use tm_data_table(datanames = "all") to keep the previous behavior and avoid this warning.',
119+
)
120+
}
121+
checkmate::assert_character(datanames, min.len = 0, min.chars = 1, null.ok = TRUE)
116122
checkmate::assert(
117123
checkmate::check_list(dt_args, len = 0),
118124
checkmate::check_subset(names(dt_args), choices = names(formals(DT::datatable)))
@@ -128,10 +134,10 @@ tm_data_table <- function(label = "Data Table",
128134
label,
129135
server = srv_page_data_table,
130136
ui = ui_page_data_table,
131-
datanames = if (length(datasets_selected) == 0) "all" else datasets_selected,
137+
datanames = datanames,
132138
server_args = list(
139+
datanames = datanames,
133140
variables_selected = variables_selected,
134-
datasets_selected = datasets_selected,
135141
dt_args = dt_args,
136142
dt_options = dt_options,
137143
server_rendering = server_rendering
@@ -180,7 +186,7 @@ ui_page_data_table <- function(id, pre_output = NULL, post_output = NULL) {
180186
# Server page module
181187
srv_page_data_table <- function(id,
182188
data,
183-
datasets_selected,
189+
datanames,
184190
variables_selected,
185191
dt_args,
186192
dt_options,
@@ -193,16 +199,10 @@ srv_page_data_table <- function(id,
193199
if_filtered <- reactive(as.logical(input$if_filtered))
194200
if_distinct <- reactive(as.logical(input$if_distinct))
195201

196-
datanames <- isolate(names(data()))
197202
datanames <- Filter(function(name) {
198203
is.data.frame(isolate(data())[[name]])
199204
}, datanames)
200205

201-
if (!identical(datasets_selected, character(0))) {
202-
checkmate::assert_subset(datasets_selected, datanames)
203-
datanames <- datasets_selected
204-
}
205-
206206
output$dataset_table <- renderUI({
207207
do.call(
208208
tabsetPanel,

R/tm_front_page.R

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
#' `HTML("html text here")`.
1414
#' @param footnotes (`character` vector) of text to be shown at the bottom of the module, for each
1515
#' element, if named the name is shown first in bold, followed by the value.
16-
#' @param show_metadata (`logical`) indicating whether the metadata of the datasets be available on the module.
16+
#' @param show_metadata (`logical`) `r lifecycle::badge("deprecated")` indicating
17+
#' whether the metadata of the datasets be available on the module.
18+
#' Metadata shown automatically when `datanames` set.
19+
#' @inheritParams tm_variable_browser
1720
#'
1821
#' @inherit shared_params return
1922
#'
@@ -50,12 +53,11 @@
5053
#' ),
5154
#' tables = table_input,
5255
#' additional_tags = HTML("Additional HTML or shiny tags go here <br>"),
53-
#' footnotes = c("X" = "is the first footnote", "Y is the second footnote"),
54-
#' show_metadata = TRUE
56+
#' footnotes = c("X" = "is the first footnote", "Y is the second footnote")
5557
#' )
5658
#' ),
5759
#' header = tags$h1("Sample Application"),
58-
#' footer = tags$p("Application footer"),
60+
#' footer = tags$p("Application footer")
5961
#' )
6062
#'
6163
#' if (interactive()) {
@@ -69,7 +71,8 @@ tm_front_page <- function(label = "Front page",
6971
tables = list(),
7072
additional_tags = tagList(),
7173
footnotes = character(0),
72-
show_metadata = FALSE) {
74+
show_metadata = deprecated(),
75+
datanames = if (missing(show_metadata)) "all" else NULL) {
7376
message("Initializing tm_front_page")
7477

7578
# Start of assertions
@@ -78,7 +81,19 @@ tm_front_page <- function(label = "Front page",
7881
checkmate::assert_list(tables, types = "data.frame", names = "named", any.missing = FALSE)
7982
checkmate::assert_multi_class(additional_tags, classes = c("shiny.tag.list", "html"))
8083
checkmate::assert_character(footnotes, min.len = 0, any.missing = FALSE)
81-
checkmate::assert_flag(show_metadata)
84+
if (!missing(show_metadata)) {
85+
lifecycle::deprecate_soft(
86+
when = "0.4.0",
87+
what = "tm_front_page(show_metadata)",
88+
with = "tm_front_page(datanames)",
89+
details = c(
90+
"With `datanames` you can select which datasets are displayed.",
91+
i = "Use `tm_front_page(datanames = 'all')` to keep the previous behavior and avoid this warning."
92+
)
93+
)
94+
}
95+
checkmate::assert_character(datanames, min.len = 0, min.chars = 1, null.ok = TRUE)
96+
8297
# End of assertions
8398

8499
# Make UI args
@@ -89,8 +104,8 @@ tm_front_page <- function(label = "Front page",
89104
server = srv_front_page,
90105
ui = ui_front_page,
91106
ui_args = args,
92-
server_args = list(tables = tables, show_metadata = show_metadata),
93-
datanames = if (show_metadata) "all" else NULL
107+
server_args = list(tables = tables),
108+
datanames = datanames
94109
)
95110
attr(ans, "teal_bookmarkable") <- TRUE
96111
ans
@@ -120,7 +135,7 @@ ui_front_page <- function(id, ...) {
120135
class = "my-4",
121136
args$additional_tags
122137
),
123-
if (args$show_metadata) {
138+
if (length(args$datanames) > 0L) {
124139
tags$div(
125140
id = "front_page_metabutton",
126141
class = "m-4",
@@ -136,7 +151,7 @@ ui_front_page <- function(id, ...) {
136151
}
137152

138153
# Server function for the front page module
139-
srv_front_page <- function(id, data, tables, show_metadata) {
154+
srv_front_page <- function(id, data, tables) {
140155
checkmate::assert_class(data, "reactive")
141156
checkmate::assert_class(isolate(data()), "teal_data")
142157
moduleServer(id, function(input, output, session) {
@@ -154,8 +169,7 @@ srv_front_page <- function(id, data, tables, show_metadata) {
154169
caption.placement = "top"
155170
)
156171
})
157-
158-
if (show_metadata) {
172+
if (length(isolate(names(data()))) > 0L) {
159173
observeEvent(
160174
input$metadata_button, showModal(
161175
modalDialog(

R/tm_missing_data.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
#' app <- init(
7474
#' data = data,
7575
#' modules = modules(
76-
#' tm_missing_data()
76+
#' tm_missing_data(parent_dataname = "mtcars")
7777
#' )
7878
#' )
7979
#' if (interactive()) {
@@ -109,6 +109,7 @@
109109
tm_missing_data <- function(label = "Missing data",
110110
plot_height = c(600, 400, 5000),
111111
plot_width = NULL,
112+
datanames = "all",
112113
parent_dataname = "ADSL",
113114
ggtheme = c("classic", "gray", "bw", "linedraw", "light", "dark", "minimal", "void"),
114115
ggplot2_args = list(
@@ -135,6 +136,7 @@ tm_missing_data <- function(label = "Missing data",
135136
lower = plot_width[2], upper = plot_width[3], null.ok = TRUE, .var.name = "plot_width"
136137
)
137138

139+
checkmate::assert_character(datanames, min.len = 0, min.chars = 1, null.ok = TRUE)
138140
checkmate::assert_character(parent_dataname, min.len = 0, max.len = 1)
139141
ggtheme <- match.arg(ggtheme)
140142

@@ -153,6 +155,7 @@ tm_missing_data <- function(label = "Missing data",
153155
ans <- module(
154156
label,
155157
server = srv_page_missing_data,
158+
datanames = if (identical(datanames, "all")) union(datanames, parent_dataname) else "all",
156159
server_args = list(
157160
parent_dataname = parent_dataname,
158161
plot_height = plot_height,
@@ -163,7 +166,6 @@ tm_missing_data <- function(label = "Missing data",
163166
),
164167
ui = ui_page_missing_data,
165168
transformators = transformators,
166-
datanames = "all",
167169
ui_args = list(pre_output = pre_output, post_output = post_output)
168170
)
169171
attr(ans, "teal_bookmarkable") <- TRUE

R/tm_variable_browser.R

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
#' @inheritParams teal::module
1111
#' @inheritParams shared_params
1212
#' @param parent_dataname (`character(1)`) string specifying a parent dataset.
13-
#' If it exists in `datasets_selected`then an extra checkbox will be shown to
13+
#' If it exists in `datanames` then an extra checkbox will be shown to
1414
#' allow users to not show variables in other datasets which exist in this `dataname`.
1515
#' This is typically used to remove `ADSL` columns in `CDISC` data.
1616
#' In non `CDISC` data this can be ignored. Defaults to `"ADSL"`.
17-
#' @param datasets_selected (`character`) vector of datasets which should be
18-
#' shown, in order. Names must correspond with datasets names.
19-
#' If vector of length zero (default) then all datasets are shown.
20-
#' Note: Only `data.frame` objects are compatible; using other types will cause an error.
17+
#' @param datasets_selected (`character`) `r lifecycle::badge("deprecated")` vector of datasets to show, please
18+
#' use the `datanames` argument.
2119
#'
2220
#' @inherit shared_params return
2321
#'
@@ -81,7 +79,8 @@
8179
#' @export
8280
#'
8381
tm_variable_browser <- function(label = "Variable Browser",
84-
datasets_selected = character(0),
82+
datasets_selected = deprecated(),
83+
datanames = if (missing(datasets_selected)) "all" else datasets_selected,
8584
parent_dataname = "ADSL",
8685
pre_output = NULL,
8786
post_output = NULL,
@@ -90,22 +89,37 @@ tm_variable_browser <- function(label = "Variable Browser",
9089

9190
# Start of assertions
9291
checkmate::assert_string(label)
93-
checkmate::assert_character(datasets_selected)
92+
if (!missing(datasets_selected)) {
93+
lifecycle::deprecate_soft(
94+
when = "0.4.0",
95+
what = "tm_variable_browser(datasets_selected)",
96+
with = "tm_variable_browser(datanames)",
97+
details = c(
98+
"If both `datasets_selected` and `datanames` are set `datasets_selected` will be silently ignored.",
99+
i = 'Use `tm_variable_browser(datanames = "all")` to keep the previous behavior and avoid this warning.'
100+
)
101+
)
102+
}
103+
checkmate::assert_character(datanames, min.len = 0, min.chars = 1, null.ok = TRUE)
94104
checkmate::assert_character(parent_dataname, min.len = 0, max.len = 1)
95105
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
96106
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
97107
checkmate::assert_class(ggplot2_args, "ggplot2_args")
98108
# End of assertions
99109

100-
datasets_selected <- unique(datasets_selected)
110+
datanames <- if (identical(datanames, "all")) {
111+
"all"
112+
} else {
113+
union(datanames, parent_dataname)
114+
}
101115

102116
ans <- module(
103117
label,
104118
server = srv_variable_browser,
105119
ui = ui_variable_browser,
106-
datanames = "all",
120+
datanames = datanames,
107121
server_args = list(
108-
datasets_selected = datasets_selected,
122+
datanames = datanames,
109123
parent_dataname = parent_dataname,
110124
ggplot2_args = ggplot2_args
111125
),
@@ -194,7 +208,7 @@ srv_variable_browser <- function(id,
194208
data,
195209
reporter,
196210
filter_panel_api,
197-
datasets_selected, parent_dataname, ggplot2_args) {
211+
datanames, parent_dataname, ggplot2_args) {
198212
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
199213
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
200214
checkmate::assert_class(data, "reactive")
@@ -212,18 +226,10 @@ srv_variable_browser <- function(id,
212226

213227
varname_numeric_as_factor <- reactiveValues()
214228

215-
datanames <- isolate(names(data()))
216229
datanames <- Filter(function(name) {
217230
is.data.frame(isolate(data())[[name]])
218231
}, datanames)
219232

220-
checkmate::assert_character(datasets_selected)
221-
checkmate::assert_subset(datasets_selected, datanames)
222-
if (!identical(datasets_selected, character(0))) {
223-
checkmate::assert_subset(datasets_selected, datanames)
224-
datanames <- datasets_selected
225-
}
226-
227233
output$ui_variable_browser <- renderUI({
228234
ns <- session$ns
229235
do.call(

R/zzz.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
### global variables
77
ggplot_themes <- c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void")
88

9+
#' @importFrom lifecycle deprecated
910
interactive <- NULL

man/tm_data_table.Rd

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)