-
-
Notifications
You must be signed in to change notification settings - Fork 15
Fix decorators #854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix decorators #854
Conversation
Code Coverage SummaryDiff against mainResults for commit: cd0e4dd Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Unit Tests Summary 1 files 22 suites 12m 58s ⏱️ Results for commit cd0e4dd. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Additional test case details
Results for commit 635b403 ♻️ This comment has been updated with latest results. |
m7pr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with below. Works like a charm
table_decorator <- function(.color1 = "#f9f9f9", .color2 = "#f0f0f0", .var_to_replace = "table") {
teal_transform_module(
label = "Table color",
ui = function(id) {
selectInput(
NS(id, "style"),
"Table Style",
choices = c("Default", "Color1", "Color2"),
selected = "Default"
)
},
server = function(id, data) {
moduleServer(id, function(input, output, session) {
logger::log_info("🔵 Table row color called to action!", namespace = "teal.modules.general")
reactive({
req(data(), input$style)
logger::log_info("changing the Table row color '{input$style}'", namespace = "teal.modules.general")
teal.code::eval_code(data(), substitute({
.var_to_replace <- switch(
style,
"Color1" = DT::formatStyle(
.var_to_replace,
columns = attr(.var_to_replace$x, "colnames")[-1],
target = "row",
backgroundColor = .color1
),
"Color2" = DT::formatStyle(
.var_to_replace,
columns = attr(.var_to_replace$x, "colnames")[-1],
target = "row",
backgroundColor = .color2
),
.var_to_replace
)
}, env = list(
style = input$style,
.var_to_replace = as.name(.var_to_replace),
.color1 = .color1,
.color2 = .color2
)))
})
})
}
)
}
# general data example
data <- teal_data()
data <- within(data, {
iris <- iris
})
app <- init(
data = data,
modules = list(
tm_g_distribution(
dist_var = data_extract_spec(
dataname = "iris",
select = select_spec(variable_choices("iris"), "Petal.Length")
),
decorators = list(summary_table = table_decorator(.var_to_replace = "summary_table"))
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
Closes #849