Skip to content

Commit

Permalink
treecheckInput: allow to pass parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Feb 25, 2022
1 parent c3fc08a commit 2370b0f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
35 changes: 18 additions & 17 deletions R/input-treecheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @inheritParams treeviewInput
#' @param hierarchical When a level is selected, also select all levels below it?
#'
#' @return Server-side: A \code{character} value or a \code{list} depending on the \code{return_value} argument.
#' @return Server-side: A `character` value or a `list` depending on the `return_value` argument.
#' @export
#'
#' @importFrom htmltools tags validateCssUnit htmlDependencies
Expand All @@ -19,27 +19,28 @@ treecheckInput <- function(inputId,
hierarchical = TRUE,
levels = 1,
borders = TRUE,
...,
return_value = c("name", "id", "all"),
width = NULL) {
selected <- shiny::restoreInput(id = inputId, default = selected)
return_value <- match.arg(return_value)
config <- list(
data = choices,
levels = levels,
showBorder = borders,
showCheckbox = TRUE,
highlightSelected = FALSE,
propagateCheckEvent = hierarchical,
hierarchicalCheck = hierarchical,
uncheckedIcon = "fa fa-square-o",
partiallyCheckedIcon = "fa fa-minus-square-o",
checkedIcon = "fa fa-check-square-o",
expandIcon = "fa fa-chevron-right",
collapseIcon = "fa fa-chevron-down",
...
)
options <- dropNulls(list(
config = c(
list(
data = choices,
levels = levels,
showBorder = borders,
showCheckbox = TRUE,
highlightSelected = FALSE,
propagateCheckEvent = hierarchical,
hierarchicalCheck = hierarchical,
uncheckedIcon = "fa fa-square-o",
partiallyCheckedIcon = "fa fa-minus-square-o",
checkedIcon = "fa fa-check-square-o",
expandIcon = "fa fa-chevron-right",
collapseIcon = "fa fa-chevron-down"
)
),
config = config[!duplicated(names(config), fromLast = TRUE)],
selected = list1(selected)
))

Expand Down
3 changes: 3 additions & 0 deletions man/treecheckInput.Rd

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

0 comments on commit 2370b0f

Please sign in to comment.