Skip to content

Commit 0f9565c

Browse files
committed
fix: show errors in transform even if there is no UI
1 parent be49c50 commit 0f9565c

File tree

1 file changed

+39
-27
lines changed

1 file changed

+39
-27
lines changed

R/module_transform_data.R

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,38 @@ ui_teal_transform_data <- function(id, transformators, class = "well") {
3333
data_mod <- transformators[[name]]
3434
transform_wrapper_id <- ns(sprintf("wrapper_%s", name))
3535

36-
div( # todo: accordion?
37-
# class .teal_validated changes the color of the boarder on error in ui_validate_reactive_teal_data
38-
# For details see tealValidate.js file.
39-
class = c(class, "teal_validated"),
40-
title = attr(data_mod, "label"),
41-
tags$span(
42-
class = "text-primary mb-4",
43-
icon("fas fa-square-pen"),
44-
attr(data_mod, "label")
45-
),
46-
tags$i(
47-
class = "remove pull-right fa fa-angle-down",
48-
style = "cursor: pointer;",
49-
title = "fold/expand transformator panel",
50-
onclick = sprintf("togglePanelItems(this, '%s', 'fa-angle-right', 'fa-angle-down');", transform_wrapper_id)
51-
),
52-
tags$div(
53-
id = transform_wrapper_id,
54-
if (is.null(data_mod$ui)) {
55-
return(NULL)
56-
} else {
57-
data_mod$ui(id = ns("transform"))
58-
},
59-
div(
60-
id = ns("validate_messages"),
61-
class = "teal_validated",
62-
uiOutput(ns("error_wrapper"))
36+
display_fun <- if (is.null(data_mod$ui)) shinyjs::hidden else function(x) x
37+
38+
display_fun(
39+
div( # todo: accordion?
40+
# class .teal_validated changes the color of the boarder on error in ui_validate_reactive_teal_data
41+
# For details see tealValidate.js file.
42+
id = ns("wrapper"),
43+
class = c(class, "teal_validated"),
44+
title = attr(data_mod, "label"),
45+
tags$span(
46+
class = "text-primary mb-4",
47+
icon("fas fa-square-pen"),
48+
attr(data_mod, "label")
49+
),
50+
tags$i(
51+
class = "remove pull-right fa fa-angle-down",
52+
style = "cursor: pointer;",
53+
title = "fold/expand transformator panel",
54+
onclick = sprintf("togglePanelItems(this, '%s', 'fa-angle-right', 'fa-angle-down');", transform_wrapper_id)
55+
),
56+
tags$div(
57+
id = transform_wrapper_id,
58+
if (is.null(data_mod$ui)) {
59+
NULL
60+
} else {
61+
data_mod$ui(id = ns("transform"))
62+
},
63+
div(
64+
id = ns("validate_messages"),
65+
class = "teal_validated",
66+
uiOutput(ns("error_wrapper"))
67+
)
6368
)
6469
)
6570
)
@@ -111,6 +116,13 @@ srv_teal_transform_data <- function(id, data, transformators, modules = NULL, is
111116
srv_check_module_datanames("datanames_warning", data_handled, modules)
112117
}
113118

119+
# When there is no UI (`ui = NULL`) it should still show the errors
120+
observe({
121+
if (!inherits(data_handled(), "teal_data") && !is_previous_failed()) {
122+
shinyjs::show("wrapper")
123+
}
124+
})
125+
114126
transform_wrapper_id <- sprintf("wrapper_%s", name)
115127
output$error_wrapper <- renderUI({
116128
if (is_previous_failed()) {

0 commit comments

Comments
 (0)