Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions R/AddCardModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand Down
18 changes: 12 additions & 6 deletions R/SimpleReporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down