From 3a3061e948efd973236b8a8dc3cd6a5cb17f0c3a Mon Sep 17 00:00:00 2001 From: Mauro Masiero Date: Wed, 13 Mar 2024 11:31:46 +0100 Subject: [PATCH 1/3] add header option to wizard --- R/wizard.R | 12 +++++++++++- man/wizard.Rd | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/R/wizard.R b/R/wizard.R index 2121d76..688174f 100644 --- a/R/wizard.R +++ b/R/wizard.R @@ -15,6 +15,8 @@ #' @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 header show header or not (TRUE or FALSE) +#' @param header_title header title #' @param options A list of options. See the documentation of #' 'Wizard-JS' () for #' possible options. @@ -27,10 +29,12 @@ wizard <- function( show_buttons = TRUE, id = NULL, modal = TRUE, - height = 60, + height = 50, width = 90, flex = TRUE, lock_start = FALSE, + header = TRUE, + header_title = "Wizard", options = list()) { # check inputs orientation <- match.arg(orientation, c("horizontal", "vertical")) @@ -158,6 +162,12 @@ wizard <- function( ui <- ( bsutils::modal( id = sprintf("wizard-modal-%s", id), + if(header){ + bsutils::modalHeader( + title = header_title, + close_button = TRUE + ) + }, bsutils::modalBody(ui), size = bs_size, htmltools::tags$head( diff --git a/man/wizard.Rd b/man/wizard.Rd index 10ed176..f9f8b61 100644 --- a/man/wizard.Rd +++ b/man/wizard.Rd @@ -11,10 +11,12 @@ wizard( show_buttons = TRUE, id = NULL, modal = TRUE, - height = 60, + height = 50, width = 90, flex = TRUE, lock_start = FALSE, + header = TRUE, + header_title = "Wizard", options = list() ) } @@ -39,6 +41,10 @@ wizard( \item{lock_start}{lock the wizard at the start (TRUE or FALSE)} +\item{header}{show header or not (TRUE or FALSE)} + +\item{header_title}{header title} + \item{options}{A list of options. See the documentation of 'Wizard-JS' () for possible options.} From de7ba621d037a6beffda21007cff9f92558cdbbc Mon Sep 17 00:00:00 2001 From: Mauro Masiero Date: Wed, 13 Mar 2024 11:35:27 +0100 Subject: [PATCH 2/3] add static backdrop option --- R/wizard.R | 17 +++++++++++++---- man/wizard.Rd | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/R/wizard.R b/R/wizard.R index 688174f..aa38bc6 100644 --- a/R/wizard.R +++ b/R/wizard.R @@ -17,6 +17,7 @@ #' @param lock_start lock the wizard at the start (TRUE or FALSE) #' @param header show header or not (TRUE or FALSE) #' @param header_title header title +#' @param static_backdrop static backdrop or not (TRUE or FALSE) #' @param options A list of options. See the documentation of #' 'Wizard-JS' () for #' possible options. @@ -35,6 +36,7 @@ wizard <- function( lock_start = FALSE, header = TRUE, header_title = "Wizard", + static_backdrop = TRUE, options = list()) { # check inputs orientation <- match.arg(orientation, c("horizontal", "vertical")) @@ -62,11 +64,16 @@ wizard <- function( stop("lock_start must be logical") } - # TODO fix static_backdrop + # check if static_backdrop is logical - # if(!is.logical(static_backdrop)){ - # stop("static_backdrop must be logical") - # } + if(!is.logical(static_backdrop)){ + stop("static_backdrop must be logical") + } + + # check if header is logical + if (!is.logical(header)) { + stop("header must be logical") + } if (is.numeric(width)) { bs_size <- "default" @@ -162,6 +169,8 @@ wizard <- function( ui <- ( bsutils::modal( id = sprintf("wizard-modal-%s", id), + static_backdrop = TRUE, + if(header){ bsutils::modalHeader( title = header_title, diff --git a/man/wizard.Rd b/man/wizard.Rd index f9f8b61..9579f74 100644 --- a/man/wizard.Rd +++ b/man/wizard.Rd @@ -17,6 +17,7 @@ wizard( lock_start = FALSE, header = TRUE, header_title = "Wizard", + static_backdrop = TRUE, options = list() ) } @@ -45,6 +46,8 @@ wizard( \item{header_title}{header title} +\item{static_backdrop}{static backdrop or not (TRUE or FALSE)} + \item{options}{A list of options. See the documentation of 'Wizard-JS' () for possible options.} From 7b9558fbde2deb2c2f2463a27f8e7885d0ac1fad Mon Sep 17 00:00:00 2001 From: Mauro Masiero Date: Wed, 13 Mar 2024 11:36:10 +0100 Subject: [PATCH 3/3] minor fix --- R/wizard.R | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/R/wizard.R b/R/wizard.R index aa38bc6..dc95eb7 100644 --- a/R/wizard.R +++ b/R/wizard.R @@ -169,8 +169,7 @@ wizard <- function( ui <- ( bsutils::modal( id = sprintf("wizard-modal-%s", id), - static_backdrop = TRUE, - + static_backdrop = static_backdrop, if(header){ bsutils::modalHeader( title = header_title, @@ -184,8 +183,6 @@ wizard <- function( htmltools::HTML(modal_width) ) ) - - # static_backdrop = FALSE #TODO file a github issue on static_backdrop ) ) }