Skip to content

Commit 91e686e

Browse files
committed
Work with datanames boundaries: "all" and NULL
1 parent ff47c93 commit 91e686e

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

R/tm_data_table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ srv_page_data_table <- function(id,
199199
if_filtered <- reactive(as.logical(input$if_filtered))
200200
if_distinct <- reactive(as.logical(input$if_distinct))
201201

202-
datanames <- Filter(function(name) {
202+
datanames <- Filter(function(name) {
203203
is.data.frame(isolate(data())[[name]])
204204
}, if (identical(datanames, "all")) names(isolate(data())) else datanames)
205205

R/tm_missing_data.R

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,18 @@ tm_missing_data <- function(label = "Missing data",
152152
assert_decorators(decorators, names = available_decorators)
153153
# End of assertions
154154

155+
datanames_module <- if (identical(datanames, "all") || is.null(datanames)) {
156+
datanames
157+
} else {
158+
union(datanames, parent_dataname)
159+
}
160+
155161
ans <- module(
156162
label,
157163
server = srv_page_missing_data,
158-
datanames = if (identical(datanames, "all")) union(datanames, parent_dataname) else "all",
164+
datanames = datanames_module,
159165
server_args = list(
166+
datanames = if (is.null(datanames)) "all" else datanames,
160167
parent_dataname = parent_dataname,
161168
plot_height = plot_height,
162169
plot_width = plot_width,
@@ -198,18 +205,17 @@ ui_page_missing_data <- function(id, pre_output = NULL, post_output = NULL) {
198205
}
199206

200207
# Server function for the missing data module (all datasets)
201-
srv_page_missing_data <- function(id, data, reporter, filter_panel_api, parent_dataname,
208+
srv_page_missing_data <- function(id, data, reporter, filter_panel_api, datanames, parent_dataname,
202209
plot_height, plot_width, ggplot2_args, ggtheme, decorators) {
203210
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
204211
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
205212
moduleServer(id, function(input, output, session) {
206213
teal.logger::log_shiny_input_changes(input, namespace = "teal.modules.general")
207214

208-
datanames <- isolate(names(data()))
209-
datanames <- Filter(
210-
function(name) is.data.frame(isolate(data())[[name]]),
211-
datanames
212-
)
215+
datanames <- Filter(function(name) {
216+
is.data.frame(isolate(data())[[name]])
217+
}, if (identical(datanames, "all")) names(isolate(data())) else datanames)
218+
213219
if_subject_plot <- length(parent_dataname) > 0 && parent_dataname %in% datanames
214220

215221
ns <- session$ns

R/tm_variable_browser.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ tm_variable_browser <- function(label = "Variable Browser",
107107
checkmate::assert_class(ggplot2_args, "ggplot2_args")
108108
# End of assertions
109109

110-
datanames <- if (identical(datanames, "all")) {
111-
"all"
110+
datanames_module <- if (identical(datanames, "all") || is.null(datanames)) {
111+
datanames
112112
} else {
113113
union(datanames, parent_dataname)
114114
}
@@ -117,9 +117,9 @@ tm_variable_browser <- function(label = "Variable Browser",
117117
label,
118118
server = srv_variable_browser,
119119
ui = ui_variable_browser,
120-
datanames = datanames,
120+
datanames = datanames_module,
121121
server_args = list(
122-
datanames = datanames,
122+
datanames = if (is.null(datanames)) "all" else datanames,
123123
parent_dataname = parent_dataname,
124124
ggplot2_args = ggplot2_args
125125
),
@@ -228,7 +228,7 @@ srv_variable_browser <- function(id,
228228

229229
datanames <- Filter(function(name) {
230230
is.data.frame(isolate(data())[[name]])
231-
}, datanames)
231+
}, if (identical(datanames, "all")) names(isolate(data())) else datanames)
232232

233233
output$ui_variable_browser <- renderUI({
234234
ns <- session$ns

0 commit comments

Comments
 (0)