Skip to content

Commit

Permalink
feat: adds extra parameters to methods that use it
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Mar 21, 2024
1 parent 90cf513 commit 59f9de0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
39 changes: 30 additions & 9 deletions R/TealAppDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,16 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
#'
#' @param input_id (character) The shiny input id to get the value from.
#' @param value The value to set the input to.
#' @param ... Additional arguments to be passed to `shinytest2::AppDriver$set_inputs`
#'
#' @return The `TealAppDriver` object invisibly.
set_module_input = function(input_id, value) {
set_module_input = function(input_id, value, ...) {
checkmate::check_string(input_id)
checkmate::check_string(value)
self$set_input(
sprintf("%s-%s", self$active_module_ns(), input_id),
value
value,
...
)
invisible(self)
},
Expand Down Expand Up @@ -264,9 +266,10 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
#'
#' @param dataset_name (character) The name of the dataset to add the filter variable to.
#' @param var_name (character) The name of the variable to add to the filter panel.
#' @param ... Additional arguments to be passed to `shinytest2::AppDriver$set_inputs`
#'
#' @return The `TealAppDriver` object invisibly.
add_filter_var = function(dataset_name, var_name) {
add_filter_var = function(dataset_name, var_name, ...) {
checkmate::check_string(dataset_name)
checkmate::check_string(var_name)
self$set_input(
Expand All @@ -275,7 +278,8 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
self$active_filters_ns(),
dataset_name
),
var_name
var_name,
...
)
invisible(self)
},
Expand Down Expand Up @@ -322,10 +326,13 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
#' @param dataset_name (character) The name of the dataset to set the filter value for.
#' @param var_name (character) The name of the variable to set the filter value for.
#' @param input The value to set the filter to.
#' @param type (character) The type of the filter to get the value from. Default is `categorical`.
#' @param ... Additional arguments to be passed to `shinytest2::AppDriver$set_inputs`
#'
#' @return The `TealAppDriver` object invisibly.
set_active_filter_selection = function(dataset_name, var_name, input) {
set_active_filter_selection = function(dataset_name,
var_name,
input,
...) {
checkmate::check_string(dataset_name)
checkmate::check_string(var_name)
checkmate::check_string(input)
Expand Down Expand Up @@ -365,16 +372,30 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.

if (identical(slices_suffix, "selection_manual")) {
checkmate::assert_numeric(input, len = 2)
extra_formals <- formals(app$set_inputs)

checkmate::assert_choice(dots$priority_, formals(self$set_inputs))

dots <- rlang::list2(...)
self$run_js(
sprintf(
"Shiny.setInputValue('%s:sw.numericRange', [%f, %f], {priority: 'event'})",
"Shiny.setInputValue('%s:sw.numericRange', [%f, %f], {priority: '%s'})",
slices_input_id,
input[[1]],
input[[2]]
input[[2]],
priority_ = dplyr::coalesce(dots$priority_, "input", .size = 1)
)
)
self$wait_for_idle(
wait = dplyr::coalesce(dots$wait_, TRUE, .size = 1),
timeout = dplyr::coalesce(dots$timeout_, private$timeout, .size = 1)
)
} else if (identical(slices_suffix, "selection")) {
self$set_input(slices_input_id, input)
self$set_input(
slices_input_id,
input,
...
)
} else {
stop("Filter selection set not supported for this slice.")
}
Expand Down
12 changes: 8 additions & 4 deletions man/TealAppDriver.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 59f9de0

Please sign in to comment.