From cb7da4a4769e5358a631297ef7ea769badd47145 Mon Sep 17 00:00:00 2001 From: metanoid Date: Sat, 27 Feb 2016 14:04:53 +0200 Subject: [PATCH 1/6] testing id change on menuItem --- R/dashboardSidebar.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/dashboardSidebar.R b/R/dashboardSidebar.R index 8e2068e8..43605d49 100644 --- a/R/dashboardSidebar.R +++ b/R/dashboardSidebar.R @@ -250,7 +250,7 @@ sidebarMenu <- function(..., id = NULL, .list = NULL) { #' @rdname sidebarMenu #' @export menuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "green", - tabName = NULL, href = NULL, newtab = TRUE, selected = NULL) { + tabName = NULL, href = NULL, newtab = TRUE, selected = NULL, id = NULL) { subItems <- list(...) if (!is.null(icon)) tagAssert(icon, type = "i") @@ -291,7 +291,7 @@ menuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "gr # If no subitems, return a pretty simple tag object if (length(subItems) == 0) { return( - tags$li( + tags$li(id = id, a(href = href, `data-toggle` = if (isTabItem) "tab", `data-value` = if (!is.null(tabName)) tabName, @@ -305,7 +305,7 @@ menuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "gr ) } - tags$li(class = "treeview", + tags$li(class = "treeview", id = id, a(href = href, icon, span(text), From 6d8b6dbbfbc8c09709ae25b9e7a72a4c55a8ee5d Mon Sep 17 00:00:00 2001 From: metanoid Date: Sat, 27 Feb 2016 14:09:22 +0200 Subject: [PATCH 2/6] Adding id to menusubitem --- R/dashboardSidebar.R | 4 ++-- tests-manual/dashboardSidebar.R | 11 +++++++---- tests-manual/renderMenu.R | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/R/dashboardSidebar.R b/R/dashboardSidebar.R index 43605d49..6073da68 100644 --- a/R/dashboardSidebar.R +++ b/R/dashboardSidebar.R @@ -320,7 +320,7 @@ menuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "gr #' @rdname sidebarMenu #' @export menuSubItem <- function(text, tabName = NULL, href = NULL, newtab = TRUE, - icon = shiny::icon("angle-double-right"), selected = NULL) + icon = shiny::icon("angle-double-right"), selected = NULL, id = NULL) { if (!is.null(href) && !is.null(tabName)) { @@ -343,7 +343,7 @@ menuSubItem <- function(text, tabName = NULL, href = NULL, newtab = TRUE, } - tags$li( + tags$li( id = id, a(href = href, `data-toggle` = if (isTabItem) "tab", `data-value` = if (!is.null(tabName)) tabName, diff --git a/tests-manual/dashboardSidebar.R b/tests-manual/dashboardSidebar.R index e8bcf179..c0acab60 100644 --- a/tests-manual/dashboardSidebar.R +++ b/tests-manual/dashboardSidebar.R @@ -16,20 +16,23 @@ sidebar <- dashboardSidebar( menuItem( "Dashboard", tabName = "dashboard", - icon = icon("dashboard") + icon = icon("dashboard"), + id = "dashboardmenuitem" ), menuItem( "Widgets", icon = icon("th"), tabName = "widgets", badgeLabel = "new", - badgeColor = "green" + badgeColor = "green", + id = "widgetsmenuitem" ), menuItem( "Charts", icon = icon("bar-chart-o"), - menuSubItem("Sub-item 1", tabName = "subitem1"), - menuSubItem("Sub-item 2", tabName = "subitem2") + menuSubItem("Sub-item 1", tabName = "subitem1", id = "subitem1menuitem"), + menuSubItem("Sub-item 2", tabName = "subitem2", id = "subitem2menuitem"), + id = "chartsmenuitem" ) ) ) diff --git a/tests-manual/renderMenu.R b/tests-manual/renderMenu.R index 5bc5b227..8aa7e341 100644 --- a/tests-manual/renderMenu.R +++ b/tests-manual/renderMenu.R @@ -12,7 +12,7 @@ ui <- dashboardPage( server <- function(input, output) { output$menu <- renderMenu({ sidebarMenu( - menuItem("Menu item", icon = icon("calendar")) + menuItem("Menu item", icon = icon("calendar"), id = "aaa") ) }) } From 51dbffccfa626f8101aa4ef1b67a61d45a6bc866 Mon Sep 17 00:00:00 2001 From: metanoid Date: Mon, 29 Feb 2016 22:12:30 +0200 Subject: [PATCH 3/6] Added documentation fix thanks to comments from @dmpe --- R/dashboardSidebar.R | 3 ++- man/sidebarMenu.Rd | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/R/dashboardSidebar.R b/R/dashboardSidebar.R index 6073da68..fc3f29fe 100644 --- a/R/dashboardSidebar.R +++ b/R/dashboardSidebar.R @@ -212,7 +212,8 @@ sidebarSearchForm <- function(textId, buttonId, label = "Search...", #' @param id For \code{sidebarMenu}, if \code{id} is present, this id will be #' used for a Shiny input value, and it will report which tab is selected. For #' example, if \code{id="tabs"}, then \code{input$tabs} will be the -#' \code{tabName} of the currently-selected tab. +#' \code{tabName} of the currently-selected tab. For \code{menuItem} and +#' \code{menuSubItem}, the id is used as the id of the tag object created. #' @param icon An icon tag, created by \code{\link[shiny]{icon}}. If #' \code{NULL}, don't display an icon. #' @param badgeLabel A label for an optional badge. Usually a number or a short diff --git a/man/sidebarMenu.Rd b/man/sidebarMenu.Rd index 7623f017..aa83d061 100644 --- a/man/sidebarMenu.Rd +++ b/man/sidebarMenu.Rd @@ -9,10 +9,11 @@ sidebarMenu(..., id = NULL, .list = NULL) menuItem(text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "green", - tabName = NULL, href = NULL, newtab = TRUE, selected = NULL) + tabName = NULL, href = NULL, newtab = TRUE, selected = NULL, + id = NULL) menuSubItem(text, tabName = NULL, href = NULL, newtab = TRUE, - icon = shiny::icon("angle-double-right"), selected = NULL) + icon = shiny::icon("angle-double-right"), selected = NULL, id = NULL) } \arguments{ \item{...}{For menu items, this may consist of \code{\link{menuSubItem}}s.} @@ -20,7 +21,8 @@ menuSubItem(text, tabName = NULL, href = NULL, newtab = TRUE, \item{id}{For \code{sidebarMenu}, if \code{id} is present, this id will be used for a Shiny input value, and it will report which tab is selected. For example, if \code{id="tabs"}, then \code{input$tabs} will be the -\code{tabName} of the currently-selected tab.} +\code{tabName} of the currently-selected tab. For \code{menuItem} and +\code{menuSubItem}, the id is used as the id of the tag object created.} \item{.list}{An optional list containing items to put in the menu Same as the \code{...} arguments, but in list format. This can be useful when working From c626b39ae87413b4109c680e4416ccbde0cc3fb5 Mon Sep 17 00:00:00 2001 From: metanoid Date: Wed, 6 Jul 2016 13:06:38 +0200 Subject: [PATCH 4/6] Added optional id parameter to box, infoBox and valueBox, to allow for use by shinyjs::hide --- R/boxes.R | 12 +++++++++--- man/box.Rd | 4 +++- man/infoBox.Rd | 4 +++- man/valueBox.Rd | 4 +++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/R/boxes.R b/R/boxes.R index 4f287ec9..3fbb32e6 100644 --- a/R/boxes.R +++ b/R/boxes.R @@ -11,13 +11,14 @@ #' @param color A color for the box. Valid colors are listed in #' \link{validColors}. #' @param href An optional URL to link to. +#' @param id An optional id for the element #' #' @family boxes #' @seealso \code{\link{box}} for usage examples. #' #' @export valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, - href = NULL) + href = NULL, id = NULL) { validateColor(color) if (!is.null(icon)) tagAssert(icon, type = "i") @@ -34,6 +35,7 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, boxContent <- a(href = href, boxContent) div(class = if (!is.null(width)) paste0("col-sm-", width), + id = id, boxContent ) } @@ -58,6 +60,7 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, #' content; the icon will use the same color with a slightly darkened #' background. #' @param href An optional URL to link to. +#' @param id An optional id for the element #' #' @family boxes #' @seealso \code{\link{box}} for usage examples. @@ -65,7 +68,7 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, #' @export infoBox <- function(title, value = NULL, subtitle = NULL, icon = shiny::icon("bar-chart"), color = "aqua", width = 4, href = NULL, - fill = FALSE) { + fill = FALSE, id = id) { validateColor(color) tagAssert(icon, type = "i") @@ -91,6 +94,7 @@ infoBox <- function(title, value = NULL, subtitle = NULL, boxContent <- a(href = href, boxContent) div(class = if (!is.null(width)) paste0("col-sm-", width), + id = id, boxContent ) } @@ -119,6 +123,7 @@ infoBox <- function(title, value = NULL, subtitle = NULL, #' the user to collapse the box. #' @param collapsed If TRUE, start collapsed. This must be used with #' \code{collapsible=TRUE}. +#' @param id An optional id for the element #' @param ... Contents of the box. #' #' @family boxes @@ -250,7 +255,7 @@ infoBox <- function(title, value = NULL, subtitle = NULL, #' @export box <- function(..., title = NULL, footer = NULL, status = NULL, solidHeader = FALSE, background = NULL, width = 6, - height = NULL, collapsible = FALSE, collapsed = FALSE) { + height = NULL, collapsible = FALSE, collapsed = FALSE, id = NULL) { boxClass <- "box" if (solidHeader || !is.null(background)) { @@ -301,6 +306,7 @@ box <- function(..., title = NULL, footer = NULL, status = NULL, } div(class = if (!is.null(width)) paste0("col-sm-", width), + id = id, div(class = boxClass, style = if (!is.null(style)) style, headerTag, diff --git a/man/box.Rd b/man/box.Rd index 9626aaf0..f8e5906c 100644 --- a/man/box.Rd +++ b/man/box.Rd @@ -6,7 +6,7 @@ \usage{ box(..., title = NULL, footer = NULL, status = NULL, solidHeader = FALSE, background = NULL, width = 6, height = NULL, - collapsible = FALSE, collapsed = FALSE) + collapsible = FALSE, collapsed = FALSE, id = NULL) } \arguments{ \item{...}{Contents of the box.} @@ -38,6 +38,8 @@ the user to collapse the box.} \item{collapsed}{If TRUE, start collapsed. This must be used with \code{collapsible=TRUE}.} + +\item{id}{An optional id for the element} } \description{ Boxes can be used to hold content in the main body of a dashboard. diff --git a/man/infoBox.Rd b/man/infoBox.Rd index e2695477..59f6bcdc 100644 --- a/man/infoBox.Rd +++ b/man/infoBox.Rd @@ -6,7 +6,7 @@ \usage{ infoBox(title, value = NULL, subtitle = NULL, icon = shiny::icon("bar-chart"), color = "aqua", width = 4, - href = NULL, fill = FALSE) + href = NULL, fill = FALSE, id = id) } \arguments{ \item{title}{Title text.} @@ -33,6 +33,8 @@ content, and the \code{color} argument for the background of the icon. If \code{TRUE}, use the \code{color} argument for the background of the content; the icon will use the same color with a slightly darkened background.} + +\item{id}{An optional id for the element} } \description{ An info box displays a large icon on the left side, and a title, value diff --git a/man/valueBox.Rd b/man/valueBox.Rd index a79faf03..98df72d9 100644 --- a/man/valueBox.Rd +++ b/man/valueBox.Rd @@ -5,7 +5,7 @@ \title{Create a value box for the main body of a dashboard.} \usage{ valueBox(value, subtitle, icon = NULL, color = "aqua", width = 4, - href = NULL) + href = NULL, id = NULL) } \arguments{ \item{value}{The value to display in the box. Usually a number or short text.} @@ -24,6 +24,8 @@ layouts, use \code{NULL} for the width; the width is set by the column that contains the box.} \item{href}{An optional URL to link to.} + +\item{id}{An optional id for the element} } \description{ A value box displays a value (usually a number) in large text, with a smaller From d4a4cdef33de1f05c4747a1941f0d62eb33c3a0d Mon Sep 17 00:00:00 2001 From: Colin Phillips Date: Wed, 14 Mar 2018 10:07:27 +0200 Subject: [PATCH 5/6] Added fix suggested by @Eli-Berkow Good catch - thanks! --- R/boxes.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/boxes.R b/R/boxes.R index 3fbb32e6..b130c903 100644 --- a/R/boxes.R +++ b/R/boxes.R @@ -68,7 +68,7 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, #' @export infoBox <- function(title, value = NULL, subtitle = NULL, icon = shiny::icon("bar-chart"), color = "aqua", width = 4, href = NULL, - fill = FALSE, id = id) { + fill = FALSE, id = NULL) { validateColor(color) tagAssert(icon, type = "i") From 9c213ea3baad1c9be15497d3a227b0f4c0c5f4a1 Mon Sep 17 00:00:00 2001 From: Colin Phillips Date: Wed, 14 Mar 2018 10:13:44 +0200 Subject: [PATCH 6/6] Also updating documentation to match --- man/infoBox.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/infoBox.Rd b/man/infoBox.Rd index a58cb80c..e439c882 100644 --- a/man/infoBox.Rd +++ b/man/infoBox.Rd @@ -6,7 +6,7 @@ \usage{ infoBox(title, value = NULL, subtitle = NULL, icon = shiny::icon("bar-chart"), color = "aqua", width = 4, - href = NULL, fill = FALSE, id = id) + href = NULL, fill = FALSE, id = NULL) } \arguments{ \item{title}{Title text.}