Skip to content

Commit 7a96181

Browse files
committed
feat: tm_g_crosstable
1 parent ff7d3c2 commit 7a96181

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

R/tm_t_crosstable.R

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,15 @@ tm_t_crosstable <- function(label = "Cross Table",
167167
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
168168
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
169169
checkmate::assert_class(basic_table_args, classes = "basic_table_args")
170-
checkmate::assert_list(decorators, "teal_transform_module", null.ok = TRUE)
170+
171+
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
172+
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default", "table"))) {
173+
lapply(decorators, list)
174+
} else {
175+
list(default = decorators)
176+
}
177+
}
178+
assert_decorators(decorators, null.ok = TRUE, names = c("default", "table"))
171179
# End of assertions
172180

173181
# Make UI args
@@ -234,7 +242,7 @@ ui_t_crosstable <- function(id, x, y, show_percentage, show_total, pre_output, p
234242
checkboxInput(ns("show_total"), "Show total column", value = show_total)
235243
)
236244
),
237-
ui_transform_teal_data(ns("decorate"), transformators = args$decorators)
245+
ui_decorate_teal_data(ns("decorator"), decorators = subset_decorators("table", args$decorators))
238246
),
239247
forms = tagList(
240248
teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
@@ -407,15 +415,18 @@ srv_t_crosstable <- function(id, data, reporter, filter_panel_api, label, x, y,
407415
)
408416
})
409417

410-
decorated_output_q_no_print <- srv_transform_teal_data("decorate", data = output_q, transformators = decorators)
411-
decorated_output_q <- reactive(within(decorated_output_q_no_print(), expr = table))
418+
decorated_output_q <- srv_decorate_teal_data(
419+
id = "decorator",
420+
data = output_q,
421+
decorators = subset_decorators("table", decorators),
422+
expr = table
423+
)
412424

413-
output$title <- renderText(output_q()[["title"]])
425+
output$title <- renderText(req(decorated_output_q())[["title"]])
414426

415427
table_r <- reactive({
416428
req(iv_r()$is_valid())
417-
req(output_q())
418-
decorated_output_q()[["table"]]
429+
req(decorated_output_q())[["table"]]
419430
})
420431

421432
teal.widgets::table_with_settings_srv(

0 commit comments

Comments
 (0)