Skip to content

Commit 2708f8f

Browse files
authored
Merge branch 'main' into 821_select_datanames@main
Signed-off-by: Lluís Revilla <[email protected]>
2 parents 0bbce3a + 268a604 commit 2708f8f

34 files changed

+338
-222
lines changed

DESCRIPTION

Lines changed: 4 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.9061
5-
Date: 2024-12-17
4+
Version: 0.3.0.9062
5+
Date: 2025-01-09
66
Authors@R: c(
77
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre")),
88
person("Pawel", "Rucki", , "[email protected]", role = "aut"),
@@ -35,7 +35,7 @@ Imports:
3535
DT (>= 0.13),
3636
forcats (>= 1.0.0),
3737
grid,
38-
lifecycle (>= 0.2.0),
38+
rlistings (>= 0.2.8),
3939
scales,
4040
shinyjs,
4141
shinyTree (>= 0.2.8),
@@ -66,6 +66,7 @@ Suggests:
6666
jsonlite,
6767
knitr (>= 1.42),
6868
lattice (>= 0.18-4),
69+
lifecycle (>= 0.2.0),
6970
logger (>= 0.2.0),
7071
MASS,
7172
nestcolor (>= 0.1.0),

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# teal.modules.general 0.3.0.9061
1+
# teal.modules.general 0.3.0.9062
22

33
* Removed `Show Warnings` modals from modules.
44
* Hard deprecated `datasets_selected` argument of modules in favor of `datanames`.

R/roxygen2_templates.R

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
11
# nocov start
2-
roxygen_decorators_param <- function(module_name) {
3-
paste(
4-
sep = " ",
5-
lifecycle::badge("experimental"),
6-
" (`list` of `teal_transform_module`, named `list` of `teal_transform_module` or",
7-
"`NULL`) optional, if not `NULL`, decorator for tables or plots included in the module.",
8-
"When a named list of `teal_transform_module`, the decorators are applied to the",
9-
"respective output objects.\n\n",
10-
"Otherwise, the decorators are applied to all objects, which is equivalent as using the name `default`.\n\n",
11-
sprintf("See section \"Decorating `%s`\"", module_name),
12-
"below for more details."
13-
)
14-
}
15-
162
roxygen_ggplot2_args_param <- function(...) {
173
paste(
184
sep = " ",
@@ -21,7 +7,7 @@ roxygen_ggplot2_args_param <- function(...) {
217
"The argument is merged with options variable `teal.ggplot2_args` and default module setup.\n\n",
228
sprintf(
239
"List names should match the following: `c(\"default\", %s)`.\n\n",
24-
paste("\"", unlist(rlang::list2(...)), "\"", collapse = ", ", sep = "")
10+
paste("\"", unlist(list(...)), "\"", collapse = ", ", sep = "")
2511
),
2612
"For more details see the vignette: `vignette(\"custom-ggplot2-arguments\", package = \"teal.widgets\")`."
2713
)

R/tm_a_pca.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
#' - If vector of `length == 1` then the font sizes will have a fixed size.
1515
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
1616
#' @param ggplot2_args `r roxygen_ggplot2_args_param("Elbow plot", "Circle plot", "Biplot", "Eigenvector plot")`
17-
#' @param decorators `r roxygen_decorators_param("tm_a_pca")`
1817
#'
1918
#' @inherit shared_params return
2019
#'
21-
#' @section Decorating `tm_a_pca`:
20+
#' @section Decorating Module:
2221
#'
2322
#' This module generates the following objects, which can be modified in place using decorators:
2423
#' - `elbow_plot` (`ggplot2`)
@@ -1121,9 +1120,12 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
11211120
)
11221121
})
11231122

1123+
# Render R code.
1124+
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q())))
1125+
11241126
teal.widgets::verbatim_popup_srv(
11251127
id = "rcode",
1126-
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
1128+
verbatim_content = source_code_r,
11271129
title = "R Code for PCA"
11281130
)
11291131

@@ -1146,7 +1148,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
11461148
card$append_text("Comment", "header3")
11471149
card$append_text(comment)
11481150
}
1149-
card$append_src(teal.code::get_code(req(decorated_output_q())))
1151+
card$append_src(source_code_r())
11501152
card
11511153
}
11521154
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)

