From 2e06eaff883e4bd7dc8f692625ddc45c09fea5da Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 12 Oct 2023 15:39:27 +0200 Subject: [PATCH 01/84] #812 proposition for landing popup with shinyalert package --- DESCRIPTION | 1 + R/init.R | 25 +++++++++++++++++++++++-- man/init.Rd | 13 +++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0930538a7c..833c7a06c5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,6 +40,7 @@ Imports: logger (>= 0.2.0), magrittr, rlang, + shinyalert, shinyjs, stats, teal.logger (>= 0.1.1), diff --git a/R/init.R b/R/init.R index 4fdb147951..fc1c5d8776 100644 --- a/R/init.R +++ b/R/init.R @@ -45,6 +45,8 @@ #' the server function must be called with [shiny::moduleServer()]; #' See the vignette for an example. However, [ui_teal_with_splash()] #' is then preferred to this function. +#' @param langind A named `list` with 3 character elements `title`, `text` and `button`. They +#' will be passed to a disclaimer landing popup created with [shinyalert::shinyalert]. #' #' @return named list with `server` and `ui` function #' @@ -100,7 +102,12 @@ #' ) #' ), #' header = tags$h1("Sample App"), -#' footer = tags$p("Copyright 2017 - 2023") +#' footer = tags$p("Copyright 2017 - 2023"), +#' landing = list( +#' title = 'Disclaimer', +#' text = 'By agreeing to this statement you confirm you accept A, B and C.', +#' button = 'Agree' +#' ) #' ) #' if (interactive()) { #' shinyApp(app$ui, app$server) @@ -112,7 +119,8 @@ init <- function(data, filter = teal_slices(), header = tags$p(), footer = tags$p(), - id = character(0)) { + id = character(0), + landing = NULL) { logger::log_trace("init initializing teal app with: data ({ class(data)[1] }).") data <- teal.data::to_relational_data(data = data) @@ -126,6 +134,10 @@ init <- function(data, checkmate::assert_multi_class(header, c("shiny.tag", "character")) checkmate::assert_multi_class(footer, c("shiny.tag", "character")) checkmate::assert_character(id, max.len = 1, any.missing = FALSE) + checkmate::check_list(landing, names = "named", null.ok = TRUE) + if (is.list(landing)) { + checkmate::check_names(names(landing), subset.of = c('title', 'text', 'button')) + } teal.logger::log_system_info() @@ -212,6 +224,15 @@ init <- function(data, res <- list( ui = ui_teal_with_splash(id = id, data = data, title = title, header = header, footer = footer), server = function(input, output, session) { + if (!is.null(landing)) { + shinyalert::shinyalert( + title = landing$title, + text = landing$text, + type = "info", + showConfirmButton = TRUE, + confirmButtonText = landing$button + ) + } # copy object so that load won't be shared between the session data <- data$copy(deep = TRUE) filter <- deep_copy_filter(filter) diff --git a/man/init.Rd b/man/init.Rd index 234f60697f..ca0e259d01 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -11,7 +11,8 @@ init( filter = teal_slices(), header = tags$p(), footer = tags$p(), - id = character(0) + id = character(0), + landing = NULL ) } \arguments{ @@ -52,6 +53,9 @@ module id to embed it, if provided, the server function must be called with \code{\link[shiny:moduleServer]{shiny::moduleServer()}}; See the vignette for an example. However, \code{\link[=ui_teal_with_splash]{ui_teal_with_splash()}} is then preferred to this function.} + +\item{langind}{A named \code{list} with 3 character elements \code{title}, \code{text} and \code{button}. They +will be passed to a disclaimer landing popup created with \link[shinyalert:shinyalert]{shinyalert::shinyalert}.} } \value{ named list with \code{server} and \code{ui} function @@ -113,7 +117,12 @@ app <- init( ) ), header = tags$h1("Sample App"), - footer = tags$p("Copyright 2017 - 2023") + footer = tags$p("Copyright 2017 - 2023"), + landing = list( + title = 'Disclaimer', + text = 'By agreeing to this statement you confirm you accept A, B and C.', + button = 'Agree' + ) ) if (interactive()) { shinyApp(app$ui, app$server) From 713b37fcc4b9dfc365c918149fd1e223f83dfb4f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:47:19 +0000 Subject: [PATCH 02/84] [skip actions] Restyle files --- R/init.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/init.R b/R/init.R index fc1c5d8776..04e7ed6716 100644 --- a/R/init.R +++ b/R/init.R @@ -104,9 +104,9 @@ #' header = tags$h1("Sample App"), #' footer = tags$p("Copyright 2017 - 2023"), #' landing = list( -#' title = 'Disclaimer', -#' text = 'By agreeing to this statement you confirm you accept A, B and C.', -#' button = 'Agree' +#' title = "Disclaimer", +#' text = "By agreeing to this statement you confirm you accept A, B and C.", +#' button = "Agree" #' ) #' ) #' if (interactive()) { @@ -136,7 +136,7 @@ init <- function(data, checkmate::assert_character(id, max.len = 1, any.missing = FALSE) checkmate::check_list(landing, names = "named", null.ok = TRUE) if (is.list(landing)) { - checkmate::check_names(names(landing), subset.of = c('title', 'text', 'button')) + checkmate::check_names(names(landing), subset.of = c("title", "text", "button")) } teal.logger::log_system_info() From 18834f459cf51dbc535a58afe68b3764ae146aa6 Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 12 Oct 2023 16:02:57 +0200 Subject: [PATCH 03/84] Empty-Commit From 02b83fd91e5eae3ad8c32f0956cfccb45eb4eb1b Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:07:35 +0000 Subject: [PATCH 04/84] [skip actions] Roxygen Man Pages Auto Update --- man/init.Rd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/init.Rd b/man/init.Rd index ca0e259d01..3f630fb872 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -119,9 +119,9 @@ app <- init( header = tags$h1("Sample App"), footer = tags$p("Copyright 2017 - 2023"), landing = list( - title = 'Disclaimer', - text = 'By agreeing to this statement you confirm you accept A, B and C.', - button = 'Agree' + title = "Disclaimer", + text = "By agreeing to this statement you confirm you accept A, B and C.", + button = "Agree" ) ) if (interactive()) { From e920f50d1955f7956cabcc8595eec2a69b863540 Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 12 Oct 2023 16:08:47 +0200 Subject: [PATCH 05/84] Empty-Commit From 3dcccf3fb538c2d4bd1ac398cc488b2969c12b29 Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 12 Oct 2023 16:21:37 +0200 Subject: [PATCH 06/84] typo --- R/init.R | 2 +- man/init.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/init.R b/R/init.R index 04e7ed6716..8ed1fe128a 100644 --- a/R/init.R +++ b/R/init.R @@ -45,7 +45,7 @@ #' the server function must be called with [shiny::moduleServer()]; #' See the vignette for an example. However, [ui_teal_with_splash()] #' is then preferred to this function. -#' @param langind A named `list` with 3 character elements `title`, `text` and `button`. They +#' @param landing A named `list` with 3 character elements `title`, `text` and `button`. They #' will be passed to a disclaimer landing popup created with [shinyalert::shinyalert]. #' #' @return named list with `server` and `ui` function diff --git a/man/init.Rd b/man/init.Rd index 3f630fb872..3353c5d32f 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -54,7 +54,7 @@ the server function must be called with \code{\link[shiny:moduleServer]{shiny::m See the vignette for an example. However, \code{\link[=ui_teal_with_splash]{ui_teal_with_splash()}} is then preferred to this function.} -\item{langind}{A named \code{list} with 3 character elements \code{title}, \code{text} and \code{button}. They +\item{landing}{A named \code{list} with 3 character elements \code{title}, \code{text} and \code{button}. They will be passed to a disclaimer landing popup created with \link[shinyalert:shinyalert]{shinyalert::shinyalert}.} } \value{ From 5d338932e48d90c3df5ade51b39b24df8829fe41 Mon Sep 17 00:00:00 2001 From: m7pr Date: Fri, 13 Oct 2023 11:47:34 +0200 Subject: [PATCH 07/84] Empty-Commit From f973beb78965fbadd5e7f18843ba752f3b4052a3 Mon Sep 17 00:00:00 2001 From: m7pr Date: Fri, 13 Oct 2023 12:04:35 +0200 Subject: [PATCH 08/84] rename landing param to extra_server in teal --- NAMESPACE | 1 + R/init.R | 21 ++++----------------- R/utils.R | 17 +++++++++++++++++ man/init.Rd | 7 +++---- man/landing_modal.Rd | 14 ++++++++++++++ 5 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 man/landing_modal.Rd diff --git a/NAMESPACE b/NAMESPACE index 4711ead7a4..dee47cf21f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,6 +24,7 @@ export(get_code_tdata) export(get_join_keys) export(get_metadata) export(init) +export(landing_modal) export(module) export(modules) export(new_tdata) diff --git a/R/init.R b/R/init.R index 8ed1fe128a..baa7937983 100644 --- a/R/init.R +++ b/R/init.R @@ -45,8 +45,7 @@ #' the server function must be called with [shiny::moduleServer()]; #' See the vignette for an example. However, [ui_teal_with_splash()] #' is then preferred to this function. -#' @param landing A named `list` with 3 character elements `title`, `text` and `button`. They -#' will be passed to a disclaimer landing popup created with [shinyalert::shinyalert]. +#' @param extra_server A list of elements passed to `shiny::server`. #' #' @return named list with `server` and `ui` function #' @@ -103,7 +102,7 @@ #' ), #' header = tags$h1("Sample App"), #' footer = tags$p("Copyright 2017 - 2023"), -#' landing = list( +#' extra_server = landing_modal( #' title = "Disclaimer", #' text = "By agreeing to this statement you confirm you accept A, B and C.", #' button = "Agree" @@ -120,7 +119,7 @@ init <- function(data, header = tags$p(), footer = tags$p(), id = character(0), - landing = NULL) { + extra_server = NULL) { logger::log_trace("init initializing teal app with: data ({ class(data)[1] }).") data <- teal.data::to_relational_data(data = data) @@ -134,10 +133,6 @@ init <- function(data, checkmate::assert_multi_class(header, c("shiny.tag", "character")) checkmate::assert_multi_class(footer, c("shiny.tag", "character")) checkmate::assert_character(id, max.len = 1, any.missing = FALSE) - checkmate::check_list(landing, names = "named", null.ok = TRUE) - if (is.list(landing)) { - checkmate::check_names(names(landing), subset.of = c("title", "text", "button")) - } teal.logger::log_system_info() @@ -224,15 +219,7 @@ init <- function(data, res <- list( ui = ui_teal_with_splash(id = id, data = data, title = title, header = header, footer = footer), server = function(input, output, session) { - if (!is.null(landing)) { - shinyalert::shinyalert( - title = landing$title, - text = landing$text, - type = "info", - showConfirmButton = TRUE, - confirmButtonText = landing$button - ) - } + extra_server # copy object so that load won't be shared between the session data <- data$copy(deep = TRUE) filter <- deep_copy_filter(filter) diff --git a/R/utils.R b/R/utils.R index 9d284e5054..131161a18a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -46,3 +46,20 @@ include_parent_datanames <- function(dataname, join_keys) { return(unique(c(parents, dataname))) } + +#' @title A Landing Page Popup +#' @description Should be a part of `teal.modules.general` +#' @param title,text,button Arguments passed to `shinyalert::shinyalert`. +#' +#' @export +landing_modal <- function(title = NULL, text = NULL, button = NULL) { + checkmate::assert_string(title, null.ok = TRUE) + checkmate::assert_string(text, null.ok = TRUE) + checkmate::assert_string(button, null.ok = TRUE) + shinyalert::shinyalert( + title = title, + text = text, + type = "info", + confirmButtonText = button + ) +} diff --git a/man/init.Rd b/man/init.Rd index 3353c5d32f..2e0795d224 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -12,7 +12,7 @@ init( header = tags$p(), footer = tags$p(), id = character(0), - landing = NULL + extra_server = NULL ) } \arguments{ @@ -54,8 +54,7 @@ the server function must be called with \code{\link[shiny:moduleServer]{shiny::m See the vignette for an example. However, \code{\link[=ui_teal_with_splash]{ui_teal_with_splash()}} is then preferred to this function.} -\item{landing}{A named \code{list} with 3 character elements \code{title}, \code{text} and \code{button}. They -will be passed to a disclaimer landing popup created with \link[shinyalert:shinyalert]{shinyalert::shinyalert}.} +\item{extra_server}{A list of elements passed to \code{shiny::server}.} } \value{ named list with \code{server} and \code{ui} function @@ -118,7 +117,7 @@ app <- init( ), header = tags$h1("Sample App"), footer = tags$p("Copyright 2017 - 2023"), - landing = list( + extra_server = landing_modal( title = "Disclaimer", text = "By agreeing to this statement you confirm you accept A, B and C.", button = "Agree" diff --git a/man/landing_modal.Rd b/man/landing_modal.Rd new file mode 100644 index 0000000000..8d43775be9 --- /dev/null +++ b/man/landing_modal.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{landing_modal} +\alias{landing_modal} +\title{A Landing Page Popup} +\usage{ +landing_modal(title = NULL, text = NULL, button = NULL) +} +\arguments{ +\item{title, text, button}{Arguments passed to \code{shinyalert::shinyalert}.} +} +\description{ +Should be a part of \code{teal.modules.general} +} From a04ee4acb255564bbc77358e6f72709d732e9333 Mon Sep 17 00:00:00 2001 From: m7pr Date: Fri, 13 Oct 2023 12:35:01 +0200 Subject: [PATCH 09/84] move out landing popup to teal.modules.general --- DESCRIPTION | 1 - NAMESPACE | 1 - R/init.R | 8 ++++---- R/utils.R | 17 ----------------- man/init.Rd | 8 ++++---- man/landing_modal.Rd | 14 -------------- 6 files changed, 8 insertions(+), 41 deletions(-) delete mode 100644 man/landing_modal.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 833c7a06c5..0930538a7c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,7 +40,6 @@ Imports: logger (>= 0.2.0), magrittr, rlang, - shinyalert, shinyjs, stats, teal.logger (>= 0.1.1), diff --git a/NAMESPACE b/NAMESPACE index dee47cf21f..4711ead7a4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,7 +24,6 @@ export(get_code_tdata) export(get_join_keys) export(get_metadata) export(init) -export(landing_modal) export(module) export(modules) export(new_tdata) diff --git a/R/init.R b/R/init.R index baa7937983..346dda1b70 100644 --- a/R/init.R +++ b/R/init.R @@ -102,10 +102,10 @@ #' ), #' header = tags$h1("Sample App"), #' footer = tags$p("Copyright 2017 - 2023"), -#' extra_server = landing_modal( -#' title = "Disclaimer", -#' text = "By agreeing to this statement you confirm you accept A, B and C.", -#' button = "Agree" +#' extra_server = teal.modules.general::tm_landing_popup( +#' title = "Welcome", +#' text = "A place for a welcome message or a disclaimer statement.", +#' button = "Proceed" #' ) #' ) #' if (interactive()) { diff --git a/R/utils.R b/R/utils.R index 131161a18a..9d284e5054 100644 --- a/R/utils.R +++ b/R/utils.R @@ -46,20 +46,3 @@ include_parent_datanames <- function(dataname, join_keys) { return(unique(c(parents, dataname))) } - -#' @title A Landing Page Popup -#' @description Should be a part of `teal.modules.general` -#' @param title,text,button Arguments passed to `shinyalert::shinyalert`. -#' -#' @export -landing_modal <- function(title = NULL, text = NULL, button = NULL) { - checkmate::assert_string(title, null.ok = TRUE) - checkmate::assert_string(text, null.ok = TRUE) - checkmate::assert_string(button, null.ok = TRUE) - shinyalert::shinyalert( - title = title, - text = text, - type = "info", - confirmButtonText = button - ) -} diff --git a/man/init.Rd b/man/init.Rd index 2e0795d224..2bdc348534 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -117,10 +117,10 @@ app <- init( ), header = tags$h1("Sample App"), footer = tags$p("Copyright 2017 - 2023"), - extra_server = landing_modal( - title = "Disclaimer", - text = "By agreeing to this statement you confirm you accept A, B and C.", - button = "Agree" + extra_server = teal.modules.general::tm_landing_popup( + title = "Welcome", + text = "A place for the welcome message or a disclaimer statement.", + button = "Proceed" ) ) if (interactive()) { diff --git a/man/landing_modal.Rd b/man/landing_modal.Rd deleted file mode 100644 index 8d43775be9..0000000000 --- a/man/landing_modal.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{landing_modal} -\alias{landing_modal} -\title{A Landing Page Popup} -\usage{ -landing_modal(title = NULL, text = NULL, button = NULL) -} -\arguments{ -\item{title, text, button}{Arguments passed to \code{shinyalert::shinyalert}.} -} -\description{ -Should be a part of \code{teal.modules.general} -} From aa253fabc38a795a6c27cc181018e600d550a7bd Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 13 Oct 2023 10:40:12 +0000 Subject: [PATCH 10/84] [skip actions] Roxygen Man Pages Auto Update --- man/init.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/init.Rd b/man/init.Rd index 2bdc348534..e14cda6540 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -119,7 +119,7 @@ app <- init( footer = tags$p("Copyright 2017 - 2023"), extra_server = teal.modules.general::tm_landing_popup( title = "Welcome", - text = "A place for the welcome message or a disclaimer statement.", + text = "A place for a welcome message or a disclaimer statement.", button = "Proceed" ) ) From 66662373c844008ea1d8ae732357c004b45422ee Mon Sep 17 00:00:00 2001 From: m7pr Date: Fri, 13 Oct 2023 14:10:29 +0200 Subject: [PATCH 11/84] update examples --- R/init.R | 4 ++-- man/init.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/init.R b/R/init.R index 346dda1b70..4c46a00c0e 100644 --- a/R/init.R +++ b/R/init.R @@ -102,10 +102,10 @@ #' ), #' header = tags$h1("Sample App"), #' footer = tags$p("Copyright 2017 - 2023"), -#' extra_server = teal.modules.general::tm_landing_popup( +#' extra_server = teal.modules.general::landing_popup( #' title = "Welcome", #' text = "A place for a welcome message or a disclaimer statement.", -#' button = "Proceed" +#' button = modalButton("Proceed") #' ) #' ) #' if (interactive()) { diff --git a/man/init.Rd b/man/init.Rd index e14cda6540..0d4df7a818 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -117,10 +117,10 @@ app <- init( ), header = tags$h1("Sample App"), footer = tags$p("Copyright 2017 - 2023"), - extra_server = teal.modules.general::tm_landing_popup( + extra_server = teal.modules.general::landing_popup( title = "Welcome", text = "A place for a welcome message or a disclaimer statement.", - button = "Proceed" + button = modalButton("Proceed") ) ) if (interactive()) { From eb3bffa917726ad27d9606743f3f5ee2f0c0b729 Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 16 Oct 2023 11:44:53 +0200 Subject: [PATCH 12/84] add teal.modules.general to Suggests --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 95328de84b..7085e9141b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -56,6 +56,7 @@ Suggests: rmarkdown, shinyvalidate, teal.code (>= 0.3.0.9009), + teal.modules.general, testthat (>= 3.1.5), withr, yaml From 0bd57c64e807ec4bc6bc59197ab0586d56202dab Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 16 Oct 2023 14:00:32 +0200 Subject: [PATCH 13/84] remove extra_server parameter --- DESCRIPTION | 1 - R/init.R | 12 ++---------- man/init.Rd | 12 ++---------- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7085e9141b..95328de84b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -56,7 +56,6 @@ Suggests: rmarkdown, shinyvalidate, teal.code (>= 0.3.0.9009), - teal.modules.general, testthat (>= 3.1.5), withr, yaml diff --git a/R/init.R b/R/init.R index 4c46a00c0e..4fdb147951 100644 --- a/R/init.R +++ b/R/init.R @@ -45,7 +45,6 @@ #' the server function must be called with [shiny::moduleServer()]; #' See the vignette for an example. However, [ui_teal_with_splash()] #' is then preferred to this function. -#' @param extra_server A list of elements passed to `shiny::server`. #' #' @return named list with `server` and `ui` function #' @@ -101,12 +100,7 @@ #' ) #' ), #' header = tags$h1("Sample App"), -#' footer = tags$p("Copyright 2017 - 2023"), -#' extra_server = teal.modules.general::landing_popup( -#' title = "Welcome", -#' text = "A place for a welcome message or a disclaimer statement.", -#' button = modalButton("Proceed") -#' ) +#' footer = tags$p("Copyright 2017 - 2023") #' ) #' if (interactive()) { #' shinyApp(app$ui, app$server) @@ -118,8 +112,7 @@ init <- function(data, filter = teal_slices(), header = tags$p(), footer = tags$p(), - id = character(0), - extra_server = NULL) { + id = character(0)) { logger::log_trace("init initializing teal app with: data ({ class(data)[1] }).") data <- teal.data::to_relational_data(data = data) @@ -219,7 +212,6 @@ init <- function(data, res <- list( ui = ui_teal_with_splash(id = id, data = data, title = title, header = header, footer = footer), server = function(input, output, session) { - extra_server # copy object so that load won't be shared between the session data <- data$copy(deep = TRUE) filter <- deep_copy_filter(filter) diff --git a/man/init.Rd b/man/init.Rd index 0d4df7a818..234f60697f 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -11,8 +11,7 @@ init( filter = teal_slices(), header = tags$p(), footer = tags$p(), - id = character(0), - extra_server = NULL + id = character(0) ) } \arguments{ @@ -53,8 +52,6 @@ module id to embed it, if provided, the server function must be called with \code{\link[shiny:moduleServer]{shiny::moduleServer()}}; See the vignette for an example. However, \code{\link[=ui_teal_with_splash]{ui_teal_with_splash()}} is then preferred to this function.} - -\item{extra_server}{A list of elements passed to \code{shiny::server}.} } \value{ named list with \code{server} and \code{ui} function @@ -116,12 +113,7 @@ app <- init( ) ), header = tags$h1("Sample App"), - footer = tags$p("Copyright 2017 - 2023"), - extra_server = teal.modules.general::landing_popup( - title = "Welcome", - text = "A place for a welcome message or a disclaimer statement.", - button = modalButton("Proceed") - ) + footer = tags$p("Copyright 2017 - 2023") ) if (interactive()) { shinyApp(app$ui, app$server) From b86ccff9fdc993fce228c032da87d2c6debb286e Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 16 Oct 2023 16:43:17 +0200 Subject: [PATCH 14/84] Remove module labelled "Landing Popup" from modules list and pass it to server directly --- R/init.R | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/R/init.R b/R/init.R index 4fdb147951..452fa51291 100644 --- a/R/init.R +++ b/R/init.R @@ -46,6 +46,8 @@ #' See the vignette for an example. However, [ui_teal_with_splash()] #' is then preferred to this function. #' +#' @note If you use a module labelled `"Landing Popup"` `teal` will not create a tab for this module. +#' #' @return named list with `server` and `ui` function #' #' @export @@ -205,6 +207,20 @@ init <- function(data, } } + # In case of a "Landing Popup", do not create a module for it. Just extract the module and use directly in server. + # Assuming "Landing Popup" is not used in a nested module. + labels <- module_labels(modules) + lp_cond <- "Landing_Popup" %in% names(labels) + + if (!lp_cond && "Landing Page" %in% unlist(labels)) { + stop("Please do not use a module labelled 'Landing Popup' within a nested module.") + } else if (lp_cond) { + landing_popup <- modules$children[which(lp_cond)] + modules$children <- modules$children[-which(lp_cond)] + } else { + landing_popup <- NULL + } + # Note regarding case `id = character(0)`: # rather than using `callModule` and creating a submodule of this module, we directly modify # the `ui` and `server` with `id = character(0)` and calling the server function directly @@ -212,6 +228,7 @@ init <- function(data, res <- list( ui = ui_teal_with_splash(id = id, data = data, title = title, header = header, footer = footer), server = function(input, output, session) { + landing_popup # copy object so that load won't be shared between the session data <- data$copy(deep = TRUE) filter <- deep_copy_filter(filter) From 4f01d3170eb3f8d69beb3e4e0fffa1a494ec6239 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:49:09 +0000 Subject: [PATCH 15/84] [skip actions] Roxygen Man Pages Auto Update --- man/init.Rd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/man/init.Rd b/man/init.Rd index 234f60697f..a60f6c1735 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -65,6 +65,9 @@ teal app that is composed out of teal modules. This is a wrapper function around the \code{module_teal.R} functions. Unless you are an end-user, don't use this function, but instead this module. } +\note{ +If you use a module labelled \code{"Landing Popup"} \code{teal} will not create a tab for this module. +} \examples{ new_iris <- transform(iris, id = seq_len(nrow(iris))) new_mtcars <- transform(mtcars, id = seq_len(nrow(mtcars))) From 5d1841788a6ef94bc093ab3ebfbb9bd456836b43 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 17 Oct 2023 17:40:21 +0200 Subject: [PATCH 16/84] fix teal::init server usage of landing popup thanks to @chlebowa ideas --- R/init.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index 452fa51291..67faa4e1bd 100644 --- a/R/init.R +++ b/R/init.R @@ -228,7 +228,9 @@ init <- function(data, res <- list( ui = ui_teal_with_splash(id = id, data = data, title = title, header = header, footer = footer), server = function(input, output, session) { - landing_popup + if (length(landing_popup) > 0L) { + do.call(landing_popup[[1]]$server, c(list(id = "landing_module_shiny_id"), landing_popup[[1]]$server_args)) + } # copy object so that load won't be shared between the session data <- data$copy(deep = TRUE) filter <- deep_copy_filter(filter) From a0e2ce24cf892bbbcb6f6f5c6c126820c98d6c64 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:37:42 +0200 Subject: [PATCH 17/84] 812 landing popup mod@812 landing popup@main (#936) some suggestions --------- Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> Co-authored-by: m7pr Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/init.R | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/R/init.R b/R/init.R index c6587f0c8e..8f609737ea 100644 --- a/R/init.R +++ b/R/init.R @@ -138,6 +138,32 @@ init <- function(data, modules <- do.call(teal::modules, modules) } + # move these two functions to utils.R or modules.R + # maybe combine into one function? + extract_landing <- function(modules) { + if (inherits(modules, "landing_module")) { + modules + } else if (inherits(modules, "teal_module")) { + NULL + } else if (inherits(modules, "teal_modules")) { + Filter(function(x) length(x) > 0L, lapply(modules$children, extract_landing)) + } + } + drop_landing <- function(modules) { + if (inherits(modules, "landing_module")) { + NULL + } else if (inherits(modules, "teal_module")) { + modules + } else if (inherits(modules, "teal_modules")) { + do.call( + "modules", + c(Filter(function(x) length(x) > 0L, lapply(modules$children, drop_landing)), label = modules$label) + ) + } + } + landing <- extract_landing(modules) + modules <- drop_landing(modules) + # resolve modules datanames datanames <- teal.data::get_dataname(data) join_keys <- data$get_join_keys() @@ -218,20 +244,6 @@ init <- function(data, } } - # In case of a "Landing Popup", do not create a module for it. Just extract the module and use directly in server. - # Assuming "Landing Popup" is not used in a nested module. - labels <- module_labels(modules) - lp_cond <- "Landing_Popup" %in% names(labels) - - if (!lp_cond && "Landing Page" %in% unlist(labels)) { - stop("Please do not use a module labelled 'Landing Popup' within a nested module.") - } else if (lp_cond) { - landing_popup <- modules$children[which(lp_cond)] - modules$children <- modules$children[-which(lp_cond)] - } else { - landing_popup <- NULL - } - # Note regarding case `id = character(0)`: # rather than using `callModule` and creating a submodule of this module, we directly modify # the `ui` and `server` with `id = character(0)` and calling the server function directly @@ -239,8 +251,9 @@ init <- function(data, res <- list( ui = ui_teal_with_splash(id = id, data = data, title = title, header = header, footer = footer), server = function(input, output, session) { - if (length(landing_popup) > 0L) { - do.call(landing_popup[[1]]$server, c(list(id = "landing_module_shiny_id"), landing_popup[[1]]$server_args)) + if (length(landing) > 0L) { + landing_module <- landing[[1L]] + do.call(landing_module$server, c(list(id = "landing_module_shiny_id"), landing_module$server_args)) } # copy object so that load won't be shared between the session data <- data$copy(deep = TRUE) From 5b3467816f781a7747face41cc01140a88487e5c Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 23 Oct 2023 12:41:39 +0200 Subject: [PATCH 18/84] move extract_landing and drop_landing into modules.R --- R/init.R | 23 ----------------------- R/modules.R | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/R/init.R b/R/init.R index 8f609737ea..030d4f3742 100644 --- a/R/init.R +++ b/R/init.R @@ -138,29 +138,6 @@ init <- function(data, modules <- do.call(teal::modules, modules) } - # move these two functions to utils.R or modules.R - # maybe combine into one function? - extract_landing <- function(modules) { - if (inherits(modules, "landing_module")) { - modules - } else if (inherits(modules, "teal_module")) { - NULL - } else if (inherits(modules, "teal_modules")) { - Filter(function(x) length(x) > 0L, lapply(modules$children, extract_landing)) - } - } - drop_landing <- function(modules) { - if (inherits(modules, "landing_module")) { - NULL - } else if (inherits(modules, "teal_module")) { - modules - } else if (inherits(modules, "teal_modules")) { - do.call( - "modules", - c(Filter(function(x) length(x) > 0L, lapply(modules$children, drop_landing)), label = modules$label) - ) - } - } landing <- extract_landing(modules) modules <- drop_landing(modules) diff --git a/R/modules.R b/R/modules.R index 2cc426b7fe..7bf6412379 100644 --- a/R/modules.R +++ b/R/modules.R @@ -103,6 +103,36 @@ append_module <- function(modules, module) { modules } +#' Extract a `landing_module` from list of `modules` +#' @param modules `teal_modules` +#' @keywords internal +#' @return `landing_module` +extract_landing <- function(modules) { + if (inherits(modules, "landing_module")) { + modules + } else if (inherits(modules, "teal_module")) { + NULL + } else if (inherits(modules, "teal_modules")) { + Filter(function(x) length(x) > 0L, lapply(modules$children, extract_landing)) + } +} +#' Remove a `landing_module` from list of `modules` +#' @param modules `teal_modules` +#' @keywords internal +#' @return `teal_modules` +drop_landing <- function(modules) { + if (inherits(modules, "landing_module")) { + NULL + } else if (inherits(modules, "teal_module")) { + modules + } else if (inherits(modules, "teal_modules")) { + do.call( + "modules", + c(Filter(function(x) length(x) > 0L, lapply(modules$children, drop_landing)), label = modules$label) + ) + } +} + #' Does the object make use of the `arg` #' #' @param modules (`teal_module` or `teal_modules`) object From 54482060f14f682668b3b2229d48a57dd5bc43bd Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 10:46:13 +0000 Subject: [PATCH 19/84] [skip actions] Roxygen Man Pages Auto Update --- man/drop_landing.Rd | 18 ++++++++++++++++++ man/extract_landing.Rd | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 man/drop_landing.Rd create mode 100644 man/extract_landing.Rd diff --git a/man/drop_landing.Rd b/man/drop_landing.Rd new file mode 100644 index 0000000000..a38d91c6c4 --- /dev/null +++ b/man/drop_landing.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/modules.R +\name{drop_landing} +\alias{drop_landing} +\title{Remove a \code{landing_module} from list of \code{modules}} +\usage{ +drop_landing(modules) +} +\arguments{ +\item{modules}{\code{teal_modules}} +} +\value{ +\code{teal_modules} +} +\description{ +Remove a \code{landing_module} from list of \code{modules} +} +\keyword{internal} diff --git a/man/extract_landing.Rd b/man/extract_landing.Rd new file mode 100644 index 0000000000..0e1bbee714 --- /dev/null +++ b/man/extract_landing.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/modules.R +\name{extract_landing} +\alias{extract_landing} +\title{Extract a \code{landing_module} from list of \code{modules}} +\usage{ +extract_landing(modules) +} +\arguments{ +\item{modules}{\code{teal_modules}} +} +\value{ +\code{landing_module} +} +\description{ +Extract a \code{landing_module} from list of \code{modules} +} +\keyword{internal} From ec595bc551f553e2924beaf742593b507def53c9 Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 23 Oct 2023 12:52:30 +0200 Subject: [PATCH 20/84] extend module - change `landing_module` class to `teal_module_landing` - specify new parameter type where you can specify one of 3 classes for final module --- NEWS.md | 2 ++ R/init.R | 1 + R/modules.R | 19 ++++++++++++------- man/drop_landing.Rd | 18 ++++++++++++++++++ man/extract_landing.Rd | 18 ++++++++++++++++++ 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 man/drop_landing.Rd create mode 100644 man/extract_landing.Rd diff --git a/NEWS.md b/NEWS.md index 645ed4a170..f4f18f9deb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,8 @@ * Added internal functions for storing and restoring of `teal_slices` objects. * Filter state snapshots can now be uploaded from file. See `?snapshot`. * Added argument to `teal_slices` and made modifications to `init` to enable tagging `teal_slices` with an app id to safely upload snapshots from disk. +* Modules created with `module()` function are divided into specific classes: `"teal_module"`, `"teal_module_reporter"` +and `"teal_module_landing"`. Modules of class `"teal_module_landing"` will not be wrapped into tabs in the `teal` apps. # teal 0.14.0 diff --git a/R/init.R b/R/init.R index 030d4f3742..c9f7b0dbc9 100644 --- a/R/init.R +++ b/R/init.R @@ -139,6 +139,7 @@ init <- function(data, } landing <- extract_landing(modules) + if (length(landing) > 1L) stop("teal only supports apps with one module of `tm_landing_poup` class.") modules <- drop_landing(modules) # resolve modules datanames diff --git a/R/modules.R b/R/modules.R index 7bf6412379..6d03488aaa 100644 --- a/R/modules.R +++ b/R/modules.R @@ -103,12 +103,12 @@ append_module <- function(modules, module) { modules } -#' Extract a `landing_module` from list of `modules` +#' Extract a `teal_module_landing` from list of `modules` #' @param modules `teal_modules` #' @keywords internal -#' @return `landing_module` +#' @return `teal_module_landing` extract_landing <- function(modules) { - if (inherits(modules, "landing_module")) { + if (inherits(modules, "teal_module_landing")) { modules } else if (inherits(modules, "teal_module")) { NULL @@ -116,12 +116,12 @@ extract_landing <- function(modules) { Filter(function(x) length(x) > 0L, lapply(modules$children, extract_landing)) } } -#' Remove a `landing_module` from list of `modules` +#' Remove a `teal_module_landing` from list of `modules` #' @param modules `teal_modules` #' @keywords internal #' @return `teal_modules` drop_landing <- function(modules) { - if (inherits(modules, "landing_module")) { + if (inherits(modules, "teal_module_landing")) { NULL } else if (inherits(modules, "teal_module")) { modules @@ -185,6 +185,9 @@ is_arg_used <- function(modules, arg) { #' `server` function. #' @param ui_args (named `list`) with additional arguments passed on to the #' `ui` function. +#' @param type (`character(1)`) The type of the class assigned to the final module. One of `"teal_module"`, +#' `"teal_module_reporter"` or `"teal_module_landing"`. Modules of class `"teal_module_landing"` will not be wrapped +#' into tabs in the `teal` application. #' #' @return object of class `teal_module`. #' @export @@ -224,13 +227,15 @@ module <- function(label = "module", filters, datanames = "all", server_args = NULL, - ui_args = NULL) { + ui_args = NULL, + type = c("teal_module", "teal_module_reporter", "teal_module_landing")) { checkmate::assert_string(label) checkmate::assert_function(server) checkmate::assert_function(ui) checkmate::assert_character(datanames, min.len = 1, null.ok = TRUE, any.missing = FALSE) checkmate::assert_list(server_args, null.ok = TRUE, names = "named") checkmate::assert_list(ui_args, null.ok = TRUE, names = "named") + type <- match.arg(type) if (!missing(filters)) { checkmate::assert_character(filters, min.len = 1, null.ok = TRUE, any.missing = FALSE) @@ -314,7 +319,7 @@ module <- function(label = "module", server = server, ui = ui, datanames = datanames, server_args = server_args, ui_args = ui_args ), - class = "teal_module" + class = type ) } diff --git a/man/drop_landing.Rd b/man/drop_landing.Rd new file mode 100644 index 0000000000..a38d91c6c4 --- /dev/null +++ b/man/drop_landing.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/modules.R +\name{drop_landing} +\alias{drop_landing} +\title{Remove a \code{landing_module} from list of \code{modules}} +\usage{ +drop_landing(modules) +} +\arguments{ +\item{modules}{\code{teal_modules}} +} +\value{ +\code{teal_modules} +} +\description{ +Remove a \code{landing_module} from list of \code{modules} +} +\keyword{internal} diff --git a/man/extract_landing.Rd b/man/extract_landing.Rd new file mode 100644 index 0000000000..0e1bbee714 --- /dev/null +++ b/man/extract_landing.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/modules.R +\name{extract_landing} +\alias{extract_landing} +\title{Extract a \code{landing_module} from list of \code{modules}} +\usage{ +extract_landing(modules) +} +\arguments{ +\item{modules}{\code{teal_modules}} +} +\value{ +\code{landing_module} +} +\description{ +Extract a \code{landing_module} from list of \code{modules} +} +\keyword{internal} From b03ddc109068c936e889acae2b8abb4d0c5cdee6 Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 23 Oct 2023 12:52:53 +0200 Subject: [PATCH 21/84] rebuild manual pages --- man/drop_landing.Rd | 4 ++-- man/extract_landing.Rd | 6 +++--- man/module.Rd | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/man/drop_landing.Rd b/man/drop_landing.Rd index a38d91c6c4..7e46431fe5 100644 --- a/man/drop_landing.Rd +++ b/man/drop_landing.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/modules.R \name{drop_landing} \alias{drop_landing} -\title{Remove a \code{landing_module} from list of \code{modules}} +\title{Remove a \code{teal_module_landing} from list of \code{modules}} \usage{ drop_landing(modules) } @@ -13,6 +13,6 @@ drop_landing(modules) \code{teal_modules} } \description{ -Remove a \code{landing_module} from list of \code{modules} +Remove a \code{teal_module_landing} from list of \code{modules} } \keyword{internal} diff --git a/man/extract_landing.Rd b/man/extract_landing.Rd index 0e1bbee714..71a78ede66 100644 --- a/man/extract_landing.Rd +++ b/man/extract_landing.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/modules.R \name{extract_landing} \alias{extract_landing} -\title{Extract a \code{landing_module} from list of \code{modules}} +\title{Extract a \code{teal_module_landing} from list of \code{modules}} \usage{ extract_landing(modules) } @@ -10,9 +10,9 @@ extract_landing(modules) \item{modules}{\code{teal_modules}} } \value{ -\code{landing_module} +\code{teal_module_landing} } \description{ -Extract a \code{landing_module} from list of \code{modules} +Extract a \code{teal_module_landing} from list of \code{modules} } \keyword{internal} diff --git a/man/module.Rd b/man/module.Rd index d7267630cd..5e037668b0 100644 --- a/man/module.Rd +++ b/man/module.Rd @@ -20,7 +20,8 @@ module( filters, datanames = "all", server_args = NULL, - ui_args = NULL + ui_args = NULL, + type = c("teal_module", "teal_module_reporter", "teal_module_landing") ) \method{toString}{teal_module}(x, indent = 0, ...) @@ -64,6 +65,10 @@ a subset of datasets which are appended to the \code{data} argument in \code{ser \item{ui_args}{(named \code{list}) with additional arguments passed on to the \code{ui} function.} +\item{type}{(\code{character(1)}) The type of the class assigned to the final module. One of \code{"teal_module"}, +\code{"teal_module_reporter"} or \code{"teal_module_landing"}. Modules of class \code{"teal_module_landing"} will not be wrapped +into tabs in the \code{teal} application.} + \item{x}{\code{teal_module}} \item{indent}{(\code{integer}) indent level; From bdc373b4bf78d1bd41db0f9545ac104ae96b4559 Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 23 Oct 2023 12:54:12 +0200 Subject: [PATCH 22/84] Empty-Commit From 464c42c5fc8d1590aafad28e8586b7dbe9e1de4f Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 23 Oct 2023 13:17:09 +0200 Subject: [PATCH 23/84] extend assertion of class of elements passed to modules() --- R/modules.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index 6d03488aaa..3064937c26 100644 --- a/R/modules.R +++ b/R/modules.R @@ -75,7 +75,7 @@ modules <- function(..., label = "root") { ) } - checkmate::assert_list(submodules, min.len = 1, any.missing = FALSE, types = c("teal_module", "teal_modules")) + checkmate::assert_list(submodules, min.len = 1, any.missing = FALSE, types = c("teal_module", "teal_module_reporter", "teal_module_landing", "teal_modules")) # name them so we can more easily access the children # beware however that the label of the submodules should not be changed as it must be kept synced labels <- vapply(submodules, function(submodule) submodule$label, character(1)) From 11955bc32d7b9271ef3b0fd47166037be09cca7d Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 23 Oct 2023 13:45:04 +0200 Subject: [PATCH 24/84] update teal init note --- R/init.R | 3 ++- man/init.Rd | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/init.R b/R/init.R index c9f7b0dbc9..af1bb3d25f 100644 --- a/R/init.R +++ b/R/init.R @@ -46,7 +46,8 @@ #' See the vignette for an example. However, [ui_teal_with_splash()] #' is then preferred to this function. #' -#' @note If you use a module labelled `"Landing Popup"` `teal` will not create a tab for this module. +#' @note If you pass a module of class `"teal_module_landing"` in `modules` parameter, `teal` will not create a tab for +#' this module. #' #' @return named list with `server` and `ui` function #' diff --git a/man/init.Rd b/man/init.Rd index a60f6c1735..a1bfc9e9e6 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -66,7 +66,8 @@ This is a wrapper function around the \code{module_teal.R} functions. Unless you an end-user, don't use this function, but instead this module. } \note{ -If you use a module labelled \code{"Landing Popup"} \code{teal} will not create a tab for this module. +If you pass a module of class \code{"teal_module_landing"} in \code{modules} parameter, \code{teal} will not create a tab for +this module. } \examples{ new_iris <- transform(iris, id = seq_len(nrow(iris))) From 881d88ff42e285947d147d3dbc38dfc9e13e6549 Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 23 Oct 2023 13:47:34 +0200 Subject: [PATCH 25/84] typo --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index af1bb3d25f..d019994f86 100644 --- a/R/init.R +++ b/R/init.R @@ -140,7 +140,7 @@ init <- function(data, } landing <- extract_landing(modules) - if (length(landing) > 1L) stop("teal only supports apps with one module of `tm_landing_poup` class.") + if (length(landing) > 1L) stop("teal only supports apps with one module of `tm_landing_popup` class.") modules <- drop_landing(modules) # resolve modules datanames From 69d5c714cd18f48f87eb22108a0a2c8ad3691236 Mon Sep 17 00:00:00 2001 From: m7pr Date: Mon, 23 Oct 2023 14:04:59 +0200 Subject: [PATCH 26/84] change extract/drop_landing into extract/drop_module with class argument --- R/init.R | 4 ++-- R/module_teal.R | 11 +---------- R/modules.R | 15 ++++++++------- man/{drop_landing.Rd => drop_module.Rd} | 10 +++++----- man/{extract_landing.Rd => extract_module.Rd} | 10 +++++----- 5 files changed, 21 insertions(+), 29 deletions(-) rename man/{drop_landing.Rd => drop_module.Rd} (51%) rename man/{extract_landing.Rd => extract_module.Rd} (51%) diff --git a/R/init.R b/R/init.R index d019994f86..cc71084d4c 100644 --- a/R/init.R +++ b/R/init.R @@ -139,9 +139,9 @@ init <- function(data, modules <- do.call(teal::modules, modules) } - landing <- extract_landing(modules) + landing <- extract_module(modules, "teal_module_landing") if (length(landing) > 1L) stop("teal only supports apps with one module of `tm_landing_popup` class.") - modules <- drop_landing(modules) + modules <- drop_module(modules, "teal_module_landing") # resolve modules datanames datanames <- teal.data::get_dataname(data) diff --git a/R/module_teal.R b/R/module_teal.R index fbce6ed5bd..5f068b483b 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -226,16 +226,7 @@ srv_teal <- function(id, modules, raw_data, filter = teal_slices()) { }) reporter <- teal.reporter::Reporter$new() - is_any_previewer <- function(modules) { - if (inherits(modules, "teal_modules")) { - any(unlist(lapply(modules$children, is_any_previewer), use.names = FALSE)) - } else if (inherits(modules, "teal_module_previewer")) { - TRUE - } else { - FALSE - } - } - if (is_arg_used(modules, "reporter") && !is_any_previewer(modules)) { + if (is_arg_used(modules, "reporter") && length(extract_module(modules, 'teal_module_previewer')) == 0) { modules <- append_module(modules, reporter_previewer_module()) } diff --git a/R/modules.R b/R/modules.R index 3064937c26..4b9e9edeea 100644 --- a/R/modules.R +++ b/R/modules.R @@ -103,25 +103,26 @@ append_module <- function(modules, module) { modules } -#' Extract a `teal_module_landing` from list of `modules` +#' Extract specific class from a list of `modules` #' @param modules `teal_modules` #' @keywords internal #' @return `teal_module_landing` -extract_landing <- function(modules) { - if (inherits(modules, "teal_module_landing")) { +extract_module <- function(modules, class) { + if (inherits(modules, class)) { modules } else if (inherits(modules, "teal_module")) { NULL } else if (inherits(modules, "teal_modules")) { - Filter(function(x) length(x) > 0L, lapply(modules$children, extract_landing)) + Filter(function(x) length(x) > 0L, lapply(modules$children, extract_module)) } } -#' Remove a `teal_module_landing` from list of `modules` + +#' Remove a specific class from list of `modules` #' @param modules `teal_modules` #' @keywords internal #' @return `teal_modules` -drop_landing <- function(modules) { - if (inherits(modules, "teal_module_landing")) { +drop_module <- function(modules, class) { + if (inherits(modules, class)) { NULL } else if (inherits(modules, "teal_module")) { modules diff --git a/man/drop_landing.Rd b/man/drop_module.Rd similarity index 51% rename from man/drop_landing.Rd rename to man/drop_module.Rd index 7e46431fe5..d29d808c4d 100644 --- a/man/drop_landing.Rd +++ b/man/drop_module.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/modules.R -\name{drop_landing} -\alias{drop_landing} -\title{Remove a \code{teal_module_landing} from list of \code{modules}} +\name{drop_module} +\alias{drop_module} +\title{Remove a specific class from list of \code{modules}} \usage{ -drop_landing(modules) +drop_module(modules, class) } \arguments{ \item{modules}{\code{teal_modules}} @@ -13,6 +13,6 @@ drop_landing(modules) \code{teal_modules} } \description{ -Remove a \code{teal_module_landing} from list of \code{modules} +Remove a specific class from list of \code{modules} } \keyword{internal} diff --git a/man/extract_landing.Rd b/man/extract_module.Rd similarity index 51% rename from man/extract_landing.Rd rename to man/extract_module.Rd index 71a78ede66..5c6213a038 100644 --- a/man/extract_landing.Rd +++ b/man/extract_module.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/modules.R -\name{extract_landing} -\alias{extract_landing} -\title{Extract a \code{teal_module_landing} from list of \code{modules}} +\name{extract_module} +\alias{extract_module} +\title{Extract specific class from a list of \code{modules}} \usage{ -extract_landing(modules) +extract_module(modules, class) } \arguments{ \item{modules}{\code{teal_modules}} @@ -13,6 +13,6 @@ extract_landing(modules) \code{teal_module_landing} } \description{ -Extract a \code{teal_module_landing} from list of \code{modules} +Extract specific class from a list of \code{modules} } \keyword{internal} From 3604eb02796332f2b959272a2998561785c0dc4f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:07:38 +0000 Subject: [PATCH 27/84] [skip actions] Restyle files --- R/module_teal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/module_teal.R b/R/module_teal.R index 5f068b483b..e5d3b399e4 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -226,7 +226,7 @@ srv_teal <- function(id, modules, raw_data, filter = teal_slices()) { }) reporter <- teal.reporter::Reporter$new() - if (is_arg_used(modules, "reporter") && length(extract_module(modules, 'teal_module_previewer')) == 0) { + if (is_arg_used(modules, "reporter") && length(extract_module(modules, "teal_module_previewer")) == 0) { modules <- append_module(modules, reporter_previewer_module()) } From daa14c609a2dc5c1de2546c914b09de6f8b7e3e3 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:33:43 +0200 Subject: [PATCH 28/84] Update R/init.R Co-authored-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index cc71084d4c..228c1d245d 100644 --- a/R/init.R +++ b/R/init.R @@ -140,7 +140,7 @@ init <- function(data, } landing <- extract_module(modules, "teal_module_landing") - if (length(landing) > 1L) stop("teal only supports apps with one module of `tm_landing_popup` class.") + if (length(landing) > 1L) stop("teal only supports apps with one module of `teal_module_landing` class.") modules <- drop_module(modules, "teal_module_landing") # resolve modules datanames From cce8655cf85ac5f7a608a901fff76c5428c6495b Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:07:35 +0200 Subject: [PATCH 29/84] Update R/init.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index 228c1d245d..c097f7318a 100644 --- a/R/init.R +++ b/R/init.R @@ -140,7 +140,7 @@ init <- function(data, } landing <- extract_module(modules, "teal_module_landing") - if (length(landing) > 1L) stop("teal only supports apps with one module of `teal_module_landing` class.") + if (length(landing) > 1L) stop("only one `teal_module_landing` can be used") modules <- drop_module(modules, "teal_module_landing") # resolve modules datanames From ed6bafccb4ba55d0d0291c6847b54a8a3752701c Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:08:18 +0200 Subject: [PATCH 30/84] Update NEWS.md Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- NEWS.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index f4f18f9deb..ebd44803db 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,8 +7,7 @@ * Added internal functions for storing and restoring of `teal_slices` objects. * Filter state snapshots can now be uploaded from file. See `?snapshot`. * Added argument to `teal_slices` and made modifications to `init` to enable tagging `teal_slices` with an app id to safely upload snapshots from disk. -* Modules created with `module()` function are divided into specific classes: `"teal_module"`, `"teal_module_reporter"` -and `"teal_module_landing"`. Modules of class `"teal_module_landing"` will not be wrapped into tabs in the `teal` apps. +* `module` can now create modules of different classes that will be handled differently by `init`. The default class is still `"teal_module"` so no changes to existing templates are necessary. Currently handled classes are `"teal_module_landing"`, which will not be presented in tabs, and `"teal_module_reporter"`. # teal 0.14.0 From 98b2e0a7deba2b04030dd637516630fcadae168f Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:09:04 +0200 Subject: [PATCH 31/84] Update R/modules.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/modules.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index 4b9e9edeea..2924760a8b 100644 --- a/R/modules.R +++ b/R/modules.R @@ -103,7 +103,10 @@ append_module <- function(modules, module) { modules } -#' Extract specific class from a list of `modules` +#' Extract module(s) of specific class. +#' +#' Given a `teal_module` or a `teal_modules`, return the elements of the structure according to `class`. +#' #' @param modules `teal_modules` #' @keywords internal #' @return `teal_module_landing` From a629e3cf90770dd6c778916f40f9def188e367ee Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:09:19 +0200 Subject: [PATCH 32/84] Update R/modules.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/modules.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index 2924760a8b..8f400ee655 100644 --- a/R/modules.R +++ b/R/modules.R @@ -107,7 +107,7 @@ append_module <- function(modules, module) { #' #' Given a `teal_module` or a `teal_modules`, return the elements of the structure according to `class`. #' -#' @param modules `teal_modules` +#' @param modules `teal_modules` or `teal_module`, whatever is passed to `init`'s `modules` argument #' @keywords internal #' @return `teal_module_landing` extract_module <- function(modules, class) { From f0bbf5218552a86a6304fd16e87a036ab6c7cc5e Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:09:28 +0200 Subject: [PATCH 33/84] Update R/modules.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/modules.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index 8f400ee655..6b32da879e 100644 --- a/R/modules.R +++ b/R/modules.R @@ -109,7 +109,7 @@ append_module <- function(modules, module) { #' #' @param modules `teal_modules` or `teal_module`, whatever is passed to `init`'s `modules` argument #' @keywords internal -#' @return `teal_module_landing` +#' @return `teal_module` of class `class` or `teal_modules` containing modules of class `class`. extract_module <- function(modules, class) { if (inherits(modules, class)) { modules From 1e1fa37f6c5ac58246d9323e3283009e58832474 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 08:11:56 +0000 Subject: [PATCH 34/84] [skip actions] Restyle files --- R/modules.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index 6b32da879e..2caf2af93a 100644 --- a/R/modules.R +++ b/R/modules.R @@ -104,7 +104,7 @@ append_module <- function(modules, module) { } #' Extract module(s) of specific class. -#' +#' #' Given a `teal_module` or a `teal_modules`, return the elements of the structure according to `class`. #' #' @param modules `teal_modules` or `teal_module`, whatever is passed to `init`'s `modules` argument From f26ee16f0020976c2851f6c7d389b6cdba0a6f61 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:36:20 +0200 Subject: [PATCH 35/84] Update R/modules.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/modules.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/modules.R b/R/modules.R index 2caf2af93a..06237097bd 100644 --- a/R/modules.R +++ b/R/modules.R @@ -189,9 +189,9 @@ is_arg_used <- function(modules, arg) { #' `server` function. #' @param ui_args (named `list`) with additional arguments passed on to the #' `ui` function. -#' @param type (`character(1)`) The type of the class assigned to the final module. One of `"teal_module"`, -#' `"teal_module_reporter"` or `"teal_module_landing"`. Modules of class `"teal_module_landing"` will not be wrapped -#' into tabs in the `teal` application. +#' @param type (`character(1)`) Class assigned to the resulting module. +#' All modules will have class `teal_module` (default) but one other class may be added. +#' Modules of class `"teal_module_landing"` will not be wrapped into tabs in the `teal` application. #' #' @return object of class `teal_module`. #' @export From c47552e35154db23259fdea90a5d9b282bc455fe Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 10:38:25 +0200 Subject: [PATCH 36/84] change the condition on the lenght of the landing --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index c097f7318a..70c0564596 100644 --- a/R/init.R +++ b/R/init.R @@ -230,7 +230,7 @@ init <- function(data, res <- list( ui = ui_teal_with_splash(id = id, data = data, title = title, header = header, footer = footer), server = function(input, output, session) { - if (length(landing) > 0L) { + if (length(landing) == 1L) { landing_module <- landing[[1L]] do.call(landing_module$server, c(list(id = "landing_module_shiny_id"), landing_module$server_args)) } From 93eee85cf3a4da8a462d64a7e4cc7a3ce395be4f Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:41:29 +0200 Subject: [PATCH 37/84] Update R/modules.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/modules.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index 06237097bd..42ed83ffa3 100644 --- a/R/modules.R +++ b/R/modules.R @@ -323,7 +323,7 @@ module <- function(label = "module", server = server, ui = ui, datanames = datanames, server_args = server_args, ui_args = ui_args ), - class = type + class = union(type, "teal_module") ) } From 0fa96e691d8d6297de842dc1c2ac7c6f92b67741 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 10:42:28 +0200 Subject: [PATCH 38/84] rebuild documentation --- man/extract_module.Rd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/man/extract_module.Rd b/man/extract_module.Rd index 5c6213a038..1bfaddc2ff 100644 --- a/man/extract_module.Rd +++ b/man/extract_module.Rd @@ -2,17 +2,17 @@ % Please edit documentation in R/modules.R \name{extract_module} \alias{extract_module} -\title{Extract specific class from a list of \code{modules}} +\title{Extract module(s) of specific class.} \usage{ extract_module(modules, class) } \arguments{ -\item{modules}{\code{teal_modules}} +\item{modules}{\code{teal_modules} or \code{teal_module}, whatever is passed to \code{init}'s \code{modules} argument} } \value{ -\code{teal_module_landing} +\code{teal_module} of class \code{class} or \code{teal_modules} containing modules of class \code{class}. } \description{ -Extract specific class from a list of \code{modules} +Given a \code{teal_module} or a \code{teal_modules}, return the elements of the structure according to \code{class}. } \keyword{internal} From 4d54613040913c480a23eb1b1eddb41387cf3eda Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 08:45:47 +0000 Subject: [PATCH 39/84] [skip actions] Restyle files --- R/modules.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/modules.R b/R/modules.R index 42ed83ffa3..adfbc65750 100644 --- a/R/modules.R +++ b/R/modules.R @@ -189,8 +189,8 @@ is_arg_used <- function(modules, arg) { #' `server` function. #' @param ui_args (named `list`) with additional arguments passed on to the #' `ui` function. -#' @param type (`character(1)`) Class assigned to the resulting module. -#' All modules will have class `teal_module` (default) but one other class may be added. +#' @param type (`character(1)`) Class assigned to the resulting module. +#' All modules will have class `teal_module` (default) but one other class may be added. #' Modules of class `"teal_module_landing"` will not be wrapped into tabs in the `teal` application. #' #' @return object of class `teal_module`. From affd16fe97f2160c446f1ca623cd3f167c225173 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 10:57:28 +0200 Subject: [PATCH 40/84] fix drop/extract_module --- R/modules.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/modules.R b/R/modules.R index 42ed83ffa3..e6a67aa0ab 100644 --- a/R/modules.R +++ b/R/modules.R @@ -116,7 +116,7 @@ extract_module <- function(modules, class) { } else if (inherits(modules, "teal_module")) { NULL } else if (inherits(modules, "teal_modules")) { - Filter(function(x) length(x) > 0L, lapply(modules$children, extract_module)) + Filter(function(x) length(x) > 0L, lapply(modules$children, extract_module, class)) } } @@ -132,7 +132,7 @@ drop_module <- function(modules, class) { } else if (inherits(modules, "teal_modules")) { do.call( "modules", - c(Filter(function(x) length(x) > 0L, lapply(modules$children, drop_landing)), label = modules$label) + c(Filter(function(x) length(x) > 0L, lapply(modules$children, drop_module, class)), label = modules$label) ) } } @@ -189,8 +189,8 @@ is_arg_used <- function(modules, arg) { #' `server` function. #' @param ui_args (named `list`) with additional arguments passed on to the #' `ui` function. -#' @param type (`character(1)`) Class assigned to the resulting module. -#' All modules will have class `teal_module` (default) but one other class may be added. +#' @param type (`character(1)`) Class assigned to the resulting module. +#' All modules will have class `teal_module` (default) but one other class may be added. #' Modules of class `"teal_module_landing"` will not be wrapped into tabs in the `teal` application. #' #' @return object of class `teal_module`. From 7743f6e32ab4b27bc6afde9bb6fca55a2bc7ec58 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 09:02:18 +0000 Subject: [PATCH 41/84] [skip actions] Roxygen Man Pages Auto Update --- man/module.Rd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/module.Rd b/man/module.Rd index 5e037668b0..8c8d8add9b 100644 --- a/man/module.Rd +++ b/man/module.Rd @@ -65,9 +65,9 @@ a subset of datasets which are appended to the \code{data} argument in \code{ser \item{ui_args}{(named \code{list}) with additional arguments passed on to the \code{ui} function.} -\item{type}{(\code{character(1)}) The type of the class assigned to the final module. One of \code{"teal_module"}, -\code{"teal_module_reporter"} or \code{"teal_module_landing"}. Modules of class \code{"teal_module_landing"} will not be wrapped -into tabs in the \code{teal} application.} +\item{type}{(\code{character(1)}) Class assigned to the resulting module. +All modules will have class \code{teal_module} (default) but one other class may be added. +Modules of class \code{"teal_module_landing"} will not be wrapped into tabs in the \code{teal} application.} \item{x}{\code{teal_module}} From 530d1f50f1e40bfecab36e1d145c8a6e8d909b27 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 11:52:26 +0200 Subject: [PATCH 42/84] add dots at the end of sentences --- R/reporter_previewer_module.R | 6 ++++-- man/reporter_previewer_module.Rd | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/R/reporter_previewer_module.R b/R/reporter_previewer_module.R index 12dac5791c..c3e1e3f671 100644 --- a/R/reporter_previewer_module.R +++ b/R/reporter_previewer_module.R @@ -7,12 +7,13 @@ #' #' If you are creating a `teal` application using [teal::init()] then this #' module will be added to your application automatically if any of your `teal modules` -#' support report generation +#' support report generation. #' #' @inheritParams module #' @param server_args (`named list`)\cr #' Arguments passed to [teal.reporter::reporter_previewer_srv()]. -#' @return `teal_module` containing the `teal.reporter` previewer functionality +#' @return `teal_module` (extended with `teal_module_previewer` class) containing the `teal.reporter` previewer +#' functionality. #' @export reporter_previewer_module <- function(label = "Report previewer", server_args = list()) { checkmate::assert_string(label) @@ -32,6 +33,7 @@ reporter_previewer_module <- function(label = "Report previewer", server_args = server = srv, ui = ui, server_args = server_args, ui_args = list(), datanames = NULL ) + # Label 'Report previewer' is reserved in teal. class(module) <- c("teal_module_previewer", class(module)) module$label <- label module diff --git a/man/reporter_previewer_module.Rd b/man/reporter_previewer_module.Rd index 063bc518a5..937a3ec9dc 100644 --- a/man/reporter_previewer_module.Rd +++ b/man/reporter_previewer_module.Rd @@ -14,7 +14,8 @@ reporter_previewer_module(label = "Report previewer", server_args = list()) Arguments passed to \code{\link[teal.reporter:reporter_previewer_srv]{teal.reporter::reporter_previewer_srv()}}.} } \value{ -\code{teal_module} containing the \code{teal.reporter} previewer functionality +\code{teal_module} (extended with \code{teal_module_previewer} class) containing the \code{teal.reporter} previewer +functionality. } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} @@ -24,5 +25,5 @@ used in \code{teal} applications. If you are creating a \code{teal} application using \code{\link[=init]{init()}} then this module will be added to your application automatically if any of your \verb{teal modules} -support report generation +support report generation. } From 26c82f6a25c5bb58710fb694a912704f2f1c702e Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 11:52:35 +0200 Subject: [PATCH 43/84] remove type from modules --- R/modules.R | 5 ++--- man/module.Rd | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/R/modules.R b/R/modules.R index e6a67aa0ab..a78171ae8d 100644 --- a/R/modules.R +++ b/R/modules.R @@ -231,8 +231,7 @@ module <- function(label = "module", filters, datanames = "all", server_args = NULL, - ui_args = NULL, - type = c("teal_module", "teal_module_reporter", "teal_module_landing")) { + ui_args = NULL) { checkmate::assert_string(label) checkmate::assert_function(server) checkmate::assert_function(ui) @@ -323,7 +322,7 @@ module <- function(label = "module", server = server, ui = ui, datanames = datanames, server_args = server_args, ui_args = ui_args ), - class = union(type, "teal_module") + class = "teal_module" ) } diff --git a/man/module.Rd b/man/module.Rd index 5e037668b0..c3ae5b00c7 100644 --- a/man/module.Rd +++ b/man/module.Rd @@ -20,8 +20,7 @@ module( filters, datanames = "all", server_args = NULL, - ui_args = NULL, - type = c("teal_module", "teal_module_reporter", "teal_module_landing") + ui_args = NULL ) \method{toString}{teal_module}(x, indent = 0, ...) @@ -65,16 +64,16 @@ a subset of datasets which are appended to the \code{data} argument in \code{ser \item{ui_args}{(named \code{list}) with additional arguments passed on to the \code{ui} function.} -\item{type}{(\code{character(1)}) The type of the class assigned to the final module. One of \code{"teal_module"}, -\code{"teal_module_reporter"} or \code{"teal_module_landing"}. Modules of class \code{"teal_module_landing"} will not be wrapped -into tabs in the \code{teal} application.} - \item{x}{\code{teal_module}} \item{indent}{(\code{integer}) indent level; each \code{submodule} is indented one level more} \item{...}{parameters passed to \code{toString}} + +\item{type}{(\code{character(1)}) Class assigned to the resulting module. +All modules will have class \code{teal_module} (default) but one other class may be added. +Modules of class \code{"teal_module_landing"} will not be wrapped into tabs in the \code{teal} application.} } \value{ object of class \code{teal_module}. From ad0ad107c9ae5a31137c931920c16090a0b2e187 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 11:52:49 +0200 Subject: [PATCH 44/84] move tm_landing_popup from tmg to teal --- DESCRIPTION | 1 + NAMESPACE | 1 + R/tm_landing_popup.R | 80 +++++++++++++++++++++++++++++++++++++++++ _pkgdown.yml | 3 ++ man/tm_landing_popup.Rd | 65 +++++++++++++++++++++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 R/tm_landing_popup.R create mode 100644 man/tm_landing_popup.Rd diff --git a/DESCRIPTION b/DESCRIPTION index bfd00285b6..0e8564fcfc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -90,6 +90,7 @@ Collate: 'teal_reporter.R' 'teal_slices-store.R' 'teal_slices.R' + 'tm_landing_popup.R' 'utils.R' 'validate_inputs.R' 'validations.R' diff --git a/NAMESPACE b/NAMESPACE index fbf4258c0c..e4d39206ca 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -33,6 +33,7 @@ export(show_rcode_modal) export(srv_teal_with_splash) export(tdata2env) export(teal_slices) +export(tm_landing_popup) export(ui_teal_with_splash) export(validate_has_data) export(validate_has_elements) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R new file mode 100644 index 0000000000..47939c3138 --- /dev/null +++ b/R/tm_landing_popup.R @@ -0,0 +1,80 @@ +#' Landing Popup Module +#' +#' @description This module creates a landing welcome popup for `teal` applications. +#' +#' @details If you use this module in `teal::init(modules = )`, it will not be wrapped in a tab in `teal` application. +#' +#' @param label `character(1)` the label of the module. +#' @param title `character(1)` the text to be displayed as a title of the popup. +#' @param content `character(1)` the content of the popup. Passed to `...` of `shiny::modalDialog`. Can be a `character` +#' or a text input control (like `textInput`) or a list of `shiny` tags. See examples. +#' @param buttons `shiny` tag or a list of tags (`tagList`). Typically a `modalButton` or `actionButton`. See examples. +#' +#' @return A `teal_module` (extended with `teal_landing_module` class) to be used in `teal` applications. +#' +#' @examples +#' app1 <- teal::init( +#' data = teal.data::dataset("iris", iris), +#' modules = teal::modules( +#' teal::tm_landing_popup( +#' content = "A place for the welcome message or a disclaimer statement.", +#' buttons = modalButton("Proceed") +#' ) +#' ) +#' ) +#' if (interactive()) { +#' shinyApp(app1$ui, app1$server) +#' } +#' +#' app2 <- teal::init( +#' data = teal.data::dataset("iris", iris), +#' modules = teal::modules( +#' teal::tm_landing_popup( +#' title = "Welcome", +#' content = div(tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;")), +#' buttons = tagList( +#' modalButton("Proceed"), +#' actionButton("close", "Read more", onclick = "window.open('http://google.com', '_blank')") +#' ) +#' ) +#' ) +#' ) +#' +#' if (interactive()) { +#' shinyApp(app2$ui, app2$server) +#' } +#' +#' @export +tm_landing_popup <- + function(label = "Landing Popup", + title = NULL, + content = NULL, + buttons = modalButton("Accept")) { + checkmate::assert_string(label) + checkmate::assert_string(title, null.ok = TRUE) + checkmate::assert_multi_class( + content, + classes = c("character", "shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE + ) + checkmate::assert_multi_class(buttons, classes = c("shiny.tag", "shiny.tag.list")) + + logger::log_info("Initializing tm_landing_popup") + + module <- module( + label = label, + server = function(id) { + moduleServer(id, function(input, output, session) { + showModal( + modalDialog( + id = "landingpopup", + title = title, + content, + footer = buttons + ) + ) + }) + } + ) + class(module) <- c("teal_module_landing", class(module)) + module +} diff --git a/_pkgdown.yml b/_pkgdown.yml index 9525fbdd7a..892e6f6686 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -107,6 +107,9 @@ reference: - reporter_previewer_module - TealReportCard - report_card_template + - title: Landing Popup + contents: + - tm_landing_popup - title: Functions for Module Developers contents: - tdata diff --git a/man/tm_landing_popup.Rd b/man/tm_landing_popup.Rd new file mode 100644 index 0000000000..04bf3c0435 --- /dev/null +++ b/man/tm_landing_popup.Rd @@ -0,0 +1,65 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tm_landing_popup.R +\name{tm_landing_popup} +\alias{tm_landing_popup} +\title{Landing Popup Module} +\usage{ +tm_landing_popup( + label = "Landing Popup", + title = NULL, + content = NULL, + buttons = modalButton("Accept") +) +} +\arguments{ +\item{label}{\code{character(1)} the label of the module.} + +\item{title}{\code{character(1)} the text to be displayed as a title of the popup.} + +\item{content}{\code{character(1)} the content of the popup. Passed to \code{...} of \code{shiny::modalDialog}. Can be a \code{character} +or a text input control (like \code{textInput}) or a list of \code{shiny} tags. See examples.} + +\item{buttons}{\code{shiny} tag or a list of tags (\code{tagList}). Typically a \code{modalButton} or \code{actionButton}. See examples.} +} +\value{ +A \code{teal_module} (extended with \code{teal_landing_module} class) to be used in \code{teal} applications. +} +\description{ +This module creates a landing welcome popup for \code{teal} applications. +} +\details{ +If you use this module in \code{teal::init(modules = )}, it will not be wrapped in a tab in \code{teal} application. +} +\examples{ +app1 <- teal::init( + data = teal.data::dataset("iris", iris), + modules = teal::modules( + teal::tm_landing_popup( + content = "A place for the welcome message or a disclaimer statement.", + buttons = modalButton("Proceed") + ) + ) +) +if (interactive()) { + shinyApp(app1$ui, app1$server) +} + +app2 <- teal::init( + data = teal.data::dataset("iris", iris), + modules = teal::modules( + teal::tm_landing_popup( + title = "Welcome", + content = div(tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;")), + buttons = tagList( + modalButton("Proceed"), + actionButton("close", "Read more", onclick = "window.open('http://google.com', '_blank')") + ) + ) + ) +) + +if (interactive()) { + shinyApp(app2$ui, app2$server) +} + +} From 2b4ae971078155df361c8a71d70bb1f37e18a787 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 09:57:18 +0000 Subject: [PATCH 45/84] [skip actions] Restyle files --- R/tm_landing_popup.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R index 47939c3138..8224d1fdba 100644 --- a/R/tm_landing_popup.R +++ b/R/tm_landing_popup.R @@ -77,4 +77,4 @@ tm_landing_popup <- ) class(module) <- c("teal_module_landing", class(module)) module -} + } From c92e92500530d5620c25eafbef65c2d9aa9aa5b8 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 12:02:13 +0200 Subject: [PATCH 46/84] bind drop_module and extract_module in one documentation page --- R/modules.R | 14 ++++++++------ man/append_module.Rd | 4 ++-- man/drop_module.Rd | 18 ------------------ man/extract_module.Rd | 14 +++++++++++--- man/module.Rd | 2 +- 5 files changed, 22 insertions(+), 30 deletions(-) delete mode 100644 man/drop_module.Rd diff --git a/R/modules.R b/R/modules.R index a78171ae8d..fb35bad88a 100644 --- a/R/modules.R +++ b/R/modules.R @@ -89,7 +89,7 @@ modules <- function(..., label = "root") { ) } -#' Function which appends a teal_module onto the children of a teal_modules object +#' Function which appends a `teal_module` onto the children of a `teal_modules` object #' @keywords internal #' @param modules `teal_modules` #' @param module `teal_module` object to be appended onto the children of `modules` @@ -103,13 +103,16 @@ append_module <- function(modules, module) { modules } -#' Extract module(s) of specific class. +#' Extract/Remove module(s) of specific class #' #' Given a `teal_module` or a `teal_modules`, return the elements of the structure according to `class`. #' -#' @param modules `teal_modules` or `teal_module`, whatever is passed to `init`'s `modules` argument +#' @param modules `teal_modules` +#' @param class The class name of `teal_module` to be extracted or dropped. #' @keywords internal -#' @return `teal_module` of class `class` or `teal_modules` containing modules of class `class`. +#' @return For `extract_module`, a `teal_module` of class `class` or `teal_modules` containing modules of class `class`. +#' For `drop_module`, an opposite, which is all `teal_modules` besides the ones with `class` class. +#' @rdname extract_module extract_module <- function(modules, class) { if (inherits(modules, class)) { modules @@ -120,10 +123,9 @@ extract_module <- function(modules, class) { } } -#' Remove a specific class from list of `modules` -#' @param modules `teal_modules` #' @keywords internal #' @return `teal_modules` +#' @rdname extract_module drop_module <- function(modules, class) { if (inherits(modules, class)) { NULL diff --git a/man/append_module.Rd b/man/append_module.Rd index 3c3be16559..48656ac2fb 100644 --- a/man/append_module.Rd +++ b/man/append_module.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/modules.R \name{append_module} \alias{append_module} -\title{Function which appends a teal_module onto the children of a teal_modules object} +\title{Function which appends a \code{teal_module} onto the children of a \code{teal_modules} object} \usage{ append_module(modules, module) } @@ -15,6 +15,6 @@ append_module(modules, module) \code{teal_modules} object with \code{module} appended } \description{ -Function which appends a teal_module onto the children of a teal_modules object +Function which appends a \code{teal_module} onto the children of a \code{teal_modules} object } \keyword{internal} diff --git a/man/drop_module.Rd b/man/drop_module.Rd deleted file mode 100644 index d29d808c4d..0000000000 --- a/man/drop_module.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/modules.R -\name{drop_module} -\alias{drop_module} -\title{Remove a specific class from list of \code{modules}} -\usage{ -drop_module(modules, class) -} -\arguments{ -\item{modules}{\code{teal_modules}} -} -\value{ -\code{teal_modules} -} -\description{ -Remove a specific class from list of \code{modules} -} -\keyword{internal} diff --git a/man/extract_module.Rd b/man/extract_module.Rd index 1bfaddc2ff..4745631536 100644 --- a/man/extract_module.Rd +++ b/man/extract_module.Rd @@ -2,15 +2,23 @@ % Please edit documentation in R/modules.R \name{extract_module} \alias{extract_module} -\title{Extract module(s) of specific class.} +\alias{drop_module} +\title{Extract/Remove module(s) of specific class} \usage{ extract_module(modules, class) + +drop_module(modules, class) } \arguments{ -\item{modules}{\code{teal_modules} or \code{teal_module}, whatever is passed to \code{init}'s \code{modules} argument} +\item{modules}{\code{teal_modules}} + +\item{class}{The class name of \code{teal_module} to be extracted or dropped.} } \value{ -\code{teal_module} of class \code{class} or \code{teal_modules} containing modules of class \code{class}. +For \code{extract_module}, a \code{teal_module} of class \code{class} or \code{teal_modules} containing modules of class \code{class}. +For \code{drop_module}, an opposite, which is all \code{teal_modules} besides the ones with \code{class} class. + +\code{teal_modules} } \description{ Given a \code{teal_module} or a \code{teal_modules}, return the elements of the structure according to \code{class}. diff --git a/man/module.Rd b/man/module.Rd index ac860cdc05..c3ae5b00c7 100644 --- a/man/module.Rd +++ b/man/module.Rd @@ -10,7 +10,7 @@ module( label = "module", server = function(id, ...) { moduleServer(id, function(input, output, session) { - + }) }, ui = function(id, ...) { From 3da289f71c810c7bc83d25de310fb66451862c91 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 12:04:40 +0200 Subject: [PATCH 47/84] remove a note from init about tm_landing_popup --- R/init.R | 3 --- man/init.Rd | 4 ---- 2 files changed, 7 deletions(-) diff --git a/R/init.R b/R/init.R index 70c0564596..b5344e7c62 100644 --- a/R/init.R +++ b/R/init.R @@ -46,9 +46,6 @@ #' See the vignette for an example. However, [ui_teal_with_splash()] #' is then preferred to this function. #' -#' @note If you pass a module of class `"teal_module_landing"` in `modules` parameter, `teal` will not create a tab for -#' this module. -#' #' @return named list with `server` and `ui` function #' #' @export diff --git a/man/init.Rd b/man/init.Rd index a1bfc9e9e6..234f60697f 100644 --- a/man/init.Rd +++ b/man/init.Rd @@ -65,10 +65,6 @@ teal app that is composed out of teal modules. This is a wrapper function around the \code{module_teal.R} functions. Unless you are an end-user, don't use this function, but instead this module. } -\note{ -If you pass a module of class \code{"teal_module_landing"} in \code{modules} parameter, \code{teal} will not create a tab for -this module. -} \examples{ new_iris <- transform(iris, id = seq_len(nrow(iris))) new_mtcars <- transform(mtcars, id = seq_len(nrow(mtcars))) From d9c7472bc1a84a0657d4d63f4d3b21aacc7b80cb Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:07:26 +0200 Subject: [PATCH 48/84] Update R/modules.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dawid Kałędkowski <6959016+gogonzo@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/modules.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index fb35bad88a..d9d6475714 100644 --- a/R/modules.R +++ b/R/modules.R @@ -75,7 +75,7 @@ modules <- function(..., label = "root") { ) } - checkmate::assert_list(submodules, min.len = 1, any.missing = FALSE, types = c("teal_module", "teal_module_reporter", "teal_module_landing", "teal_modules")) + checkmate::assert_list(submodules, min.len = 1, any.missing = FALSE, types = c("teal_module", "teal_modules")) # name them so we can more easily access the children # beware however that the label of the submodules should not be changed as it must be kept synced labels <- vapply(submodules, function(submodule) submodule$label, character(1)) From 3cacf36abe6d177133ee99438903821c51740218 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 12:08:16 +0200 Subject: [PATCH 49/84] remove match.arg for type from init --- R/modules.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index fb35bad88a..d814bd8375 100644 --- a/R/modules.R +++ b/R/modules.R @@ -240,7 +240,6 @@ module <- function(label = "module", checkmate::assert_character(datanames, min.len = 1, null.ok = TRUE, any.missing = FALSE) checkmate::assert_list(server_args, null.ok = TRUE, names = "named") checkmate::assert_list(ui_args, null.ok = TRUE, names = "named") - type <- match.arg(type) if (!missing(filters)) { checkmate::assert_character(filters, min.len = 1, null.ok = TRUE, any.missing = FALSE) From 95397de0a6c9bed31eae2d332d4a338281e2feeb Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 12:23:14 +0200 Subject: [PATCH 50/84] extend tm_landing_popup examples with another module --- R/tm_landing_popup.R | 10 ++++++++++ man/tm_landing_popup.Rd | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R index 8224d1fdba..f97d2d55b2 100644 --- a/R/tm_landing_popup.R +++ b/R/tm_landing_popup.R @@ -19,6 +19,11 @@ #' teal::tm_landing_popup( #' content = "A place for the welcome message or a disclaimer statement.", #' buttons = modalButton("Proceed") +#' ), +#' module( +#' label = "example module", +#' server = function(input, output, session, data) {}, +#' ui = function(id, ...) div(p("Example text")) #' ) #' ) #' ) @@ -36,6 +41,11 @@ #' modalButton("Proceed"), #' actionButton("close", "Read more", onclick = "window.open('http://google.com', '_blank')") #' ) +#' ), +#' module( +#' label = "example module", +#' server = function(input, output, session, data) {}, +#' ui = function(id, ...) div(p("Example text")) #' ) #' ) #' ) diff --git a/man/tm_landing_popup.Rd b/man/tm_landing_popup.Rd index 04bf3c0435..63bf937a04 100644 --- a/man/tm_landing_popup.Rd +++ b/man/tm_landing_popup.Rd @@ -37,6 +37,11 @@ app1 <- teal::init( teal::tm_landing_popup( content = "A place for the welcome message or a disclaimer statement.", buttons = modalButton("Proceed") + ), + module( + label = "example module", + server = function(input, output, session, data) {}, + ui = function(id, ...) div(p("Example text")) ) ) ) @@ -54,6 +59,11 @@ app2 <- teal::init( modalButton("Proceed"), actionButton("close", "Read more", onclick = "window.open('http://google.com', '_blank')") ) + ), + module( + label = "example module", + server = function(input, output, session, data) {}, + ui = function(id, ...) div(p("Example text")) ) ) ) From e6049a02ec3c3bcab837548533f6accfc4ef81df Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 12:25:58 +0200 Subject: [PATCH 51/84] bring a more meanigful warning for situation where user provided only tm_landing_popup --- R/init.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index b5344e7c62..82743c0f4a 100644 --- a/R/init.R +++ b/R/init.R @@ -137,8 +137,11 @@ init <- function(data, } landing <- extract_module(modules, "teal_module_landing") - if (length(landing) > 1L) stop("only one `teal_module_landing` can be used") + if (length(landing) > 1L) stop("only one `tm_landing_popup` can be used") modules <- drop_module(modules, "teal_module_landing") + if (length(landing) == 1L && length(modules) == 0L) { + stop("app needs to have one more module besides `tm_landing_popup`") + } # resolve modules datanames datanames <- teal.data::get_dataname(data) From 7d753997213e5351485a6143834db4d86d240433 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 14:18:11 +0200 Subject: [PATCH 52/84] remove outdated parameter from documentaiton --- R/modules.R | 3 --- man/module.Rd | 4 ---- 2 files changed, 7 deletions(-) diff --git a/R/modules.R b/R/modules.R index 8209e1300c..362b533eef 100644 --- a/R/modules.R +++ b/R/modules.R @@ -191,9 +191,6 @@ is_arg_used <- function(modules, arg) { #' `server` function. #' @param ui_args (named `list`) with additional arguments passed on to the #' `ui` function. -#' @param type (`character(1)`) Class assigned to the resulting module. -#' All modules will have class `teal_module` (default) but one other class may be added. -#' Modules of class `"teal_module_landing"` will not be wrapped into tabs in the `teal` application. #' #' @return object of class `teal_module`. #' @export diff --git a/man/module.Rd b/man/module.Rd index c3ae5b00c7..d7267630cd 100644 --- a/man/module.Rd +++ b/man/module.Rd @@ -70,10 +70,6 @@ a subset of datasets which are appended to the \code{data} argument in \code{ser each \code{submodule} is indented one level more} \item{...}{parameters passed to \code{toString}} - -\item{type}{(\code{character(1)}) Class assigned to the resulting module. -All modules will have class \code{teal_module} (default) but one other class may be added. -Modules of class \code{"teal_module_landing"} will not be wrapped into tabs in the \code{teal} application.} } \value{ object of class \code{teal_module}. From 1dffcfd38598fecf885715220b27182d946f01b4 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 14:22:43 +0200 Subject: [PATCH 53/84] remove unneeded div from the examples --- R/tm_landing_popup.R | 2 +- man/tm_landing_popup.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R index f97d2d55b2..4544da78b1 100644 --- a/R/tm_landing_popup.R +++ b/R/tm_landing_popup.R @@ -36,7 +36,7 @@ #' modules = teal::modules( #' teal::tm_landing_popup( #' title = "Welcome", -#' content = div(tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;")), +#' content = tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;"), #' buttons = tagList( #' modalButton("Proceed"), #' actionButton("close", "Read more", onclick = "window.open('http://google.com', '_blank')") diff --git a/man/tm_landing_popup.Rd b/man/tm_landing_popup.Rd index 63bf937a04..b18c37ef7c 100644 --- a/man/tm_landing_popup.Rd +++ b/man/tm_landing_popup.Rd @@ -54,7 +54,7 @@ app2 <- teal::init( modules = teal::modules( teal::tm_landing_popup( title = "Welcome", - content = div(tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;")), + content = tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;"), buttons = tagList( modalButton("Proceed"), actionButton("close", "Read more", onclick = "window.open('http://google.com', '_blank')") From 8f111e847bbf2c7bd3113e44e1b76062c58f2985 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 14:24:11 +0200 Subject: [PATCH 54/84] shiny tag -> siny.tag documentation change --- R/tm_landing_popup.R | 2 +- man/tm_landing_popup.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R index 4544da78b1..e73d9ba6db 100644 --- a/R/tm_landing_popup.R +++ b/R/tm_landing_popup.R @@ -8,7 +8,7 @@ #' @param title `character(1)` the text to be displayed as a title of the popup. #' @param content `character(1)` the content of the popup. Passed to `...` of `shiny::modalDialog`. Can be a `character` #' or a text input control (like `textInput`) or a list of `shiny` tags. See examples. -#' @param buttons `shiny` tag or a list of tags (`tagList`). Typically a `modalButton` or `actionButton`. See examples. +#' @param buttons `shiny.tag` or a list of tags (`tagList`). Typically a `modalButton` or `actionButton`. See examples. #' #' @return A `teal_module` (extended with `teal_landing_module` class) to be used in `teal` applications. #' diff --git a/man/tm_landing_popup.Rd b/man/tm_landing_popup.Rd index b18c37ef7c..1379ee441c 100644 --- a/man/tm_landing_popup.Rd +++ b/man/tm_landing_popup.Rd @@ -19,7 +19,7 @@ tm_landing_popup( \item{content}{\code{character(1)} the content of the popup. Passed to \code{...} of \code{shiny::modalDialog}. Can be a \code{character} or a text input control (like \code{textInput}) or a list of \code{shiny} tags. See examples.} -\item{buttons}{\code{shiny} tag or a list of tags (\code{tagList}). Typically a \code{modalButton} or \code{actionButton}. See examples.} +\item{buttons}{\code{shiny.tag} or a list of tags (\code{tagList}). Typically a \code{modalButton} or \code{actionButton}. See examples.} } \value{ A \code{teal_module} (extended with \code{teal_landing_module} class) to be used in \code{teal} applications. From 4eb1a39995b910efb69aac5a853479fb92e55ace Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 14:38:51 +0200 Subject: [PATCH 55/84] example with the closing of the browser --- R/tm_landing_popup.R | 23 +++++++++++++++++++++++ man/tm_landing_popup.Rd | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R index e73d9ba6db..aced5f0c21 100644 --- a/R/tm_landing_popup.R +++ b/R/tm_landing_popup.R @@ -54,6 +54,29 @@ #' shinyApp(app2$ui, app2$server) #' } #' +#' app3 <- teal::init( +#' data = teal.data::dataset("iris", iris), +#' modules = teal::modules( +#' teal::tm_landing_popup( +#' title = "Welcome", +#' content = "App will close, once you click the rejection button!", +#' buttons = tagList( +#' modalButton("Proceed"), +#' actionButton("close", "Reject", onclick = "window.close()") +#' ) +#' ), +#' module( +#' label = "example module", +#' server = function(input, output, session, data) {}, +#' ui = function(id, ...) div(p("Example text")) +#' ) +#' ) +#' ) +#' +#' if (interactive()) { +#' shinyApp(app3$ui, app3$server, options = list(launch.browser = TRUE)) +#' } +#' #' @export tm_landing_popup <- function(label = "Landing Popup", diff --git a/man/tm_landing_popup.Rd b/man/tm_landing_popup.Rd index 1379ee441c..33befd92d9 100644 --- a/man/tm_landing_popup.Rd +++ b/man/tm_landing_popup.Rd @@ -72,4 +72,27 @@ if (interactive()) { shinyApp(app2$ui, app2$server) } +app3 <- teal::init( + data = teal.data::dataset("iris", iris), + modules = teal::modules( + teal::tm_landing_popup( + title = "Welcome", + content = "App will close, once you click the rejection button!", + buttons = tagList( + modalButton("Proceed"), + actionButton("close", "Reject", onclick = "window.close()") + ) + ), + module( + label = "example module", + server = function(input, output, session, data) {}, + ui = function(id, ...) div(p("Example text")) + ) + ) +) + +if (interactive()) { + shinyApp(app3$ui, app3$server, options = list(launch.browser = TRUE)) +} + } From c6a02031f8b01f66750039cf65a0803713418760 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 14:42:35 +0200 Subject: [PATCH 56/84] adjust text in docs --- R/tm_landing_popup.R | 2 +- man/tm_landing_popup.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R index aced5f0c21..a7f502da48 100644 --- a/R/tm_landing_popup.R +++ b/R/tm_landing_popup.R @@ -6,7 +6,7 @@ #' #' @param label `character(1)` the label of the module. #' @param title `character(1)` the text to be displayed as a title of the popup. -#' @param content `character(1)` the content of the popup. Passed to `...` of `shiny::modalDialog`. Can be a `character` +#' @param content The content of the popup. Passed to `...` of `shiny::modalDialog`. Can be a `character` #' or a text input control (like `textInput`) or a list of `shiny` tags. See examples. #' @param buttons `shiny.tag` or a list of tags (`tagList`). Typically a `modalButton` or `actionButton`. See examples. #' diff --git a/man/tm_landing_popup.Rd b/man/tm_landing_popup.Rd index 33befd92d9..e07b7198a4 100644 --- a/man/tm_landing_popup.Rd +++ b/man/tm_landing_popup.Rd @@ -16,7 +16,7 @@ tm_landing_popup( \item{title}{\code{character(1)} the text to be displayed as a title of the popup.} -\item{content}{\code{character(1)} the content of the popup. Passed to \code{...} of \code{shiny::modalDialog}. Can be a \code{character} +\item{content}{The content of the popup. Passed to \code{...} of \code{shiny::modalDialog}. Can be a \code{character} or a text input control (like \code{textInput}) or a list of \code{shiny} tags. See examples.} \item{buttons}{\code{shiny.tag} or a list of tags (\code{tagList}). Typically a \code{modalButton} or \code{actionButton}. See examples.} From 7b43211a677310c28c45140334dcec38ee2f2073 Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 16:15:23 +0200 Subject: [PATCH 57/84] lintr changes --- R/tm_landing_popup.R | 8 ++++++-- man/tm_landing_popup.Rd | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R index a7f502da48..3cc7139f00 100644 --- a/R/tm_landing_popup.R +++ b/R/tm_landing_popup.R @@ -36,10 +36,14 @@ #' modules = teal::modules( #' teal::tm_landing_popup( #' title = "Welcome", -#' content = tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;"), +#' content = tags$b( +#' "A place for the welcome message or a disclaimer statement.", +#' style = "color: red;" +#' ), #' buttons = tagList( #' modalButton("Proceed"), -#' actionButton("close", "Read more", onclick = "window.open('http://google.com', '_blank')") +#' actionButton("close", "Read more", +#' onclick = "window.open('http://google.com', '_blank')") #' ) #' ), #' module( diff --git a/man/tm_landing_popup.Rd b/man/tm_landing_popup.Rd index e07b7198a4..f6c01be0c5 100644 --- a/man/tm_landing_popup.Rd +++ b/man/tm_landing_popup.Rd @@ -54,10 +54,14 @@ app2 <- teal::init( modules = teal::modules( teal::tm_landing_popup( title = "Welcome", - content = tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;"), + content = tags$b( + "A place for the welcome message or a disclaimer statement.", + style = "color: red;" + ), buttons = tagList( modalButton("Proceed"), - actionButton("close", "Read more", onclick = "window.open('http://google.com', '_blank')") + actionButton("close", "Read more", + onclick = "window.open('http://google.com', '_blank')") ) ), module( From f0f60aa3627f3452cee74e73e8016881b629a286 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:18:41 +0000 Subject: [PATCH 58/84] [skip actions] Restyle files --- R/tm_landing_popup.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/tm_landing_popup.R b/R/tm_landing_popup.R index 3cc7139f00..3a914ead1a 100644 --- a/R/tm_landing_popup.R +++ b/R/tm_landing_popup.R @@ -37,13 +37,14 @@ #' teal::tm_landing_popup( #' title = "Welcome", #' content = tags$b( -#' "A place for the welcome message or a disclaimer statement.", -#' style = "color: red;" +#' "A place for the welcome message or a disclaimer statement.", +#' style = "color: red;" #' ), #' buttons = tagList( #' modalButton("Proceed"), #' actionButton("close", "Read more", -#' onclick = "window.open('http://google.com', '_blank')") +#' onclick = "window.open('http://google.com', '_blank')" +#' ) #' ) #' ), #' module( From 1d2130514234ebfca0747afa624ab460cc977caf Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 18:22:26 +0200 Subject: [PATCH 59/84] Empty-Commit From 39975e64b089e956f597a31057f6aaba131e7608 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:27:15 +0000 Subject: [PATCH 60/84] [skip actions] Roxygen Man Pages Auto Update --- man/tm_landing_popup.Rd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/man/tm_landing_popup.Rd b/man/tm_landing_popup.Rd index f6c01be0c5..259c6c4445 100644 --- a/man/tm_landing_popup.Rd +++ b/man/tm_landing_popup.Rd @@ -55,13 +55,14 @@ app2 <- teal::init( teal::tm_landing_popup( title = "Welcome", content = tags$b( - "A place for the welcome message or a disclaimer statement.", - style = "color: red;" + "A place for the welcome message or a disclaimer statement.", + style = "color: red;" ), buttons = tagList( modalButton("Proceed"), actionButton("close", "Read more", - onclick = "window.open('http://google.com', '_blank')") + onclick = "window.open('http://google.com', '_blank')" + ) ) ), module( From 16af597238be3e14ec83181174bc6985bdd46d0a Mon Sep 17 00:00:00 2001 From: m7pr Date: Tue, 24 Oct 2023 18:27:26 +0200 Subject: [PATCH 61/84] rename tm_landing_popup to landing_popup_module --- DESCRIPTION | 2 +- NAMESPACE | 2 +- R/init.R | 4 ++-- ...landing_popup.R => landing_popup_module.R} | 10 ++++----- _pkgdown.yml | 2 +- ...nding_popup.Rd => landing_popup_module.Rd} | 21 ++++++++++--------- 6 files changed, 21 insertions(+), 20 deletions(-) rename R/{tm_landing_popup.R => landing_popup_module.R} (95%) rename man/{tm_landing_popup.Rd => landing_popup_module.Rd} (86%) diff --git a/DESCRIPTION b/DESCRIPTION index 0e8564fcfc..08b0f6ce58 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -76,6 +76,7 @@ Collate: 'include_css_js.R' 'modules.R' 'init.R' + 'landing_popup_module.R' 'module_filter_manager.R' 'module_nested_tabs.R' 'module_snapshot_manager.R' @@ -90,7 +91,6 @@ Collate: 'teal_reporter.R' 'teal_slices-store.R' 'teal_slices.R' - 'tm_landing_popup.R' 'utils.R' 'validate_inputs.R' 'validations.R' diff --git a/NAMESPACE b/NAMESPACE index e4d39206ca..51ae8f93df 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,6 +24,7 @@ export(get_code_tdata) export(get_join_keys) export(get_metadata) export(init) +export(landing_popup_module) export(module) export(modules) export(new_tdata) @@ -33,7 +34,6 @@ export(show_rcode_modal) export(srv_teal_with_splash) export(tdata2env) export(teal_slices) -export(tm_landing_popup) export(ui_teal_with_splash) export(validate_has_data) export(validate_has_elements) diff --git a/R/init.R b/R/init.R index 82743c0f4a..6cb566d2e1 100644 --- a/R/init.R +++ b/R/init.R @@ -137,10 +137,10 @@ init <- function(data, } landing <- extract_module(modules, "teal_module_landing") - if (length(landing) > 1L) stop("only one `tm_landing_popup` can be used") + if (length(landing) > 1L) stop("only one `landing_popup_module` can be used") modules <- drop_module(modules, "teal_module_landing") if (length(landing) == 1L && length(modules) == 0L) { - stop("app needs to have one more module besides `tm_landing_popup`") + stop("app needs to have one more module besides `landing_popup_module`") } # resolve modules datanames diff --git a/R/tm_landing_popup.R b/R/landing_popup_module.R similarity index 95% rename from R/tm_landing_popup.R rename to R/landing_popup_module.R index 3a914ead1a..bb98d1fa39 100644 --- a/R/tm_landing_popup.R +++ b/R/landing_popup_module.R @@ -16,7 +16,7 @@ #' app1 <- teal::init( #' data = teal.data::dataset("iris", iris), #' modules = teal::modules( -#' teal::tm_landing_popup( +#' teal::landing_popup_module( #' content = "A place for the welcome message or a disclaimer statement.", #' buttons = modalButton("Proceed") #' ), @@ -34,7 +34,7 @@ #' app2 <- teal::init( #' data = teal.data::dataset("iris", iris), #' modules = teal::modules( -#' teal::tm_landing_popup( +#' teal::landing_popup_module( #' title = "Welcome", #' content = tags$b( #' "A place for the welcome message or a disclaimer statement.", @@ -62,7 +62,7 @@ #' app3 <- teal::init( #' data = teal.data::dataset("iris", iris), #' modules = teal::modules( -#' teal::tm_landing_popup( +#' teal::landing_popup_module( #' title = "Welcome", #' content = "App will close, once you click the rejection button!", #' buttons = tagList( @@ -83,7 +83,7 @@ #' } #' #' @export -tm_landing_popup <- +landing_popup_module <- function(label = "Landing Popup", title = NULL, content = NULL, @@ -96,7 +96,7 @@ tm_landing_popup <- ) checkmate::assert_multi_class(buttons, classes = c("shiny.tag", "shiny.tag.list")) - logger::log_info("Initializing tm_landing_popup") + logger::log_info("Initializing landing_popup_module") module <- module( label = label, diff --git a/_pkgdown.yml b/_pkgdown.yml index 892e6f6686..c75a61786d 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -109,7 +109,7 @@ reference: - report_card_template - title: Landing Popup contents: - - tm_landing_popup + - landing_popup_module - title: Functions for Module Developers contents: - tdata diff --git a/man/tm_landing_popup.Rd b/man/landing_popup_module.Rd similarity index 86% rename from man/tm_landing_popup.Rd rename to man/landing_popup_module.Rd index f6c01be0c5..09ff83e83b 100644 --- a/man/tm_landing_popup.Rd +++ b/man/landing_popup_module.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tm_landing_popup.R -\name{tm_landing_popup} -\alias{tm_landing_popup} +% Please edit documentation in R/landing_popup_module.R +\name{landing_popup_module} +\alias{landing_popup_module} \title{Landing Popup Module} \usage{ -tm_landing_popup( +landing_popup_module( label = "Landing Popup", title = NULL, content = NULL, @@ -34,7 +34,7 @@ If you use this module in \code{teal::init(modules = )}, it will not be wrapped app1 <- teal::init( data = teal.data::dataset("iris", iris), modules = teal::modules( - teal::tm_landing_popup( + teal::landing_popup_module( content = "A place for the welcome message or a disclaimer statement.", buttons = modalButton("Proceed") ), @@ -52,16 +52,17 @@ if (interactive()) { app2 <- teal::init( data = teal.data::dataset("iris", iris), modules = teal::modules( - teal::tm_landing_popup( + teal::landing_popup_module( title = "Welcome", content = tags$b( - "A place for the welcome message or a disclaimer statement.", - style = "color: red;" + "A place for the welcome message or a disclaimer statement.", + style = "color: red;" ), buttons = tagList( modalButton("Proceed"), actionButton("close", "Read more", - onclick = "window.open('http://google.com', '_blank')") + onclick = "window.open('http://google.com', '_blank')" + ) ) ), module( @@ -79,7 +80,7 @@ if (interactive()) { app3 <- teal::init( data = teal.data::dataset("iris", iris), modules = teal::modules( - teal::tm_landing_popup( + teal::landing_popup_module( title = "Welcome", content = "App will close, once you click the rejection button!", buttons = tagList( From 0179152845904a5208c4c1306da62eee4481966e Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:21:23 +0200 Subject: [PATCH 62/84] specify content parameter in landind_popup_module --- R/landing_popup_module.R | 2 +- man/landing_popup_module.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index bb98d1fa39..163232b1c0 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -7,7 +7,7 @@ #' @param label `character(1)` the label of the module. #' @param title `character(1)` the text to be displayed as a title of the popup. #' @param content The content of the popup. Passed to `...` of `shiny::modalDialog`. Can be a `character` -#' or a text input control (like `textInput`) or a list of `shiny` tags. See examples. +#' or a list of `shiny.tag`s. See examples. #' @param buttons `shiny.tag` or a list of tags (`tagList`). Typically a `modalButton` or `actionButton`. See examples. #' #' @return A `teal_module` (extended with `teal_landing_module` class) to be used in `teal` applications. diff --git a/man/landing_popup_module.Rd b/man/landing_popup_module.Rd index 09ff83e83b..d06bb97e92 100644 --- a/man/landing_popup_module.Rd +++ b/man/landing_popup_module.Rd @@ -17,7 +17,7 @@ landing_popup_module( \item{title}{\code{character(1)} the text to be displayed as a title of the popup.} \item{content}{The content of the popup. Passed to \code{...} of \code{shiny::modalDialog}. Can be a \code{character} -or a text input control (like \code{textInput}) or a list of \code{shiny} tags. See examples.} +or a list of \code{shiny.tag}s. See examples.} \item{buttons}{\code{shiny.tag} or a list of tags (\code{tagList}). Typically a \code{modalButton} or \code{actionButton}. See examples.} } From 9e700ab65227433599ef78776dca4c366f4f8d58 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:22:08 +0200 Subject: [PATCH 63/84] Update R/landing_popup_module.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/landing_popup_module.R | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index 163232b1c0..6a6b878d03 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -83,11 +83,10 @@ #' } #' #' @export -landing_popup_module <- - function(label = "Landing Popup", - title = NULL, - content = NULL, - buttons = modalButton("Accept")) { +landing_popup_module <- function(label = "Landing Popup", + title = NULL, + content = NULL, + buttons = modalButton("Accept")) { checkmate::assert_string(label) checkmate::assert_string(title, null.ok = TRUE) checkmate::assert_multi_class( From bc2550355d26ac04685a29de0f373d3df71a47de Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:23:15 +0200 Subject: [PATCH 64/84] extend logging in reporter_previewer_module --- R/reporter_previewer_module.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/reporter_previewer_module.R b/R/reporter_previewer_module.R index c3e1e3f671..4c6e67b5fc 100644 --- a/R/reporter_previewer_module.R +++ b/R/reporter_previewer_module.R @@ -20,6 +20,8 @@ reporter_previewer_module <- function(label = "Report previewer", server_args = checkmate::assert_list(server_args, names = "named") checkmate::assert_true(all(names(server_args) %in% names(formals(teal.reporter::reporter_previewer_srv)))) + logger::log_info("Initializing reporter_previewer_module") + srv <- function(id, reporter, ...) { teal.reporter::reporter_previewer_srv(id, reporter, ...) } From ab29aab372fd6fc3c6f5ca4225d4d110a5ea5613 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:24:53 +0200 Subject: [PATCH 65/84] Update R/landing_popup_module.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/landing_popup_module.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index 6a6b878d03..2fda2bed86 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -2,7 +2,8 @@ #' #' @description This module creates a landing welcome popup for `teal` applications. #' -#' @details If you use this module in `teal::init(modules = )`, it will not be wrapped in a tab in `teal` application. +#' This module is used to display a popup dialog when the application starts. +#' The dialog blocks access to the application and must be closed with a button before the app is viewed. #' #' @param label `character(1)` the label of the module. #' @param title `character(1)` the text to be displayed as a title of the popup. From 064e382d4ed1b55e83f4692bff646ffe742da648 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:26:26 +0200 Subject: [PATCH 66/84] rebuild documentaion --- R/landing_popup_module.R | 4 ++-- man/landing_popup_module.Rd | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index 2fda2bed86..9a6a262f83 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -2,8 +2,8 @@ #' #' @description This module creates a landing welcome popup for `teal` applications. #' -#' This module is used to display a popup dialog when the application starts. -#' The dialog blocks access to the application and must be closed with a button before the app is viewed. +#' This module is used to display a popup dialog when the application starts. +#' The dialog blocks the access to the application and must be closed with a button before the application is viewed. #' #' @param label `character(1)` the label of the module. #' @param title `character(1)` the text to be displayed as a title of the popup. diff --git a/man/landing_popup_module.Rd b/man/landing_popup_module.Rd index d06bb97e92..63160fec09 100644 --- a/man/landing_popup_module.Rd +++ b/man/landing_popup_module.Rd @@ -26,9 +26,9 @@ A \code{teal_module} (extended with \code{teal_landing_module} class) to be used } \description{ This module creates a landing welcome popup for \code{teal} applications. -} -\details{ -If you use this module in \code{teal::init(modules = )}, it will not be wrapped in a tab in \code{teal} application. + +This module is used to display a popup dialog when the application starts. +The dialog blocks the access to the application and must be closed with a button before the application is viewed. } \examples{ app1 <- teal::init( From 64f72154119f47844467d46ea47f80ab516a5ef6 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:27:56 +0200 Subject: [PATCH 67/84] Update R/reporter_previewer_module.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/reporter_previewer_module.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/reporter_previewer_module.R b/R/reporter_previewer_module.R index 4c6e67b5fc..0c26786be8 100644 --- a/R/reporter_previewer_module.R +++ b/R/reporter_previewer_module.R @@ -35,7 +35,8 @@ reporter_previewer_module <- function(label = "Report previewer", server_args = server = srv, ui = ui, server_args = server_args, ui_args = list(), datanames = NULL ) - # Label 'Report previewer' is reserved in teal. +# Module is created with a placeholder label and the label is changed later. +# This is to prevent another module being labeled "Report previewer". class(module) <- c("teal_module_previewer", class(module)) module$label <- label module From 132872b5bd7bcba6a4deb115d6c9e5ef57101fcf Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:31:12 +0200 Subject: [PATCH 68/84] change man name for extract/drop_modules to module_management --- R/modules.R | 4 ++-- man/{extract_module.Rd => module_management.Rd} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename man/{extract_module.Rd => module_management.Rd} (100%) diff --git a/R/modules.R b/R/modules.R index 362b533eef..d4f1d784b8 100644 --- a/R/modules.R +++ b/R/modules.R @@ -112,7 +112,7 @@ append_module <- function(modules, module) { #' @keywords internal #' @return For `extract_module`, a `teal_module` of class `class` or `teal_modules` containing modules of class `class`. #' For `drop_module`, an opposite, which is all `teal_modules` besides the ones with `class` class. -#' @rdname extract_module +#' @rdname module_management extract_module <- function(modules, class) { if (inherits(modules, class)) { modules @@ -125,7 +125,7 @@ extract_module <- function(modules, class) { #' @keywords internal #' @return `teal_modules` -#' @rdname extract_module +#' @rdname module_management drop_module <- function(modules, class) { if (inherits(modules, class)) { NULL diff --git a/man/extract_module.Rd b/man/module_management.Rd similarity index 100% rename from man/extract_module.Rd rename to man/module_management.Rd From 2d25bd93c32ccc132d72ad97d65c6e5f2f1fd72f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:31:19 +0000 Subject: [PATCH 69/84] [skip actions] Restyle files --- R/landing_popup_module.R | 50 +++++++++++++++++------------------ R/reporter_previewer_module.R | 4 +-- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index 9a6a262f83..ffad92065b 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -88,31 +88,31 @@ landing_popup_module <- function(label = "Landing Popup", title = NULL, content = NULL, buttons = modalButton("Accept")) { - checkmate::assert_string(label) - checkmate::assert_string(title, null.ok = TRUE) - checkmate::assert_multi_class( - content, - classes = c("character", "shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE - ) - checkmate::assert_multi_class(buttons, classes = c("shiny.tag", "shiny.tag.list")) + checkmate::assert_string(label) + checkmate::assert_string(title, null.ok = TRUE) + checkmate::assert_multi_class( + content, + classes = c("character", "shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE + ) + checkmate::assert_multi_class(buttons, classes = c("shiny.tag", "shiny.tag.list")) - logger::log_info("Initializing landing_popup_module") + logger::log_info("Initializing landing_popup_module") - module <- module( - label = label, - server = function(id) { - moduleServer(id, function(input, output, session) { - showModal( - modalDialog( - id = "landingpopup", - title = title, - content, - footer = buttons - ) + module <- module( + label = label, + server = function(id) { + moduleServer(id, function(input, output, session) { + showModal( + modalDialog( + id = "landingpopup", + title = title, + content, + footer = buttons ) - }) - } - ) - class(module) <- c("teal_module_landing", class(module)) - module - } + ) + }) + } + ) + class(module) <- c("teal_module_landing", class(module)) + module +} diff --git a/R/reporter_previewer_module.R b/R/reporter_previewer_module.R index 0c26786be8..e24174f2d7 100644 --- a/R/reporter_previewer_module.R +++ b/R/reporter_previewer_module.R @@ -35,8 +35,8 @@ reporter_previewer_module <- function(label = "Report previewer", server_args = server = srv, ui = ui, server_args = server_args, ui_args = list(), datanames = NULL ) -# Module is created with a placeholder label and the label is changed later. -# This is to prevent another module being labeled "Report previewer". + # Module is created with a placeholder label and the label is changed later. + # This is to prevent another module being labeled "Report previewer". class(module) <- c("teal_module_previewer", class(module)) module$label <- label module From 30fb85df93839b39fb91fba9343d4eaf8c55b58c Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:33:06 +0200 Subject: [PATCH 70/84] Update R/landing_popup_module.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/landing_popup_module.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index ffad92065b..fa82b067c3 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -1,6 +1,6 @@ #' Landing Popup Module #' -#' @description This module creates a landing welcome popup for `teal` applications. +#' @description Creates a landing welcome popup for `teal` applications. #' #' This module is used to display a popup dialog when the application starts. #' The dialog blocks the access to the application and must be closed with a button before the application is viewed. From 4f651c45bc79413a00a19b8cf1ea84ef9eb95616 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:36:01 +0200 Subject: [PATCH 71/84] Title case warning --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index 6cb566d2e1..d3e88e6338 100644 --- a/R/init.R +++ b/R/init.R @@ -137,7 +137,7 @@ init <- function(data, } landing <- extract_module(modules, "teal_module_landing") - if (length(landing) > 1L) stop("only one `landing_popup_module` can be used") + if (length(landing) > 1L) stop("Only one `landing_popup_module` can be used.") modules <- drop_module(modules, "teal_module_landing") if (length(landing) == 1L && length(modules) == 0L) { stop("app needs to have one more module besides `landing_popup_module`") From 0200dc233aea5df6128bc90a8c10c53397ed996d Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:36:31 +0200 Subject: [PATCH 72/84] Update R/init.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/init.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index d3e88e6338..2cb01ed2d9 100644 --- a/R/init.R +++ b/R/init.R @@ -140,7 +140,7 @@ init <- function(data, if (length(landing) > 1L) stop("Only one `landing_popup_module` can be used.") modules <- drop_module(modules, "teal_module_landing") if (length(landing) == 1L && length(modules) == 0L) { - stop("app needs to have one more module besides `landing_popup_module`") + stop("The app must have at least one module besides `landing_popup_module`.") } # resolve modules datanames From 87af18ab4049362cb28fb075a2760deb638dfbc6 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:38:35 +0200 Subject: [PATCH 73/84] make it easier to read the return value for modules_management --- R/modules.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index d4f1d784b8..64c3ae58d2 100644 --- a/R/modules.R +++ b/R/modules.R @@ -110,7 +110,8 @@ append_module <- function(modules, module) { #' @param modules `teal_modules` #' @param class The class name of `teal_module` to be extracted or dropped. #' @keywords internal -#' @return For `extract_module`, a `teal_module` of class `class` or `teal_modules` containing modules of class `class`. +#' @return +#' For `extract_module`, a `teal_module` of class `class` or `teal_modules` containing modules of class `class`. #' For `drop_module`, an opposite, which is all `teal_modules` besides the ones with `class` class. #' @rdname module_management extract_module <- function(modules, class) { From 22e057eac41522886b87f5252051eb9d48be3289 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:38:55 +0200 Subject: [PATCH 74/84] rebuild man --- man/landing_popup_module.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/landing_popup_module.Rd b/man/landing_popup_module.Rd index 63160fec09..1f175751cb 100644 --- a/man/landing_popup_module.Rd +++ b/man/landing_popup_module.Rd @@ -25,7 +25,7 @@ or a list of \code{shiny.tag}s. See examples.} A \code{teal_module} (extended with \code{teal_landing_module} class) to be used in \code{teal} applications. } \description{ -This module creates a landing welcome popup for \code{teal} applications. +Creates a landing welcome popup for \code{teal} applications. This module is used to display a popup dialog when the application starts. The dialog blocks the access to the application and must be closed with a button before the application is viewed. From 71c1676b3284ed7edc25b212f18ca20bc1e69df9 Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:39:42 +0200 Subject: [PATCH 75/84] Update R/modules.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/modules.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index 64c3ae58d2..63a91cb51f 100644 --- a/R/modules.R +++ b/R/modules.R @@ -112,7 +112,7 @@ append_module <- function(modules, module) { #' @keywords internal #' @return #' For `extract_module`, a `teal_module` of class `class` or `teal_modules` containing modules of class `class`. -#' For `drop_module`, an opposite, which is all `teal_modules` besides the ones with `class` class. +#' For `drop_module`, the opposite, which is all `teal_modules` of class other than `class`. #' @rdname module_management extract_module <- function(modules, class) { if (inherits(modules, class)) { From 9de95b190d9501612d7a827cb189ffec585e184f Mon Sep 17 00:00:00 2001 From: Marcin <133694481+m7pr@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:40:00 +0200 Subject: [PATCH 76/84] Update R/modules.R Co-authored-by: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/modules.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modules.R b/R/modules.R index 63a91cb51f..472a1076b1 100644 --- a/R/modules.R +++ b/R/modules.R @@ -89,7 +89,7 @@ modules <- function(..., label = "root") { ) } -#' Function which appends a `teal_module` onto the children of a `teal_modules` object +#' Append a `teal_module` to `children` of a `teal_modules` object #' @keywords internal #' @param modules `teal_modules` #' @param module `teal_module` object to be appended onto the children of `modules` From 970ac66fd82319f4b0c2e765e912f9b8140f0416 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:41:19 +0200 Subject: [PATCH 77/84] update NEWS --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index ebd44803db..8532ba54fd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,7 +7,7 @@ * Added internal functions for storing and restoring of `teal_slices` objects. * Filter state snapshots can now be uploaded from file. See `?snapshot`. * Added argument to `teal_slices` and made modifications to `init` to enable tagging `teal_slices` with an app id to safely upload snapshots from disk. -* `module` can now create modules of different classes that will be handled differently by `init`. The default class is still `"teal_module"` so no changes to existing templates are necessary. Currently handled classes are `"teal_module_landing"`, which will not be presented in tabs, and `"teal_module_reporter"`. +* Added `landing_popup_module` function which creates a module that will display a popup when the app starts. The popup will block access to the app until it is dismissed. # teal 0.14.0 From 989f30df5030be4678da69b998d533b35aec55bd Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:46:31 +0000 Subject: [PATCH 78/84] [skip actions] Roxygen Man Pages Auto Update --- man/append_module.Rd | 4 ++-- man/module_management.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/append_module.Rd b/man/append_module.Rd index 48656ac2fb..379e474ba9 100644 --- a/man/append_module.Rd +++ b/man/append_module.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/modules.R \name{append_module} \alias{append_module} -\title{Function which appends a \code{teal_module} onto the children of a \code{teal_modules} object} +\title{Append a \code{teal_module} to \code{children} of a \code{teal_modules} object} \usage{ append_module(modules, module) } @@ -15,6 +15,6 @@ append_module(modules, module) \code{teal_modules} object with \code{module} appended } \description{ -Function which appends a \code{teal_module} onto the children of a \code{teal_modules} object +Append a \code{teal_module} to \code{children} of a \code{teal_modules} object } \keyword{internal} diff --git a/man/module_management.Rd b/man/module_management.Rd index 4745631536..bd9f88db50 100644 --- a/man/module_management.Rd +++ b/man/module_management.Rd @@ -16,7 +16,7 @@ drop_module(modules, class) } \value{ For \code{extract_module}, a \code{teal_module} of class \code{class} or \code{teal_modules} containing modules of class \code{class}. -For \code{drop_module}, an opposite, which is all \code{teal_modules} besides the ones with \code{class} class. +For \code{drop_module}, the opposite, which is all \code{teal_modules} of class other than \code{class}. \code{teal_modules} } From 0670e3be2b3db80a88d4a802ec2031749a42e057 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 11:48:31 +0200 Subject: [PATCH 79/84] Empty-Commit From 007c0e158904d589171da721845c958c60dcb8b3 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 12:26:38 +0200 Subject: [PATCH 80/84] remove unnecessary error message --- R/init.R | 3 --- 1 file changed, 3 deletions(-) diff --git a/R/init.R b/R/init.R index 2cb01ed2d9..56b6812083 100644 --- a/R/init.R +++ b/R/init.R @@ -139,9 +139,6 @@ init <- function(data, landing <- extract_module(modules, "teal_module_landing") if (length(landing) > 1L) stop("Only one `landing_popup_module` can be used.") modules <- drop_module(modules, "teal_module_landing") - if (length(landing) == 1L && length(modules) == 0L) { - stop("The app must have at least one module besides `landing_popup_module`.") - } # resolve modules datanames datanames <- teal.data::get_dataname(data) From 0b4ddf8ef30b4f72f4e517ae0d5b2feb11769da2 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 12:54:41 +0200 Subject: [PATCH 81/84] use example_module() in simple teal examples --- R/landing_popup_module.R | 12 ++---------- man/landing_popup_module.Rd | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index fa82b067c3..796c37f0f0 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -21,11 +21,7 @@ #' content = "A place for the welcome message or a disclaimer statement.", #' buttons = modalButton("Proceed") #' ), -#' module( -#' label = "example module", -#' server = function(input, output, session, data) {}, -#' ui = function(id, ...) div(p("Example text")) -#' ) +#' example_module() #' ) #' ) #' if (interactive()) { @@ -48,11 +44,7 @@ #' ) #' ) #' ), -#' module( -#' label = "example module", -#' server = function(input, output, session, data) {}, -#' ui = function(id, ...) div(p("Example text")) -#' ) +#' example_module() #' ) #' ) #' diff --git a/man/landing_popup_module.Rd b/man/landing_popup_module.Rd index 1f175751cb..c25f83ae65 100644 --- a/man/landing_popup_module.Rd +++ b/man/landing_popup_module.Rd @@ -38,11 +38,7 @@ app1 <- teal::init( content = "A place for the welcome message or a disclaimer statement.", buttons = modalButton("Proceed") ), - module( - label = "example module", - server = function(input, output, session, data) {}, - ui = function(id, ...) div(p("Example text")) - ) + example_module() ) ) if (interactive()) { @@ -65,11 +61,7 @@ app2 <- teal::init( ) ) ), - module( - label = "example module", - server = function(input, output, session, data) {}, - ui = function(id, ...) div(p("Example text")) - ) + example_module() ) ) From 9e7ecfbdcae6365aa65339aee2316e9baac45586 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 13:02:28 +0200 Subject: [PATCH 82/84] update landing examples --- R/landing_popup_module.R | 6 +----- man/landing_popup_module.Rd | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index 796c37f0f0..a4f8eba2ed 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -63,11 +63,7 @@ #' actionButton("close", "Reject", onclick = "window.close()") #' ) #' ), -#' module( -#' label = "example module", -#' server = function(input, output, session, data) {}, -#' ui = function(id, ...) div(p("Example text")) -#' ) +#' example_module() #' ) #' ) #' diff --git a/man/landing_popup_module.Rd b/man/landing_popup_module.Rd index c25f83ae65..2f41f36fbb 100644 --- a/man/landing_popup_module.Rd +++ b/man/landing_popup_module.Rd @@ -80,11 +80,7 @@ app3 <- teal::init( actionButton("close", "Reject", onclick = "window.close()") ) ), - module( - label = "example module", - server = function(input, output, session, data) {}, - ui = function(id, ...) div(p("Example text")) - ) + example_module() ) ) From 10ac427129ba2f843354c054a9d21f999b7f6733 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 16:14:52 +0200 Subject: [PATCH 83/84] merge 2 example for landing page popup --- R/landing_popup_module.R | 24 +++--------------------- man/landing_popup_module.Rd | 24 +++--------------------- 2 files changed, 6 insertions(+), 42 deletions(-) diff --git a/R/landing_popup_module.R b/R/landing_popup_module.R index a4f8eba2ed..cb94e14484 100644 --- a/R/landing_popup_module.R +++ b/R/landing_popup_module.R @@ -39,27 +39,9 @@ #' ), #' buttons = tagList( #' modalButton("Proceed"), -#' actionButton("close", "Read more", +#' actionButton("read", "Read more", #' onclick = "window.open('http://google.com', '_blank')" -#' ) -#' ) -#' ), -#' example_module() -#' ) -#' ) -#' -#' if (interactive()) { -#' shinyApp(app2$ui, app2$server) -#' } -#' -#' app3 <- teal::init( -#' data = teal.data::dataset("iris", iris), -#' modules = teal::modules( -#' teal::landing_popup_module( -#' title = "Welcome", -#' content = "App will close, once you click the rejection button!", -#' buttons = tagList( -#' modalButton("Proceed"), +#' ), #' actionButton("close", "Reject", onclick = "window.close()") #' ) #' ), @@ -68,7 +50,7 @@ #' ) #' #' if (interactive()) { -#' shinyApp(app3$ui, app3$server, options = list(launch.browser = TRUE)) +#' shinyApp(app2$ui, app2$server) #' } #' #' @export diff --git a/man/landing_popup_module.Rd b/man/landing_popup_module.Rd index 2f41f36fbb..92531ca334 100644 --- a/man/landing_popup_module.Rd +++ b/man/landing_popup_module.Rd @@ -56,27 +56,9 @@ app2 <- teal::init( ), buttons = tagList( modalButton("Proceed"), - actionButton("close", "Read more", + actionButton("read", "Read more", onclick = "window.open('http://google.com', '_blank')" - ) - ) - ), - example_module() - ) -) - -if (interactive()) { - shinyApp(app2$ui, app2$server) -} - -app3 <- teal::init( - data = teal.data::dataset("iris", iris), - modules = teal::modules( - teal::landing_popup_module( - title = "Welcome", - content = "App will close, once you click the rejection button!", - buttons = tagList( - modalButton("Proceed"), + ), actionButton("close", "Reject", onclick = "window.close()") ) ), @@ -85,7 +67,7 @@ app3 <- teal::init( ) if (interactive()) { - shinyApp(app3$ui, app3$server, options = list(launch.browser = TRUE)) + shinyApp(app2$ui, app2$server) } } From 330097986ff4f6806a6b0f9133ca49a4d1fe895f Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 25 Oct 2023 16:16:00 +0200 Subject: [PATCH 84/84] Empty-Commit