Skip to content

Commit 24b0533

Browse files
committed
attempt on tm_variable_browser
1 parent 9deb408 commit 24b0533

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

R/tm_variable_browser.R

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ ui_variable_browser <- function(id,
155155
})
156156
),
157157
teal.widgets::white_small_well(
158-
### Reporter
159-
teal.reporter::add_card_button_ui(ns("add_reporter"), label = "Add Report Card"),
160-
tags$br(), tags$br(),
161-
###
162158
uiOutput(ns("ui_histogram_display")),
163159
uiOutput(ns("ui_numeric_display")),
164160
teal.widgets::plot_with_settings_ui(ns("variable_plot")),
@@ -201,11 +197,7 @@ ui_variable_browser <- function(id,
201197
# Server function for the variable browser module
202198
srv_variable_browser <- function(id,
203199
data,
204-
reporter,
205-
filter_panel_api,
206200
datanames, parent_dataname, ggplot2_args) {
207-
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
208-
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
209201
checkmate::assert_class(data, "reactive")
210202
checkmate::assert_class(isolate(data()), "teal_data")
211203
moduleServer(id, function(input, output, session) {
@@ -498,24 +490,28 @@ srv_variable_browser <- function(id,
498490
)
499491
})
500492

501-
### REPORTER
502-
if (with_reporter) {
503-
card_fun <- function(comment) {
504-
card <- teal::TealReportCard$new()
505-
card$set_name("Variable Browser Plot")
506-
card$append_text("Variable Browser Plot", "header2")
507-
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
508-
card$append_text("Plot", "header3")
509-
card$append_plot(variable_plot_r(), dim = pws$dim())
510-
if (!comment == "") {
511-
card$append_text("Comment", "header3")
512-
card$append_text(comment)
513-
}
514-
card
515-
}
516-
teal.reporter::add_card_button_srv("add_reporter", reporter = reporter, card_fun = card_fun)
517-
}
518-
###
493+
reactive({
494+
# Version 1
495+
# since data() is not being build up in this module, we need to create a reactive that will
496+
# return the plot in the reactive teal_data()
497+
validation_checks()
498+
obj <- data()
499+
env <- new.env()
500+
assign("plot", variable_plot_r(), envir = env)
501+
obj@.xData <- rlang::env_clone(env)
502+
teal.reporter::teal_card(obj) <-
503+
c(
504+
teal.reporter::teal_card("# Variable Browser Plot"),
505+
teal.reporter::teal_card(obj),
506+
teal.reporter::teal_card("## Module's code")
507+
)
508+
teal.code::eval_code(obj, "plot")
509+
510+
511+
# VERSION 2
512+
# validation_checks()
513+
# teal.data::teal_data(plot = variable_plot_r()) |> teal.code::eval_code("plot")
514+
})
519515
})
520516
}
521517

0 commit comments

Comments
 (0)