Skip to content

Commit

Permalink
- fix callback execution for multiple transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot-preview[bot] committed Sep 13, 2024
1 parent 023a63b commit 32792e3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
8 changes: 4 additions & 4 deletions R/module_init_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ srv_init_data <- function(id, data, modules, filter = teal_slices()) {
data_module = data,
modules = modules,
validate_shiny_silent_error = FALSE,
failure_callback = function(data) {
if (inherits(data(), "teal_data")) {
shinyjs::enable(selector = sprintf(".teal-body:has('#%s') .nav li a", session$ns("content")))
} else {
failure_callback = function(is_any_failed) {
if (is_any_failed) {
shinyjs::disable(selector = sprintf(".teal-body:has('#%s') .nav li a", session$ns("content")))
} else {
shinyjs::enable(selector = sprintf(".teal-body:has('#%s') .nav li a", session$ns("content")))
}
}
)
Expand Down
12 changes: 6 additions & 6 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,15 @@ srv_teal_module.teal_module <- function(id,
data = filtered_teal_data,
transforms = modules$transformers,
modules = modules,
failure_callback = function(data) {
if (inherits(data(), "teal_data")) {
shinyjs::show(selector = sprintf("#%s", session$ns("teal_module_ui")))
shinyjs::show(selector = sprintf("#%s", session$ns("validate_datanames")))
shinyjs::hide(selector = sprintf("#%s", session$ns("transformer_failure_info")))
} else {
failure_callback = function(is_any_failed) {
if (is_any_failed) {
shinyjs::hide(selector = sprintf("#%s", session$ns("teal_module_ui")))
shinyjs::hide(selector = sprintf("#%s", session$ns("validate_datanames")))
shinyjs::show(selector = sprintf("#%s", session$ns("transformer_failure_info")))
} else {
shinyjs::show(selector = sprintf("#%s", session$ns("teal_module_ui")))
shinyjs::show(selector = sprintf("#%s", session$ns("validate_datanames")))
shinyjs::hide(selector = sprintf("#%s", session$ns("transformer_failure_info")))
}
}
)
Expand Down
10 changes: 8 additions & 2 deletions R/module_teal_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,23 @@ srv_teal_data <- function(id,
} else {
is_transformer_failed[[id]] <- TRUE
}
failure_callback(data_validated)
})


is_previous_failed <- reactive({
idx_this <- which(names(is_transformer_failed) == id)
is_transformer_failed_list <- reactiveValuesToList(is_transformer_failed)
idx_failures <- which(unlist(is_transformer_failed_list))
any(idx_failures < idx_this)
})

is_any_failed <- reactive({
any(unlist(reactiveValuesToList(is_transformer_failed)))
})

observeEvent(is_any_failed(), {
failure_callback(is_any_failed())
})

output$error <- renderUI({
if (is_previous_failed()) {
shinyjs::disable("wrapper")
Expand Down

0 comments on commit 32792e3

Please sign in to comment.