R/file_upload.R

Defines functions file_upload_server file_upload_ui

Documented in file_upload_server file_upload_ui

#'
#' file Upload Module UI
#'
#' @description A file upload can be created to display local machine or hosted
#' directories to share information with the shiny application
#'
#' @param id is unique ID associated with the button for the UI namespace
#' @return HTML UI code for a shiny application
#'
#' @export


file_upload_ui <-
  function(id) {
    ns <- NS(id)
    uiOutput(ns("file-u"))
  }

#'
#' file Upload Module Server
#'
#' @description A file upload can be created to display local machine or hosted
#' directories to share information with the shiny application
#'
#' @param input list of inputs used in the shiny application session
#' @param output list of outputs used the shiny application session
#' @param session The shiny app session object
#' @param label The label of the file upload UI
#' @param accept The file extension to accept
#' @param multiple Can multiple items be shared.  Default FALSE
#' @param rl The reactive label for debugging
#' @return HTML UI code for a shiny application
#'
#' @export


file_upload_server <- function(input,
                               output,
                               session,
                               label = "Please upload the Excel file",
                               accept = c(".xlsx"),
                               multiple = F,
                               rl  = 'Input File Module') {

  session$ns->ns
  output[['file-u']]<-renderUI({fileInput(ns("file"), label,
                                          multiple = multiple,
                                          accept = accept)})

  return(list(selected = reactive(input$file, label = rl)))
}
HarryRosen/hrimodules documentation built on Jan. 11, 2022, 12:36 a.m.