Skip to content

Commit

Permalink
update example module (#991)
Browse files Browse the repository at this point in the history
Modified `example_module` to remove `data` argument from UI function.
Data set selection is moved to a `renderUI` element on the server side.
  • Loading branch information
chlebowa authored Nov 30, 2023
1 parent 021678d commit 28e1972
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/dummy_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,25 @@ example_module <- function(label = "example teal module", datanames = "all") {
server = function(id, data) {
checkmate::assert_class(data(), "teal_data")
moduleServer(id, function(input, output, session) {
output$text <- renderPrint(data()[[input$dataname]])
ns <- session$ns
updateSelectInput(session, "dataname", choices = isolate(teal.data::datanames(data())))
output$text <- renderPrint({
req(input$dataname)
data()[[input$dataname]]
})
teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(data())),
title = "Association Plot"
)
})
},
ui = function(id, data) {
ui = function(id) {
ns <- NS(id)
teal.widgets::standard_layout(
output = verbatimTextOutput(ns("text")),
encoding = div(
selectInput(ns("dataname"), "Choose a dataset", choices = teal.data::datanames(data)),
selectInput(ns("dataname"), "Choose a dataset", choices = NULL),
teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
)
)
Expand Down

0 comments on commit 28e1972

Please sign in to comment.