R/fct_handle_save_holidays.R

Defines functions handle_save_holidays

handle_save_holidays <- function(rv, input) {
  
  new_contents <- input$holidays_area
  if (stringr::str_sub(new_contents, -1, -1) != '\n') {
    # Add final new line (in case user deleted it)
    # This new line will also make load_holidays handle
    # the contents of the text area as a vector, not as
    # a file name.
    new_contents <- paste0(new_contents, '\n')
  }
  rv$holidays_csv <- new_contents
  rv$holidays_df <- load_holidays(rv$holidays_csv) %>% 
    expand_holidays()
  shiny::removeModal()
  
}
fnaufel/PlanneR documentation built on March 19, 2022, 4:10 p.m.