-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add reporter #635
add reporter #635
Changes from all commits
ddef912
f43c41f
35b317c
8e52770
0cb656d
d34305c
caad0b4
d9443fb
c0b6fc8
378b9ca
93abc49
d8358a6
2515176
b6fee4c
29b5d3e
f4d1898
70ae4d8
6a42612
9233441
a82cdb7
dcedbea
06f2fae
2c48145
ee89b81
c2eadcb
bada2e2
3d27837
13fc537
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,51 @@ modules <- function(..., label = "root") { | |
} | ||
|
||
|
||
|
||
#' 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` | ||
#' @return `teal_modules` object with `module` appended | ||
append_module <- function(modules, module) { | ||
checkmate::assert_class(modules, "teal_modules") | ||
checkmate::assert_class(module, "teal_module") | ||
modules$children <- c(modules$children, list(module)) | ||
labels <- vapply(modules$children, function(submodule) submodule$label, character(1)) | ||
names(modules$children) <- make.unique(gsub("[^[:alnum:]]", "_", tolower(labels)), sep = "_") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In what capacity are the names of the modules used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you plan on testing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My suspicion is it is to do with knowing which module is active so that a signal can be sent to the filter panel when they change. @gogonzo ?
Erm, This is copied from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test written let me know if you want more |
||
modules | ||
} | ||
|
||
#' Does the object make use of `teal.reporter` reporting | ||
#' @param modules `teal_module` or `teal_modules` object | ||
#' @return `logical` whether the object makes use of `teal.reporter` reporting | ||
#' @rdname is_reporter_used | ||
#' @keywords internal | ||
is_reporter_used <- function(modules) { | ||
UseMethod("is_reporter_used", modules) | ||
} | ||
|
||
#' @rdname is_reporter_used | ||
#' @keywords internal | ||
is_reporter_used.default <- function(modules) { | ||
stop("is_reporter_used function not implemented for this object") | ||
} | ||
|
||
#' @rdname is_reporter_used | ||
#' @export | ||
#' @keywords internal | ||
is_reporter_used.teal_modules <- function(modules) { | ||
any(unlist(lapply(modules$children, function(x) is_reporter_used(x)))) | ||
} | ||
|
||
#' @rdname is_reporter_used | ||
#' @export | ||
#' @keywords internal | ||
is_reporter_used.teal_module <- function(modules) { | ||
"reporter" %in% names(formals(modules$server)) | ||
} | ||
|
||
|
||
#' Deprecated: Creates the root modules container | ||
#' | ||
#' @description `r lifecycle::badge("deprecated")` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#' Create a `teal` module for previewing a report | ||
#' | ||
#' This function wraps [teal.reporter::reporter_previewer_ui()] and | ||
#' [teal.reporter::reporter_previewer_srv()] into a `teal_module` to be | ||
#' used in `teal` applications. | ||
#' | ||
#' 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 | ||
#' | ||
#' @inheritParams module | ||
#' @return `teal_module` containing the `teal.reporter` previewer functionality | ||
#' @export | ||
reporter_previewer_module <- function(label = "Report previewer") { | ||
checkmate::assert_string(label) | ||
srv <- function(id, datasets, reporter, ...) { | ||
teal.reporter::reporter_previewer_srv(id, reporter, ...) | ||
} | ||
|
||
ui <- function(id, datasets, ...) { | ||
teal.reporter::reporter_previewer_ui(id, ...) | ||
} | ||
|
||
module( | ||
label = label, | ||
server = srv, ui = ui, | ||
server_args = list(), ui_args = list(), filters = NULL | ||
nikolas-burkoff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be done before ui_tabs_with_filters (~ 20 lines below) so that the previewer ui is appended before being called