Skip to content

Commit

Permalink
updating get_choices function. (#282)
Browse files Browse the repository at this point in the history
extension to insightsengineering/teal.osprey#276

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dawid Kałędkowski <6959016+gogonzo@users.noreply.github.com>
  • Loading branch information
3 people committed Jul 3, 2024
1 parent 5faa22d commit 4229578
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
15 changes: 14 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,27 @@ report_card_template_goshawk <- function(title,
#'
#' This function returns choices based on the class of the input.
#' If the input is of class `delayed_data`, it returns the `subset` of the input.
#' If `subset` is NULL and the input contains `var_label` and `var_choices`,
#' it throws an error prompting to resolve delayed inputs.
#' Otherwise, it returns the input as is.
#'
#' @param choices An object that contains choices.
#' @return A vector of choices.
#' @keywords internal
get_choices <- function(choices) {
if (inherits(choices, "delayed_data")) {
choices$subset
if (is.null(choices$subset)) {
if (!is.null(choices$var_label) && !is.null(choices$var_choices)) {
stop(
"Resolve delayed inputs by evaluating the code within the provided datasets.
Check ?teal.transform::resolve_delayed for more information."
)
} else {
stop("Subset is NULL and necessary fields are missing.")
}
} else {
choices$subset
}
} else {
choices
}
Expand Down
2 changes: 2 additions & 0 deletions man/get_choices.Rd

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

0 comments on commit 4229578

Please sign in to comment.