R/ui_exportSidebarPane.R

Defines functions exportSidebarPane

Documented in exportSidebarPane

#' @include internal.R
NULL

#' Export sidebar pane
#'
#' Constructs a sidebar pane for exporting data.
#'
#' @inheritParams solutionResultsSidebarPane
#'
#' @inherit importModal examples
#'
#' @inherit solutionResultsSidebarPane details return
#'
#' @export
exportSidebarPane <- function(id) {
  # assert arguments are valid
  assertthat::assert_that(
    assertthat::is.string(id),
    assertthat::noNA(id)
  )

  # create sidebar
  leaflet.extras2::sidebar_pane(
    title = "Download data",
    id = id,
    icon = NULL,

    # sidebar pane content
    htmltools::tags$div(
      class = "sidebar-pane-content",
      htmltools::tags$script(paste0("
        $('a[href=\"#", id, "\"]').tooltip({
          container: 'body',
          trigger: 'hover',
          placement: 'right',
          title: 'Open sidebar for downloading data and solutions'
        });
      ")),
      htmltools::tags$div(
        class = "sidebar-pane-inner",
        htmltools::tags$div(
          class = "generic-container",

          ## select columns
          shiny::selectizeInput(
            inputId = paste0(id, "_fields"),
            label = "Select data and solutions to download",
            choices = c(),
            multiple = TRUE,
            options = list(placeholder = "select data (required)"),
            width = "100%"
          ),

          ## upload button
          htmltools::tags$div(
            class = "col text-center",
            shiny::downloadButton(
              outputId = paste0(id, "_button"),
              label = "Download",
              class = "btn-primary btn-block",
              icon = shiny::icon("download")
            )
          )
        )
      )
    )
  )
}
NCC-CNC/wheretowork documentation built on Feb. 27, 2025, 6:11 p.m.