-
-
Notifications
You must be signed in to change notification settings - Fork 15
Fix decorators #856
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 #856
Conversation
Code Coverage SummaryDiff against mainResults for commit: 2ff03e1 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Unit Tests Summary 1 files 22 suites 13m 3s ⏱️ Results for commit 2ff03e1. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Additional test case details
Results for commit 1e51531 ♻️ 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.
Decorator code is visible in the Show R Code
and the decorator is applied
tested with
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, {
CO2 <- CO2
CO2[["primary_key"]] <- seq_len(nrow(CO2))
})
join_keys(data) <- join_keys(join_key("CO2", "CO2", "primary_key"))
vars <- choices_selected(variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")))
app <- init(
data = data,
modules = modules(
tm_outliers(
outlier_var = list(
data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
selected = "uptake",
multiple = FALSE,
fixed = FALSE
)
)
),
categorical_var = list(
data_extract_spec(
dataname = "CO2",
filter = filter_spec(
vars = vars,
choices = value_choices(data[["CO2"]], vars$selected),
selected = value_choices(data[["CO2"]], vars$selected),
multiple = TRUE
)
)
),
decorators = list(table = table_decorator(.var_to_replace = "table"))
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
Closes #851