Skip to content
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

Adds decorate functionality to module output #1357

Merged
merged 198 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 185 commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
b74d1f6
WIP
dependabot-preview[bot] Sep 26, 2024
6835c18
init
dependabot-preview[bot] Sep 27, 2024
9fc5923
WIP
dependabot-preview[bot] Sep 27, 2024
9bc0405
Merge branch 'main' into 1187_decorate_output@main
dependabot-preview[bot] Sep 27, 2024
9f4e6dd
[skip style] [skip vbump] Restyle files
github-actions[bot] Sep 30, 2024
fa117d1
multiple outputs
dependabot-preview[bot] Sep 30, 2024
ed29e78
Merge remote-tracking branch 'origin/main' into 1187_decorate_output@…
dependabot-preview[bot] Oct 3, 2024
c214c25
reshuffle validation of teal_transform_module
dependabot-preview[bot] Oct 4, 2024
5f7ab79
don't display UI if not specified
dependabot-preview[bot] Oct 7, 2024
898015f
Dispatch in teal_transform_module constructor
dependabot-preview[bot] Oct 8, 2024
b5cb59f
- make_teal_transform_server to simplify teal_transform_module's serv…
dependabot-preview[bot] Oct 9, 2024
30bb248
move teal_transform_module to a new file instead of keeping with teal…
dependabot-preview[bot] Oct 9, 2024
dfce86b
Merge branch 'main' into 1187_decorate_output@main
gogonzo Oct 30, 2024
1c75925
post merge fixes
gogonzo Oct 30, 2024
a92ebc9
Merge branch 'main' into 1187_decorate_output@main
gogonzo Nov 6, 2024
5894970
Merge branch 'main' into 1187_decorate_output@main
gogonzo Nov 7, 2024
b1b85d4
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 11, 2024
d2626b1
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 11, 2024
3cd4761
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Nov 11, 2024
a0977eb
Update R/teal_transform_module.R
m7pr Nov 11, 2024
51e10cd
Update R/teal_transform_module.R
m7pr Nov 11, 2024
9dfce2d
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Nov 11, 2024
e46964e
redact decorate-modules-output vignette
m7pr Nov 11, 2024
b54fd6d
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 11, 2024
8f03d2e
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 11, 2024
c2e530d
small edits to the second vignette
m7pr Nov 11, 2024
4be8b97
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 11, 2024
02de519
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 11, 2024
b09ff42
add init part to examples of teal_transform_data so it's clear where …
m7pr Nov 11, 2024
ac475e8
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 11, 2024
106bf4c
decorator -> decorators
m7pr Nov 11, 2024
5206bfe
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 11, 2024
a1888c0
Update R/teal_transform_module.R
m7pr Nov 11, 2024
4cabc0c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Nov 11, 2024
e5e2e58
teal.data::datanames to names
m7pr Nov 11, 2024
d9bc6e7
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 11, 2024
f33669d
woops
m7pr Nov 11, 2024
8182e6d
ugh
m7pr Nov 11, 2024
38335b7
bring back extract_transformers
m7pr Nov 11, 2024
cabf9f2
Revert "bring back extract_transformers"
m7pr Nov 11, 2024
350d990
unify naming convention transformers->transforms
m7pr Nov 11, 2024
c36ab66
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 11, 2024
6eccdb8
fix 3 tests
m7pr Nov 11, 2024
6843cc8
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 11, 2024
bf210b4
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 11, 2024
1004af4
fix 2 more tests
m7pr Nov 11, 2024
df0b16e
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 11, 2024
5b7e901
change names of ui/srv_transform_data in vignette
m7pr Nov 12, 2024
9d82fea
fix vignette code
m7pr Nov 12, 2024
9d4eeac
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 12, 2024
e132211
remove pipe operator from vignette
m7pr Nov 12, 2024
64fbbbd
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 12, 2024
c84cbb6
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 12, 2024
64e7f5d
remove pipes, simplify example in the vignette, add skeleton tests
m7pr Nov 12, 2024
97b55af
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 12, 2024
4117417
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 12, 2024
7f1375f
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 13, 2024
f6a4513
documentation enhancemenes
m7pr Nov 13, 2024
81e1277
decorator example with DT table
m7pr Nov 13, 2024
6729e4d
update names in vignette
m7pr Nov 13, 2024
ecbf96f
extend example_module so it handles decorations
m7pr Nov 13, 2024
99c7a7c
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 13, 2024
e0bcb23
update NEWS
m7pr Nov 13, 2024
41fd9d7
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 13, 2024
cc1f7be
remove indent from format.teal_module
m7pr Nov 14, 2024
a1aaee2
fix Spell Check
m7pr Nov 14, 2024
fc596d4
missing chunk end typo
m7pr Nov 14, 2024
986a7c8
rename *_transofrm_data -> *_teal_transform_data
m7pr Nov 14, 2024
efdf8d2
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 14, 2024
e6c2ff0
fix pkgdown
m7pr Nov 14, 2024
f0e0605
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 14, 2024
875ccdb
update names in tests
m7pr Nov 14, 2024
56872ec
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Nov 14, 2024
e86e19f
Apply suggestions from code review
m7pr Nov 14, 2024
c2bc50d
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 14, 2024
e14f9b1
Update NEWS.md
m7pr Nov 14, 2024
f9bdb60
@gogonzo suggestions
m7pr Nov 14, 2024
f0b87f8
change transform to transformator
m7pr Nov 14, 2024
b54ebfc
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 14, 2024
a90544f
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Nov 14, 2024
d7f8366
update WORDLIST
m7pr Nov 14, 2024
d3c8830
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 14, 2024
0481d15
update docuemntaion
m7pr Nov 14, 2024
103ad27
change the object in example_module and document it
m7pr Nov 14, 2024
0e1d83f
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Nov 14, 2024
e91d198
update examples
m7pr Nov 14, 2024
7576e11
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Nov 14, 2024
8ced169
create two shinytest2 tests for decorators
m7pr Nov 14, 2024
9daa456
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 14, 2024
532fe73
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 14, 2024
40c73fd
combine decorator vignettes into one
m7pr Nov 14, 2024
a73dc58
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 14, 2024
80af8a2
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 14, 2024
5c839b5
lintr fixes
m7pr Nov 14, 2024
8bc8c10
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 14, 2024
3d5bc4e
rebuild docs
m7pr Nov 14, 2024
87acaec
fix one more test
m7pr Nov 14, 2024
2d7089c
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 14, 2024
28f17da
Update tests/testthat/test-shinytest2-decorators.R
m7pr Nov 14, 2024
8d3a465
Update R/modules.R
m7pr Nov 14, 2024
30002e1
bring back test for eventReactive value returned by teal_transform_mo…
m7pr Nov 14, 2024
0f6a2a8
merge
m7pr Nov 14, 2024
af099e8
prefix in vignette
m7pr Nov 14, 2024
37dc226
rerun docs
m7pr Nov 14, 2024
5663ca2
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Nov 14, 2024
717603d
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 14, 2024
31aa2d2
cleanup tests - remove ggplot2 examples
m7pr Nov 14, 2024
ceb97ff
Update R/dummy_functions.R
m7pr Nov 14, 2024
9ceff8b
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 14, 2024
0860bdf
fix: test with datanames validation
averissimo Nov 15, 2024
a8f1166
Merge branch 'main' into 1187_decorate_output@main
averissimo Nov 15, 2024
1f97c13
Update vignettes/decorate-module-output.Rmd
m7pr Nov 18, 2024
2bb9291
Update vignettes/decorate-module-output.Rmd
m7pr Nov 18, 2024
17afb2b
Update vignettes/decorate-module-output.Rmd
m7pr Nov 18, 2024
72e33f4
remove DT from vignette/dependencies
m7pr Nov 18, 2024
7bf54e7
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 18, 2024
6e9ae0c
change expression to language - as that's how it is documented in the…
m7pr Nov 18, 2024
0f51ce5
wrapper -> convenience function
m7pr Nov 18, 2024
5d09fcf
adjust intro
m7pr Nov 18, 2024
afbe5be
shiny::testServer tests for srv_teal_transform
m7pr Nov 18, 2024
4ba6320
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 18, 2024
2dae2b6
add pkgdown links to 1st appearance of the function in the decorators…
m7pr Nov 18, 2024
e39a883
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 18, 2024
60eec6e
be direct about which modules we talk
m7pr Nov 18, 2024
5007a82
Update R/dummy_functions.R
m7pr Nov 18, 2024
d395ac6
Update R/dummy_functions.R
m7pr Nov 18, 2024
d7c1f7e
Update R/modules.R
m7pr Nov 18, 2024
29ea4f1
change order of setnences in transofrmator vignette
m7pr Nov 18, 2024
cdf8797
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 18, 2024
9de76b9
Update vignettes/decorate-module-output.Rmd
m7pr Nov 18, 2024
f90bb77
Update vignettes/decorate-module-output.Rmd
m7pr Nov 18, 2024
75b41b9
Update vignettes/decorate-module-output.Rmd
m7pr Nov 18, 2024
1bdd159
link to teal_transform_module in transform vignettes
m7pr Nov 18, 2024
7a4778a
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 18, 2024
fd78283
Update vignettes/data-transform-as-shiny-module.Rmd
m7pr Nov 18, 2024
9e00183
Update vignettes/data-transform-as-shiny-module.Rmd
m7pr Nov 18, 2024
f329c0e
write about what is a decorator in general
m7pr Nov 18, 2024
6140ff8
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 18, 2024
585a3ba
Update vignettes/decorate-module-output.Rmd
m7pr Nov 18, 2024
33b308f
fix: tests
averissimo Nov 18, 2024
44e4bc3
fix: long test name
averissimo Nov 18, 2024
134dcf4
fix: long test name
averissimo Nov 18, 2024
21d0e36
fix: namespace in tests
averissimo Nov 18, 2024
5e088eb
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 19, 2024
b91b8c0
Apply suggestions from code review
m7pr Nov 19, 2024
cbc401e
this req is not needed
m7pr Nov 19, 2024
8a34f0f
apply @pawelru feedback
m7pr Nov 19, 2024
2c0dbf0
fix: namespace change in server function applied to UI
averissimo Nov 19, 2024
ad54746
docs: test title
averissimo Nov 19, 2024
5b402e2
fix: reactivity issue
averissimo Nov 19, 2024
ffe1a19
docs: fix spelling
averissimo Nov 19, 2024
1ad0b84
Merge branch 'main' into 1187_decorate_output@main
averissimo Nov 20, 2024
f264ad1
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 20, 2024
20a3962
Update tests/testthat/test-teal_transform_module.R
m7pr Nov 20, 2024
0003fef
@averissimo suggestions on debounce removal
m7pr Nov 20, 2024
1b0d5fd
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 20, 2024
42035b7
Update decorators vignette for multiple decorators (#1418)
m7pr Nov 20, 2024
cc32fe0
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 20, 2024
e1e49da
fix superlintr
m7pr Nov 20, 2024
fbd34d8
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 20, 2024
113b0c7
feat: updates decorators argument on dummy
averissimo Nov 21, 2024
28c50a9
feat: add print statement to code
averissimo Nov 21, 2024
62913ae
fix: tests uses list of decorators
averissimo Nov 21, 2024
f493ee1
fix: corrects e2e tests and small fixes
averissimo Nov 21, 2024
fa298c8
docs: add decorators param
averissimo Nov 21, 2024
ed921de
chore: fix linter errors
averissimo Nov 21, 2024
26ceb2d
Update R/dummy_functions.R
averissimo Nov 21, 2024
452c9da
[skip style] [skip vbump] Restyle files
github-actions[bot] Nov 21, 2024
2078b1f
docs: fixes params documentation
averissimo Nov 21, 2024
4340c2b
chore: adds ggplot2 to suggests
averissimo Nov 21, 2024
8f42166
fix: update e2e test with newer examples code
averissimo Nov 21, 2024
ab8fe49
fix: examples
averissimo Nov 21, 2024
8cb4a52
fix: R CMD check note
averissimo Nov 21, 2024
e0b9e0e
fix: remove unnecessary div
averissimo Nov 22, 2024
a9a0b0e
chore: improve on error message
averissimo Nov 22, 2024
e7747c5
chore: improve on error message (missing on last commit)
averissimo Nov 22, 2024
a71e6d5
chore: use safer ids in transformators
averissimo Nov 22, 2024
be49c50
chore: minor rename of id
averissimo Nov 22, 2024
0f9565c
fix: show errors in transform even if there is no UI
averissimo Nov 22, 2024
f67584f
chore: rename ui/srv_teal_transform_data to ui/srv_transform_teal_data
averissimo Nov 22, 2024
6389232
fix: e2e test that had the old namespace
averissimo Nov 22, 2024
347b82a
fix: typo on documentation
averissimo Nov 22, 2024
0a15929
Fix examples on decorator vignette (#1423)
llrs-roche Nov 22, 2024
6c353fe
fix: reactivity on input
averissimo Nov 26, 2024
3a9c68f
example for multiple outputs
m7pr Nov 29, 2024
8992555
Update vignettes/decorate-module-output.Rmd
m7pr Nov 29, 2024
6cd9662
Update vignettes/decorate-module-output.Rmd
m7pr Nov 29, 2024
a91a1cf
Update vignettes/decorate-module-output.Rmd
m7pr Nov 29, 2024
2685527
Update vignettes/decorate-module-output.Rmd
m7pr Nov 29, 2024
e04a892
Update vignettes/decorate-module-output.Rmd
m7pr Nov 29, 2024
33749d8
Update vignettes/decorate-module-output.Rmd
m7pr Nov 29, 2024
be6fa32
Update vignettes/decorate-module-output.Rmd
averissimo Nov 29, 2024
51b0964
Update vignettes/decorate-module-output.Rmd
averissimo Nov 29, 2024
2fd5402
docs: vignette cleanup
averissimo Nov 29, 2024
93fe55c
Merge branch 'main' into 1187_decorate_output@main
averissimo Nov 29, 2024
e2f58e9
pr feedback: simplify
averissimo Nov 29, 2024
e5acbdc
chore: add formatters to lookup references
averissimo Nov 29, 2024
c36e7b9
chore: minor clean of vignette
averissimo Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Imports:
utils
Suggests:
bslib,
ggplot2 (>= 3.4.0),
knitr (>= 1.42),
mirai (>= 1.1.1),
MultiAssayExperiment,
Expand Down Expand Up @@ -122,6 +123,7 @@ Collate:
'teal_reporter.R'
'teal_slices-store.R'
'teal_slices.R'
'teal_transform_module.R'
'utils.R'
'validate_inputs.R'
'validations.R'
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export(get_code_tdata)
export(get_metadata)
export(init)
export(landing_popup_module)
export(make_teal_transform_server)
export(module)
export(modules)
export(new_tdata)
Expand All @@ -31,12 +32,14 @@ export(set_datanames)
export(show_rcode_modal)
export(srv_teal)
export(srv_teal_with_splash)
export(srv_transform_teal_data)
export(tdata2env)
export(teal_data_module)
export(teal_slices)
export(teal_transform_module)
export(ui_teal)
export(ui_teal_with_splash)
export(ui_transform_teal_data)
export(validate_has_data)
export(validate_has_elements)
export(validate_has_variable)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### New features

* Possible to call `ui_teal` and `srv_teal` directly in any application by delivering `data` argument as a `reactive` returning `teal_data` object. #669
* Introduced `teal_transform_module` to provide a way to interactively modify data delivered to `teal_module`'s `server`. #1228
* Introduced `teal_transform_module` to provide a way to interactively modify data delivered to `teal_module`'s `server` and to decorate module outputs. #1228 #1384
* Introduced a new argument `once = FALSE` in `teal_data_module` to possibly reload data during a run time.
* Possibility to download lockfile to restore app session for reproducibility. #479
* Introduced a function `set_datanames()` to change a `datanames` of the `teal_module`.
Expand Down
50 changes: 43 additions & 7 deletions R/dummy_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
#'
#' `r lifecycle::badge("experimental")`
#'
#' This module creates an object called `object` that can be modified with decorators.
#' The `object` is determined by what's selected in `Choose a dataset` input in UI.
#' The object can be anything that can be handled by `renderPrint()`.
#' See the `vignette("decorate-modules-output", package = "teal")` or [`teal_transform_module`]
#' to read more about decorators.
#'
#' @inheritParams teal_modules
#' @param decorators `r lifecycle::badge("experimental")` (`list` of `teal_transform_module` or `NULL`) optional,
#' if not `NULL`, decorator for tables or plots included in the module.
#'
#' @return A `teal` module which can be included in the `modules` argument to [init()].
#' @examples
#' app <- init(
Expand All @@ -13,11 +22,16 @@
#' shinyApp(app$ui, app$server)
#' }
#' @export
example_module <- function(label = "example teal module", datanames = "all", transformers = list()) {
example_module <- function(label = "example teal module",
datanames = "all",
transformators = list(),
decorators = NULL) {
checkmate::assert_string(label)
checkmate::assert_list(decorators, "teal_transform_module", null.ok = TRUE)

ans <- module(
label,
server = function(id, data) {
server = function(id, data, decorators) {
checkmate::assert_class(isolate(data()), "teal_data")
moduleServer(id, function(input, output, session) {
datanames_rv <- reactive(names(req(data())))
Expand All @@ -36,30 +50,52 @@ example_module <- function(label = "example teal module", datanames = "all", tra
)
})

output$text <- renderPrint({
table_data <- reactive({
req(input$dataname)
data()[[input$dataname]]
within(data(),
m7pr marked this conversation as resolved.
Show resolved Hide resolved
{
object <- dataname
},
dataname = as.name(input$dataname)
)
})

table_data_decorated_no_print <- srv_transform_teal_data(
"decorate",
data = table_data,
transformators = decorators
)
table_data_decorated <- reactive(within(req(table_data_decorated_no_print()), expr = object))

output$text <- renderPrint({
req(table_data()) # Ensure original errors from module are displayed
table_data_decorated()[["object"]]
})

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(data())),
verbatim_content = reactive(teal.code::get_code(req(table_data_decorated()))),
averissimo marked this conversation as resolved.
Show resolved Hide resolved
title = "Example Code"
)

table_data_decorated
})
},
ui = function(id) {
ui = function(id, decorators) {
ns <- NS(id)
teal.widgets::standard_layout(
output = verbatimTextOutput(ns("text")),
encoding = tags$div(
selectInput(ns("dataname"), "Choose a dataset", choices = NULL),
ui_transform_teal_data(ns("decorate"), transformators = decorators),
teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
)
)
},
ui_args = list(decorators = decorators),
server_args = list(decorators = decorators),
datanames = datanames,
transformers = transformers
transformators = transformators
)
attr(ans, "teal_bookmarkable") <- TRUE
ans
Expand Down
2 changes: 1 addition & 1 deletion R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ init <- function(data,
}

is_modules_ok <- check_modules_datanames(modules, names(data))
if (!isTRUE(is_modules_ok) && length(unlist(extract_transformers(modules))) == 0) {
if (!isTRUE(is_modules_ok) && length(unlist(extract_transformators(modules))) == 0) {
warning(is_modules_ok, call. = FALSE)
}

Expand Down
4 changes: 2 additions & 2 deletions R/module_data_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ get_filter_overview_wrapper <- function(teal_data) {

current_data_objs <- sapply(
datanames,
function(name) teal.code::get_var(teal_data(), name),
function(name) teal_data()[[name]],
simplify = FALSE
)
initial_data_objs <- teal.code::get_var(teal_data(), ".raw_data")
initial_data_objs <- teal_data()[[".raw_data"]]

out <- lapply(
datanames,
Expand Down
46 changes: 19 additions & 27 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ ui_teal_module.teal_module <- function(id, modules, depth = 0L) {
args <- c(list(id = ns("module")), modules$ui_args)

ui_teal <- tagList(
div(
id = ns("validate_datanames"),
ui_validate_reactive_teal_data(ns("validate_datanames"))
),
shinyjs::hidden(
tags$div(
id = ns("transformer_failure_info"),
id = ns("transform_failure_info"),
class = "teal_validated",
div(
class = "teal-output-warning",
"One of transformers failed. Please fix and continue."
"One of transformators failed. Please check its inputs."
)
)
),
tags$div(
id = ns("teal_module_ui"),
tags$div(
class = "teal_validated",
ui_check_module_datanames(ns("validate_datanames"))
),
do.call(modules$ui, args)
)
)
Expand All @@ -125,18 +125,12 @@ ui_teal_module.teal_module <- function(id, modules, depth = 0L) {
width = 3,
ui_data_summary(ns("data_summary")),
ui_filter_data(ns("filter_panel")),
ui_transform_data(ns("data_transform"), transformers = modules$transformers, class = "well"),
ui_transform_teal_data(ns("data_transform"), transformators = modules$transformators, class = "well"),
class = "teal_secondary_col"
)
)
} else {
div(
div(
class = "teal_validated",
uiOutput(ns("data_input_error"))
),
ui_teal
)
ui_teal
}
)
)
Expand Down Expand Up @@ -266,27 +260,25 @@ srv_teal_module.teal_module <- function(id,
data_rv = data_rv,
is_active = is_active
)
is_transformer_failed <- reactiveValues()
transformed_teal_data <- srv_transform_data(
is_transform_failed <- reactiveValues()
transformed_teal_data <- srv_transform_teal_data(
"data_transform",
data = filtered_teal_data,
transformers = modules$transformers,
transformators = modules$transformators,
modules = modules,
is_transformer_failed = is_transformer_failed
is_transform_failed = is_transform_failed
)
any_transformer_failed <- reactive({
any(unlist(reactiveValuesToList(is_transformer_failed)))
any_transform_failed <- reactive({
any(unlist(reactiveValuesToList(is_transform_failed)))
})

observeEvent(any_transformer_failed(), {
if (isTRUE(any_transformer_failed())) {
observeEvent(any_transform_failed(), {
if (isTRUE(any_transform_failed())) {
shinyjs::hide("teal_module_ui")
shinyjs::hide("validate_datanames")
shinyjs::show("transformer_failure_info")
shinyjs::show("transform_failure_info")
} else {
shinyjs::show("teal_module_ui")
shinyjs::show("validate_datanames")
shinyjs::hide("transformer_failure_info")
shinyjs::hide("transform_failure_info")
}
})

Expand All @@ -297,7 +289,7 @@ srv_teal_module.teal_module <- function(id,
all_teal_data[c(module_datanames, ".raw_data")]
})

srv_validate_reactive_teal_data(
srv_check_module_datanames(
"validate_datanames",
data = module_teal_data,
modules = modules
Expand Down
24 changes: 17 additions & 7 deletions R/module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,20 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) {
)

data_pulled <- srv_init_data("data", data = data)
data_validated <- srv_validate_reactive_teal_data(
"validate",
data = data_pulled,
modules = modules,
validate_shiny_silent_error = FALSE

validate_ui <- tags$div(
id = session$ns("validate_messages"),
class = "teal_validated",
ui_check_class_teal_data(session$ns("class_teal_data")),
ui_validate_error(session$ns("silent_error")),
ui_check_module_datanames(session$ns("datanames_warning"))
)
srv_check_class_teal_data("class_teal_data", data_pulled)
srv_validate_error("silent_error", data_pulled, validate_shiny_silent_error = FALSE)
srv_check_module_datanames("datanames_warning", data_pulled, modules)

data_validated <- .trigger_on_success(data_pulled)

data_rv <- reactive({
req(inherits(data_validated(), "teal_data"))
is_filter_ok <- check_filter_datanames(filter, names(data_validated()))
Expand Down Expand Up @@ -226,6 +234,8 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) {
})
}



if (inherits(data, "teal_data_module")) {
setBookmarkExclude(c("teal_modules-active_tab"))
shiny::insertTab(
Expand All @@ -237,7 +247,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) {
value = "teal_data_module",
tags$div(
ui_init_data(session$ns("data")),
ui_validate_reactive_teal_data(session$ns("validate"))
validate_ui
)
)
)
Expand All @@ -254,7 +264,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) {
insertUI(
selector = sprintf("#%s", session$ns("tabpanel_wrapper")),
where = "beforeBegin",
ui = tags$div(ui_validate_reactive_teal_data(session$ns("validate")), tags$br())
ui = tags$div(validate_ui, tags$br())
)
}

Expand Down
Loading