-
-
Notifications
You must be signed in to change notification settings - Fork 15
Fix decorators #855
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 #855
Conversation
Code Coverage SummaryDiff against mainResults for commit: 9a0b6aa Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Unit Tests Summary 1 files 22 suites 12m 50s ⏱️ Results for commit 9a0b6aa. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Results for commit 50118a1 ♻️ 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 as intended
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
)))
})
})
}
)
}
data <- teal_data()
data <- within(data, {
require(nestcolor)
add_nas <- function(x) {
x[sample(seq_along(x), floor(length(x) * runif(1, .05, .17)))] <- NA
x
}
iris <- iris
mtcars <- mtcars
iris[] <- lapply(iris, add_nas)
mtcars[] <- lapply(mtcars, add_nas)
mtcars[["cyl"]] <- as.factor(mtcars[["cyl"]])
mtcars[["gear"]] <- as.factor(mtcars[["gear"]])
})
app <- init(
data = data,
modules = modules(
tm_missing_data(
parent_dataname = "mtcars",
decorators = list(table = table_decorator(.var_to_replace = "table"))
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
Closes #850