R/tm_a_regression.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@
4040
# nolint start: line_length.
4141
#' @param ggplot2_args `r roxygen_ggplot2_args_param("Response vs Regressor", "Residuals vs Fitted", "Scale-Location", "Cook's distance", "Residuals vs Leverage", "Cook's dist vs Leverage")`
4242
# nolint end: line_length.
43-
#' @param decorators `r roxygen_decorators_param("tm_a_regression")`
4443
#'
4544
#' @inherit shared_params return
4645
#'
47-
#' @section Decorating `tm_a_regression`:
46+
#' @section Decorating Module:
4847
#'
4948
#' This module generates the following objects, which can be modified in place using decorators:
5049
#' - `plot` (`ggplot2`)
@@ -1006,9 +1005,12 @@ srv_a_regression <- function(id,
10061005
)
10071006
})
10081007

1008+
# Render R code.
1009+
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q())))
1010+
10091011
teal.widgets::verbatim_popup_srv(
10101012
id = "rcode",
1011-
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
1013+
verbatim_content = source_code_r,
10121014
title = "R code for the regression plot",
10131015
)
10141016

@@ -1027,7 +1029,7 @@ srv_a_regression <- function(id,
10271029
card$append_text("Comment", "header3")
10281030
card$append_text(comment)
10291031
}
1030-
card$append_src(teal.code::get_code(req(decorated_output_q())))
1032+
card$append_src(source_code_r())
10311033
card
10321034
}
10331035
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)

