0

I am using shinymanager package to control access to data. Also, the users are the first category in the dependent drop downs. One of the users has access to all the data, so the first selection will show all the users. The remaining users will have the selection restricted only to one item, themselves.

In the ui section I will have:

              selectInput(
                 "sm",
                 "Select manager:",
                 choices = NULL,
                 multiple = FALSE
               ), 
              
               
               selectInput(
                 "rp",
                 "Select representative:",
                 choices = NULL,
                 multiple = FALSE
               ),
               
               selectInput(
                 "p_lev5",
                 "Select group level 5:",
                 choices = NULL,
                 multiple = FALSE
               ),
               
               selectInput(
                 "p_min",
                 "Select group minor:",
                 choices = NULL,
                 multiple = FALSE
               ),

And in the render section I will have:

   observeEvent(input$sm, {
  updateSelectInput(session, "sm", "Select manager:",
                    choices =
                      
                      if (reactiveValuesToList(result_auth)$user == "all") {
                        unique(df_groups$sm)
                      } else if (reactiveValuesToList(result_auth)$user != "all") {
                        reactiveValuesToList(result_auth)$user
                      })
})


observeEvent(input$sm, {
  updateSelectInput(session, "rp", "Select representative:",
                    choices =
                      
                      df_groups[df_groups$sm == input$sm,]$rp)
})

observeEvent(input$rp, {
  updateSelectInput(session, "p_lev5", "Select group major",
                    choices = df_groups[df_groups$rp == input$rp,]$p_lev5)
})

observeEvent(input$p_lev5, {
  updateSelectInput(session, "p_min", "Select group minor:",
                    choices = df_groups[df_groups$p_lev5 == input$p_lev5,]$p_min)
})

If I hard code the first selection, the dependent dropdowns work correctly. If I move the first selection to be the second or the third selection, the dropdowns work correctly and the sales representative is correctly put in from the log in entry.

However it is incorrect to expect an event in the first level of the drop down list. It must be an operation executed only once on start-up of shiny app.

What should be the syntax or a function to populate the first dropdown if I am using a shinymanager ui and it seems to reveal the user credentials only in some reactive context?

Jacek Kotowski
  • 620
  • 16
  • 49

0 Answers0