Skip to content

Commit e7cb0f1

Browse files
committed
feat: tm_data_table
1 parent 7a96181 commit e7cb0f1

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

R/tm_data_table.R

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,14 @@ tm_data_table <- function(label = "Data Table",
131131
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
132132
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
133133

134-
checkmate::assert_list(decorators, "teal_transform_module", null.ok = TRUE)
134+
if (checkmate::test_list(decorators, "teal_transform_module", null.ok = TRUE)) {
135+
decorators <- if (checkmate::test_names(names(decorators), subset.of = c("default", "table"))) {
136+
lapply(decorators, list)
137+
} else {
138+
list(default = decorators)
139+
}
140+
}
141+
assert_decorators(decorators, null.ok = TRUE, names = c("default", "table"))
135142
# End of assertions
136143

137144
ans <- module(
@@ -296,7 +303,7 @@ ui_data_table <- function(id,
296303
tagList(
297304
teal.widgets::get_dt_rows(ns("data_table"), ns("dt_rows")),
298305
fluidRow(
299-
ui_transform_teal_data(ns("decorate"), transformators = decorators),
306+
ui_decorate_teal_data(ns("decorator"), decorators = subset_decorators("table", decorators)),
300307
teal.widgets::optionalSelectInput(
301308
ns("variables"),
302309
"Select variables:",
@@ -365,13 +372,15 @@ srv_data_table <- function(id,
365372
)
366373
})
367374

368-
decorated_data_table_data <-
369-
srv_transform_teal_data("decorate", data = data_table_data, transformators = decorators)
375+
decorated_data_table_data <- srv_decorate_teal_data(
376+
id = "decorator",
377+
data = data_table_data,
378+
decorators = subset_decorators("table", decorators)
379+
)
370380

371381
output$data_table <- DT::renderDataTable(server = server_rendering, {
372-
req(data_table_data())
373382
teal::validate_inputs(iv)
374-
decorated_data_table_data()[["table"]]
383+
req(decorated_data_table_data())[["table"]]
375384
})
376385
})
377386
}

0 commit comments

Comments
 (0)