Skip to content

Commit

Permalink
Merge pull request #12 from mauromiguelm/dev-lock-start
Browse files Browse the repository at this point in the history
Add optional lock parameter to wizard initialization
  • Loading branch information
mauromiguelm authored Feb 28, 2024
2 parents 005e375 + 4aa1655 commit a74b832
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion R/wizard.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' @param height height in vh
#' @param width width in vw or bootstrap size for modals (default, sm, lg, xl, fullscreen, fullscreen-sm-down, fullscreen-md-down, fullscreen-lg-down, fullscreen-xl-down, fullscreen-xxl-down)
#' @param flex Convert the wizard to a flex container (TRUE or FALSE). flex will convert display: block to display: flex and add the htmltools::bindFillRole attribute to the wizard content.
#' @param lock_start lock the wizard at the start (TRUE or FALSE)
#' @param options A list of options. See the documentation of
#' 'Wizard-JS' (<URL: https://github.com/AdrianVillamayor/Wizard-JS>) for
#' possible options.
Expand All @@ -29,6 +30,7 @@ wizard <- function(
height = 60,
width = 90,
flex = TRUE,
lock_start = FALSE,
options = list()) {
# check inputs
orientation <- match.arg(orientation, c("horizontal", "vertical"))
Expand All @@ -51,6 +53,11 @@ wizard <- function(
stop("flex must be logical")
}

# check if lock_start is logical
if (!is.logical(lock_start)) {
stop("lock_start must be logical")
}

# TODO fix static_backdrop
# check if static_backdrop is logical
# if(!is.logical(static_backdrop)){
Expand Down Expand Up @@ -90,7 +97,8 @@ wizard <- function(
list(
"wz_ori" = orientation,
"wz_nav_style" = style,
"buttons" = show_buttons
"buttons" = show_buttons,
"lock_start" = lock_start
),
options
)
Expand Down
1 change: 1 addition & 0 deletions inst/app/app-dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ui <- fluidPage(
actionButton("show_wizard", "Show wizard"),
wizard(
modal = TRUE,
lock_start = TRUE,
id = "my_modal",
# start sequence of steps
wizard_step(
Expand Down
4 changes: 4 additions & 0 deletions inst/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ $.extend(wizard, {
wizard.unlock();
}

if (args.lock_start) {
wizard.lock();
}

return wizard;
},

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

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

2 changes: 1 addition & 1 deletion tests/testthat/test-wizard.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_that("wizard returns the correct output", {

res <- jsonlite::parse_json(res)

testthat::expect_equal(res, list("wz_ori" = "horizontal", "wz_nav_style" = "dots", "buttons" = "true"))
testthat::expect_equal(res, list("wz_ori" = "horizontal", "wz_nav_style" = "dots", "buttons" = "true", "lock_start" = FALSE))


# this id is necessary for modal to work
Expand Down

0 comments on commit a74b832

Please sign in to comment.