Skip to content
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

updating get_choices function. #282

Merged
merged 5 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading