I am trying to use the shinyFiles library in my shinyApp to give the user the option to select a group of files or a directory. My idea is to use uiOutput, which varies depending on the checkbox selected.
Here I am reporting a code, perhaps more explanatory than words
UtilityUI <- fluidPage(
titlePanel("page1"),
fluidRow(
column(2,
wellPanel(
tags$p("Check the box below if you want to choose an entire directory"),
checkboxInput(inputId = 'directory_flag', label = 'Directory path?', value = FALSE),
uiOutput("input_selection_ui")
)
),
column(8
)
)
)
UtilityServer <- function(input, output, session) {
output$input_selection_ui <- renderUI({
if(input$directory_flag == TRUE) {
shinyDirButton(id = "infiles", label = "Choose directory", title = "Choose a directory")
} else {
shinyFilesButton(id = "infiles", label = "Choose file(s)", title = "Choose one or more files", multiple = TRUE)
}
})
shinyFileChoose(input, 'infiles', roots=getVolumes(), session=session, restrictions=system.file(package='base'))
shinyDirChoose(input, 'infiles', roots=getVolumes(), session=session, restrictions=system.file(package='base'))
}
shinyApp(UtilityUI, UtilityServer)
The problem occurs when the "shinyFiles" button is pressed: the popup does not load the roots in both cases (shinyDirButton and shinyFilesButton).
If I do not use the uiOutput function, everything works fine ... But in this case, I cannot change my UI dynamically ...
Thanks so much for your answers,
Inzirio