R/tm_data_table.R

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,9 @@
2626
#' `list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)`
2727
#' @param server_rendering (`logical`) should the data table be rendered server side
2828
#' (see `server` argument of [DT::renderDataTable()])
29-
#' @param decorators `r roxygen_decorators_param("tm_data_table")`
3029
#'
3130
#' @inherit shared_params return
3231
#'
33-
#' @section Decorating `tm_data_table`:
34-
#'
35-
#' This module generates the following objects, which can be modified in place using decorators:
36-
#' - `table` ([DT::datatable()])
37-
#'
38-
#' For additional details and examples of decorators, refer to the vignette
39-
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
40-
#'
4132
#' @examplesShinylive
4233
#' library(teal.modules.general)
4334
#' interactive <- function() TRUE
@@ -106,8 +97,7 @@ tm_data_table <- function(label = "Data Table",
10697
),
10798
server_rendering = FALSE,
10899
pre_output = NULL,
109-
post_output = NULL,
110-
decorators = NULL) {
100+
post_output = NULL) {
111101
message("Initializing tm_data_table")
112102

113103
# Start of assertions
@@ -138,8 +128,6 @@ tm_data_table <- function(label = "Data Table",
138128
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
139129
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
140130

141-
decorators <- normalize_decorators(decorators)
142-
assert_decorators(decorators, null.ok = TRUE, "table")
143131
# End of assertions
144132

145133
ans <- module(
@@ -152,8 +140,7 @@ tm_data_table <- function(label = "Data Table",
152140
datanames = datanames,
153141
dt_args = dt_args,
154142
dt_options = dt_options,
155-
server_rendering = server_rendering,
156-
decorators = decorators
143+
server_rendering = server_rendering
157144
),
158145
ui_args = list(
159146
pre_output = pre_output,
@@ -203,8 +190,7 @@ srv_page_data_table <- function(id,
203190
variables_selected,
204191
dt_args,
205192
dt_options,
206-
server_rendering,
207-
decorators) {
193+
server_rendering) {
208194
checkmate::assert_class(data, "reactive")
209195
checkmate::assert_class(isolate(data()), "teal_data")
210196
moduleServer(id, function(input, output, session) {
@@ -256,8 +242,7 @@ srv_page_data_table <- function(id,
256242
ui_data_table(
257243
id = session$ns(x),
258244
choices = choices,
259-
selected = variables_selected,
260-
decorators = decorators
245+
selected = variables_selected
261246
)
262247
)
263248
)
@@ -279,19 +264,15 @@ srv_page_data_table <- function(id,
279264
if_distinct = if_distinct,
280265
dt_args = dt_args,
281266
dt_options = dt_options,
282-
server_rendering = server_rendering,
283-
decorators = decorators
267+
server_rendering = server_rendering
284268
)
285269
}
286270
)
287271
})
288272
}
289273

290274
# UI function for the data_table module
291-
ui_data_table <- function(id,
292-
choices,
293-
selected,
294-
decorators) {
275+
ui_data_table <- function(id, choices, selected) {
295276
ns <- NS(id)
296277

297278
if (!is.null(selected)) {
@@ -303,7 +284,6 @@ ui_data_table <- function(id,
303284
tagList(
304285
teal.widgets::get_dt_rows(ns("data_table"), ns("dt_rows")),
305286
fluidRow(
306-
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(decorators, "table")),
307287
teal.widgets::optionalSelectInput(
308288
ns("variables"),
309289
"Select variables:",
@@ -327,8 +307,7 @@ srv_data_table <- function(id,
327307
if_distinct,
328308
dt_args,
329309
dt_options,
330-
server_rendering,
331-
decorators) {
310+
server_rendering) {
332311
moduleServer(id, function(input, output, session) {
333312
iv <- shinyvalidate::InputValidator$new()
334313
iv$add_rule("variables", shinyvalidate::sv_required("Please select valid variable names"))
@@ -372,15 +351,9 @@ srv_data_table <- function(id,
372351
)
373352
})
374353

375-
decorated_data_table_data <- srv_decorate_teal_data(
376-
id = "decorator",
377-
data = data_table_data,
378-
decorators = select_decorators(decorators, "table")
379-
)
380-
381354
output$data_table <- DT::renderDataTable(server = server_rendering, {
382355
teal::validate_inputs(iv)
383-
req(decorated_data_table_data())[["table"]]
356+
req(data_table_data())[["table"]]
384357
})
385358
})
386359
}

R/tm_g_association.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
#' Default to `"gray"`.
2222
#'
2323
#' @param ggplot2_args `r roxygen_ggplot2_args_param("Bivariate1", "Bivariate2")`
24-
#' @param decorators `r roxygen_decorators_param("tm_g_association")`
2524
#'
2625
#' @inherit shared_params return
2726
#'
28-
#' @section Decorating `tm_g_association`:
27+
#' @section Decorating Module:
2928
#'
3029
#' This module generates the following objects, which can be modified in place using decorators:
3130
#' - `plot` (`grob` created with [ggplot2::ggplotGrob()])
@@ -526,9 +525,12 @@ srv_tm_g_association <- function(id,
526525
teal.code::dev_suppress(output_q()[["title"]])
527526
})
528527

528+
# Render R code.
529+
source_code_r <- reactive(teal.code::get_code(req(decorated_output_grob_q())))
530+
529531
teal.widgets::verbatim_popup_srv(
530532
id = "rcode",
531-
verbatim_content = reactive(teal.code::get_code(req(decorated_output_grob_q()))),
533+
verbatim_content = source_code_r,
532534
title = "Association Plot"
533535
)
534536

@@ -547,7 +549,7 @@ srv_tm_g_association <- function(id,
547549
card$append_text("Comment", "header3")
548550
card$append_text(comment)
549551
}
550-
card$append_src(teal.code::get_code(req(decorated_output_grob_q())))
552+
card$append_src(source_code_r())
551553
card
552554
}
553555
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)

R/tm_g_bivariate.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@
4343
#' @param free_y_scales (`logical`) optional, whether Y scaling shall be changeable.
4444
#' Does not allow scaling to be changed by default (`FALSE`).
4545
#' @param swap_axes (`logical`) optional, whether to swap X and Y axes. Defaults to `FALSE`.
46-
#' @param decorators `r roxygen_decorators_param("tm_g_bivariate")`
4746
#'
4847
#' @inherit shared_params return
4948
#'
50-
#' @section Decorating `tm_g_bivariate`:
49+
#' @section Decorating Module:
5150
#'
5251
#' This module generates the following objects, which can be modified in place using decorators:
5352
#' - `plot` (`ggplot2`)
@@ -715,9 +714,12 @@ srv_g_bivariate <- function(id,
715714
width = plot_width
716715
)
717716

717+
# Render R code.
718+
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q_facets())))
719+
718720
teal.widgets::verbatim_popup_srv(
719721
id = "rcode",
720-
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q_facets()))),
722+
verbatim_content = source_code_r,
721723
title = "Bivariate Plot"
722724
)
723725

@@ -736,7 +738,7 @@ srv_g_bivariate <- function(id,
736738
card$append_text("Comment", "header3")
737739
card$append_text(comment)
738740
}
739-
card$append_src(teal.code::get_code(req(decorated_output_q_facets)))
741+
card$append_src(source_code_r())
740742
card
741743
}
742744
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)

0 commit comments

Comments
 (0)