Skip to content

Commit

Permalink
initialize reporter object
Browse files Browse the repository at this point in the history
append_reporter_module to modules.R
  • Loading branch information
gogonzo committed Jan 29, 2025
1 parent 653cf03 commit eed27bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
18 changes: 3 additions & 15 deletions R/module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,6 @@
#' @return `NULL` invisibly
NULL

#' @rdname module_teal
#' @keywords internal
#' @noRd
append_reporter_module <- function(modules) {
reporter <- teal.reporter::Reporter$new()$set_id(attr(filter, "app_id"))
if (is_arg_used(modules, "reporter") && length(extract_module(modules, "teal_module_previewer")) == 0) {
modules <- append_module(
modules,
reporter_previewer_module(server_args = list(previewer_buttons = c("download", "reset")))
)
}
modules
}

#' @rdname module_teal
#' @export
ui_teal <- function(id, modules) {
Expand Down Expand Up @@ -236,6 +222,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) {
)
}

reporter <- teal.reporter::Reporter$new()$set_id(attr(filter, "app_id"))
module_labels <- unlist(module_labels(modules), use.names = FALSE)
slices_global <- methods::new(".slicesGlobal", filter, module_labels)
modules_output <- srv_teal_module(
Expand All @@ -244,7 +231,8 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) {
datasets = datasets_rv,
modules = modules,
slices_global = slices_global,
data_load_status = data_load_status
data_load_status = data_load_status,
reporter = reporter
)
mapping_table <- srv_filter_manager_panel("filter_manager_panel", slices_global = slices_global)
snapshots <- srv_snapshot_manager_panel("snapshot_manager_panel", slices_global = slices_global)
Expand Down
13 changes: 13 additions & 0 deletions R/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,19 @@ append_module <- function(modules, module) {
modules
}

#' @rdname module_teal
#' @keywords internal
#' @noRd
append_reporter_module <- function(modules) {
if (is_arg_used(modules, "reporter") && length(extract_module(modules, "teal_module_previewer")) == 0) {
modules <- append_module(
modules,
reporter_previewer_module(server_args = list(previewer_buttons = c("download", "reset")))
)
}
modules
}

#' Extract/Remove module(s) of specific class
#'
#' Given a `teal_module` or a `teal_modules`, return the elements of the structure according to `class`.
Expand Down

0 comments on commit eed27bd

Please sign in to comment.