diff --git a/R/AddCardModule.R b/R/AddCardModule.R index 91825da21..8d04050e8 100644 --- a/R/AddCardModule.R +++ b/R/AddCardModule.R @@ -83,10 +83,11 @@ add_card_button_ui <- function(id) { #' @rdname add_card_button #' @export -add_card_button_srv <- function(id, reporter, card_fun) { +add_card_button_srv <- function(id, reporter, card_fun, env) { checkmate::assert_function(card_fun) checkmate::assert_class(reporter, "Reporter") - checkmate::assert_subset(names(formals(card_fun)), c("card", "comment", "label"), empty.ok = TRUE) + checkmate::assert_subset(names(formals(card_fun)), c("card", "comment", "label", "env"), empty.ok = TRUE) + checkmate::assert_environment(env, null.ok = TRUE) shiny::moduleServer(id, function(input, output, session) { shiny::setBookmarkExclude(c( @@ -160,6 +161,7 @@ add_card_button_srv <- function(id, reporter, card_fun) { has_card_arg <- "card" %in% card_fun_args_nams has_comment_arg <- "comment" %in% card_fun_args_nams has_label_arg <- "label" %in% card_fun_args_nams + has_env_arg <- "label" %in% card_fun_args_nams arg_list <- list() @@ -169,6 +171,9 @@ add_card_button_srv <- function(id, reporter, card_fun) { if (has_label_arg) { arg_list <- c(arg_list, list(label = input$label)) } + if (has_env_arg && !is.null(env)) { + arg_list <- c(arg_list, env = env) + } if (has_card_arg) { # The default_card is defined here because formals() returns a pairedlist object diff --git a/R/SimpleReporter.R b/R/SimpleReporter.R index 3aef137ce..a12c5e277 100644 --- a/R/SimpleReporter.R +++ b/R/SimpleReporter.R @@ -64,18 +64,24 @@ simple_reporter_srv <- function( card_fun, global_knitr = getOption("teal.reporter.global_knitr"), rmd_output = c( - "html" = "html_document", "pdf" = "pdf_document", - "powerpoint" = "powerpoint_presentation", "word" = "word_document" + "html" = "html_document", + "pdf" = "pdf_document", + "powerpoint" = "powerpoint_presentation", + "word" = "word_document" ), rmd_yaml_args = list( - author = "NEST", title = "Report", - date = as.character(Sys.Date()), output = "html_document", + author = "NEST", + title = "Report", + date = as.character(Sys.Date()), + output = "html_document", toc = FALSE - )) { + ), + env +) { shiny::moduleServer( id, function(input, output, session) { - add_card_button_srv("add_report_card_simple", reporter = reporter, card_fun = card_fun) + add_card_button_srv("add_report_card_simple", reporter = reporter, card_fun = card_fun, env = env) download_report_button_srv( "download_button_simple", reporter = reporter,