Skip to content

Commit

Permalink
Merge branch 'main' into teal_reporter@main
Browse files Browse the repository at this point in the history
  • Loading branch information
llrs-roche authored Jan 27, 2025
2 parents 5e081b4 + 89f9900 commit 4fcaa41
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: teal.modules.general
Title: General Modules for 'teal' Applications
Version: 0.3.0.9071
Version: 0.3.0.9072
Date: 2025-01-27
Authors@R: c(
person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre")),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# teal.modules.general 0.3.0.9071
# teal.modules.general 0.3.0.9072

* Removed `Show Warnings` modals from modules.
* Soft deprecated `datasets_selected` argument of modules in favor of `datanames`.
Expand Down
5 changes: 3 additions & 2 deletions R/tm_data_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -201,7 +201,8 @@ srv_page_data_table <- function(id,

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(
Expand Down
2 changes: 1 addition & 1 deletion R/tm_front_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 13 additions & 7 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions R/tm_variable_browser.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
),
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/tm_front_page.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/testthat/test-shinytest2-tm_front_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-shinytest2-tm_misssing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4fcaa41

Please sign in to comment.