R/mod_date_area.R

Defines functions mod_date_area_server mod_date_area_ui

#' date_area UI Function
#'
#' @description Module for the top set of filters in the catch_area_site selects.
#'
#' @param id, input, output, session Internal parameters for {shiny}.
#'
#' @noRd 
#'
#' @importFrom shiny NS tags div br uiOutput img renderUI
#' @importFrom shinyWidgets pickerInput pickerOptions
mod_date_area_ui <- function(id) {
  tags$div(
    uiOutput(NS(id, "year_select")),
    br(),
    uiOutput(NS(id, "month_select")),
    br(),
    uiOutput(NS(id, "crc_select")),
    br()
  )
}
    
#' date_area Server Function
#'
#' @noRd 
mod_date_area_server <- function(id) {
  moduleServer(id, function(input, output, session) {
    ns <- session$ns
    
    # Get year or years of surveys (need multiple if straddeling Dec-Jan)
    output$year_select = renderUI({
      year_list = seq(2018, 1986)
      pickerInput(ns("year_select"), label = "Select the survey year(s)",
                  choices = year_list,
                  selected = year_list[2],
                  multiple = TRUE,
                  width = "100%",
                  options = pickerOptions(actionsBox = TRUE) )
    })
    
    # Select set of survey months
    output$month_select = renderUI({
      month_list = month.name
      pickerInput(ns("month_select"), label = "Select the survey month(s)",
                  choices = month_list,
                  selected = month_list[1],
                  multiple = TRUE,
                  width = "100%",
                  options = pickerOptions(actionsBox = TRUE) )
    })
    
    # Get CRC areas that have surveys in selected years and months
    output$crc_select = renderUI({
      crc_list = get_crc_list()$crc_name
      pickerInput(ns("crc_select"),
                  label = "Select Catch Area(s)",
                  multiple = TRUE,
                  choices = crc_list,
                  selected = "Area 7, San Juan Islands",
                  width = "100%",
                  options = pickerOptions(actionsBox = TRUE) )
    })
    
    # Output reactive list
    reactive({
      list(
        yr = input$year_select,
        mn = input$month_select,
        cr = input$crc_select )
    })
  })
}
arestrom/BaselineData documentation built on Sept. 28, 2020, 9:38 a.m.