Open gogonzo opened 1 week ago
CLA Assistant Lite bot ✅ All contributors have signed the CLA
Can app developer provide simple js code to hide all elements of certain class (for example reporter buttons)
So to inject the JS to teal, one will have to code teal as a module so they can pass tags$head(tags$script())
in fluidPage
?
From the code example:
data_rv <- srv_data("data", data = data, modules = modules, filter = filter)
srv_teal_1.0(id = "teal", data = data_rv, modules = modules, filter = filter)
Why do we need to pass built data_rv
before passing to srv_teal_1.0
?
Why do we need to pass built
data_rv
before passing tosrv_teal_1.0
?
This is an example of using teal
as a module. In this example I prove that you can wrap teal in the external app and pass reactive data to teal
, resubmit and it will still work
Fixes #669 #860
teal.slice
branch669_insertUI@main
to check:
ui_teal
andsrv_teal
in any application (see teal as a module example below)teal_data_module
doesn't work on main branch. On main, ddl apps can't be restored. On the feature branch, apps are restored after clicking "submit" inteal_data_module
teal_bookmarkable = TRUE
are still bookmarkable.ddl app
```r options( teal.log_level = "TRACE", teal.show_js_log = TRUE, # teal.bs_theme = bslib::bs_theme(version = 5), shiny.bookmarkStore = "server" ) library(scda) pkgload::load_all("teal") # pkgload::load_all("teal.slice") data <- teal_data_module( ui = function(id) { ns <- NS(id) tagList( textInput(ns("username"), label = "Username"), passwordInput(ns("password"), label = "Password"), actionButton(ns("submit"), label = "Submit") ) }, server = function(id, ...) { moduleServer(id, function(input, output, session) { eventReactive(input$submit, { data <- teal_data() |> within( { logger::log_trace("Loading data") ADSL <- scda::synthetic_cdisc_data("latest")$adsl ADTTE <- scda::synthetic_cdisc_data("latest")$adtte iris <- iris }, username = input$username, password = input$password ) join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] data }) }) } ) app <- teal::init( data = data, modules = modules( teal.modules.general::tm_data_table("Data Table"), example_module("Example Module", datanames = "ADTTE"), module( ui = function(id) { ns <- NS(id) tagList( tableOutput(ns("filter_summary")) ) }, server = function(id, datasets) { moduleServer(id, function(input, output, session) { output$filter_summary <- renderTable({ datasets$get_filter_overview(datanames = datasets$datanames()) }) }) } ) ), filter = teal_slices( teal_slice("ADSL", "SEX"), teal_slice("ADSL", "AGE", selected = c(18L, 65L)), module_specific = TRUE, mapping = list( global_filters = "ADSL AGE", `Example Module` = "ADSL SEX" ) ) ) shinyApp(app$ui, app$server) ```teal as a module
```r options( teal.log_level = "TRACE", teal.show_js_log = TRUE, # teal.bs_theme = bslib::bs_theme(version = 5), shiny.bookmarkStore = "server" ) library(scda) pkgload::load_all("teal") # pkgload::load_all("teal.slice") ui_data <- function(id) { ns <- NS(id) tagList( textInput(ns("username"), label = "Username"), passwordInput(ns("password"), label = "Password"), actionButton(ns("submit"), label = "Submit") ) } srv_data <- function(id, ...) { moduleServer(id, function(input, output, session) { eventReactive(input$submit, { data <- teal_data() |> within( { logger::log_trace("Loading data") ADSL <- scda::synthetic_cdisc_data("latest")$adsl ADTTE <- scda::synthetic_cdisc_data("latest")$adtte iris <- iris }, username = input$username, password = input$password ) join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")] data }) }) } modules <- modules( teal.modules.general::tm_data_table("Data Table"), example_module("Example Module", datanames = "ADTTE"), module( ui = function(id) { ns <- NS(id) tagList( tableOutput(ns("filter_summary")) ) }, server = function(id, datasets) { moduleServer(id, function(input, output, session) { output$filter_summary <- renderTable({ datasets$get_filter_overview(datanames = datasets$datanames()) }) }) } ) ) filter <- teal_slices( teal_slice("ADSL", "SEX"), teal_slice("ADSL", "AGE", selected = c(18L, 65L)), module_specific = TRUE, mapping = list( global_filters = "ADSL AGE", `Example Module` = "ADSL SEX" ) ) shinyApp( ui = function(request) { fluidPage( ui_data("data"), ui_teal_1.0(id = "teal", modules = modules) ) }, server = function(input, output, session) { data_rv <- srv_data("data", data = data, modules = modules, filter = filter) srv_teal_1.0(id = "teal", data = data_rv, modules = modules, filter = filter) } ) ```