diff --git a/R/mod_expat_repat_server.R b/R/mod_expat_repat_server.R index 1fe6ed29..31b89385 100644 --- a/R/mod_expat_repat_server.R +++ b/R/mod_expat_repat_server.R @@ -9,15 +9,6 @@ mod_expat_repat_server <- function( params, providers ) { - selected_time_profile <- update_time_profile <- NULL - # nolint start: object_usage_linter. - c(selected_time_profile, update_time_profile) %<-% - mod_time_profile_server( - shiny::NS(id, "time_profile"), - params - ) - # nolint end - mod_reasons_server(shiny::NS(id, "reasons"), params, "expat_repat") shiny::moduleServer(id, function(input, output, session) { @@ -102,18 +93,6 @@ mod_expat_repat_server <- function( ) }) - # update the time profile - shiny::observe({ - params$time_profile_mappings[ - c( - "expat", - "repat_local", - "repat_nonlocal" - ) - ] <- selected_time_profile() - }) |> - shiny::bindEvent(selected_time_profile()) - # two reactiveValues to keep track of the slider values # shadow_params always stores a value for each item selectable by the dropdowns # params contains the returned values, and will contain the value from shadow_params if "include" is checked @@ -129,9 +108,6 @@ mod_expat_repat_server <- function( params }) - # update the selected time profile (all 3 will have the same value, so just use expat) - update_time_profile(p$time_profile_mappings[["expat"]]) - default_values <- list( expat = c(0.95, 1.0), repat_local = c(1.0, 1.05), diff --git a/R/mod_expat_repat_ui.R b/R/mod_expat_repat_ui.R index ef985e86..b2526347 100644 --- a/R/mod_expat_repat_ui.R +++ b/R/mod_expat_repat_ui.R @@ -65,7 +65,6 @@ mod_expat_repat_ui <- function(id) { ) ), mod_reasons_ui(ns("reasons")), - mod_time_profile_ui(ns("time_profile")), bs4Dash::box( collapsible = FALSE, headerBorder = FALSE, diff --git a/R/mod_mitigators_server.R b/R/mod_mitigators_server.R index a8f73a96..6da0818b 100644 --- a/R/mod_mitigators_server.R +++ b/R/mod_mitigators_server.R @@ -14,15 +14,6 @@ mod_mitigators_server <- function( mitigator_codes_lkup, peers ) { - selected_time_profile <- update_time_profile <- NULL - # nolint start: object_usage_linter - c(selected_time_profile, update_time_profile) %<-% - mod_time_profile_server( - shiny::NS(id, "time_profile"), - params - ) - # nolint end - config <- get_golem_config("mitigators_config")[[id]] activity_type <- config$activity_type @@ -39,7 +30,6 @@ mod_mitigators_server <- function( shiny::moduleServer(id, function(input, output, session) { slider_values <- shiny::reactiveValues() - time_profile_mappings <- shiny::reactiveValues() strategies <- shiny::reactive({ # make sure a provider is selected @@ -115,9 +105,6 @@ mod_mitigators_server <- function( } }) - tpm <- params$time_profile_mappings[[mitigators_type]][[activity_type]] - time_profile_mappings$mappings <- tpm - init$destroy() }, priority = 100 @@ -196,10 +183,6 @@ mod_mitigators_server <- function( "slider", value = values ) - - update_time_profile( - time_profile_mappings$mappings[[strategy]] %||% "linear" - ) }) |> shiny::bindEvent(input$strategy) @@ -220,18 +203,6 @@ mod_mitigators_server <- function( }) |> shiny::bindEvent(input$slider, input$include) - shiny::observe({ - strategy <- shiny::req(input$strategy) - tp <- shiny::req(selected_time_profile()) - - time_profile_mappings$mappings[[strategy]] <- tp - - params$time_profile_mappings[[mitigators_type]][[activity_type]][[ - strategy - ]] <- if (input$include) tp - }) |> - shiny::bindEvent(selected_time_profile(), input$include) - shiny::observe({ shinyjs::toggleState("slider", condition = input$include) }) |> diff --git a/R/mod_mitigators_ui.R b/R/mod_mitigators_ui.R index 3824e23d..3b166fc4 100644 --- a/R/mod_mitigators_ui.R +++ b/R/mod_mitigators_ui.R @@ -45,8 +45,7 @@ mod_mitigators_ui <- function(id, title, show_diagnoses_table = TRUE) { shiny::p(), shiny::htmlOutput(ns("slider_interval_text")) ), - mod_reasons_ui(ns("reasons")), - mod_time_profile_ui(ns("time_profile")), + mod_reasons_ui(ns("reasons")) ) ), col_8( diff --git a/R/mod_run_model_fix_params.R b/R/mod_run_model_fix_params.R index 26ac917e..4de82a2e 100644 --- a/R/mod_run_model_fix_params.R +++ b/R/mod_run_model_fix_params.R @@ -1,35 +1,4 @@ mod_run_model_fix_params <- function(p, schema_text) { - # the time profiles may be empty, ensure that's not the case - tpm <- p[["time_profile_mappings"]] - p[["time_profile_mappings"]][["activity_avoidance"]] <- list( - ip = tpm[["activity_avoidance"]][["ip"]] %||% list(), - op = tpm[["activity_avoidance"]][["op"]] %||% list(), - aae = tpm[["activity_avoidance"]][["aae"]] %||% list() - ) - p[["time_profile_mappings"]][["efficiencies"]] <- list( - ip = tpm[["efficiencies"]][["ip"]] %||% list(), - op = tpm[["efficiencies"]][["op"]] %||% list() - ) - - # for a while, the wrong time profile was set for some items. force these to none - p[["time_profile_mappings"]][ - c( - "baseline_adjustment", - "non-demographic_adjustment" - ) - ] <- "none" - - # check all the mitigators have a time profile - for (i in c("activity_avoidance", "efficiencies")) { - for (j in names(p[[i]])) { - for (k in names(p[[i]][[j]])) { - if (is.null(p$time_profile_mappings[[i]][[j]][[k]])) { - p$time_profile_mappings[[i]][[j]][[k]] <- "linear" - } - } - } - } - p <- mod_run_model_remove_invalid_mitigators(p, schema_text) # nolint start: commented_code_linter @@ -77,7 +46,6 @@ mod_run_model_fix_params <- function(p, schema_text) { "non-demographic_adjustment", "activity_avoidance", "efficiencies", - "time_profile_mappings", "reasons" ) diff --git a/R/mod_time_profile_server.R b/R/mod_time_profile_server.R deleted file mode 100644 index 0df65eec..00000000 --- a/R/mod_time_profile_server.R +++ /dev/null @@ -1,64 +0,0 @@ -#' time_profile Server Functions -#' -#' @noRd -mod_time_profile_server <- function(id, params) { - shiny::moduleServer(id, function(input, output, session) { - update_time_profile <- shiny::reactiveVal() - - # if the baseline year, or the end year changes, update the slider - shiny::observe({ - start <- as.numeric(stringr::str_sub(params$start_year, 1, 4)) - end <- params$end_year - - shiny::updateSliderInput( - session, - "step_year", - min = start, - max = end, - value = start - ) - }) - - # show/hide the step year slider based on what is selected for the time profile - shiny::observe({ - shinyjs::toggle( - "step_year", - condition = input$time_profile == "step_change" - ) - }) - - # if the selection changes - shiny::observe({ - tp <- shiny::req(update_time_profile()) - if (stringr::str_sub(tp, 1, 4) == "step") { - shiny::updateSliderInput( - session, - "step_year", - value = as.numeric(stringr::str_sub(tp, 5)) - ) - tp <- "step_change" - } - - shiny::updateSelectInput( - session, - "time_profile", - selected = tp - ) - }) |> - shiny::bindEvent(update_time_profile()) - - # update the time profile mappings when selections change - selected_time_profile <- shiny::reactive({ - tp <- input$time_profile - sy <- input$step_year - - ifelse(tp == "step_change", glue::glue("step{sy}"), tp) - }) |> - shiny::bindEvent(input$time_profile, input$step_year) - - list( - selected_time_profile = selected_time_profile, - update_time_profile = update_time_profile - ) - }) -} diff --git a/R/mod_time_profile_ui.R b/R/mod_time_profile_ui.R deleted file mode 100644 index 653f8f74..00000000 --- a/R/mod_time_profile_ui.R +++ /dev/null @@ -1,35 +0,0 @@ -#' time_profile UI Function -#' -#' @description A shiny Module. -#' -#' @param id,input,output,session Internal parameters for {shiny}. -#' -#' @noRd -#' -#' @importFrom shiny NS tagList -mod_time_profile_ui <- function(id) { - ns <- shiny::NS(id) - bs4Dash::bs4Card( - title = "Time Profile", - width = 12, - shiny::selectInput( - ns("time_profile"), - "Time Profile", - purrr::set_names( - c("linear", "front_loaded", "back_loaded", "step_change"), - snakecase::to_title_case - ) - ), - shinyjs::hidden( - shiny::sliderInput( - ns("step_year"), - "Step Change Year", - min = 0, - max = 1, - value = 1, - step = 1, - sep = "" - ) - ) - ) -} diff --git a/R/mod_waiting_list_imbalances_server.R b/R/mod_waiting_list_imbalances_server.R index c0f87e34..d29b465a 100644 --- a/R/mod_waiting_list_imbalances_server.R +++ b/R/mod_waiting_list_imbalances_server.R @@ -2,15 +2,6 @@ #' #' @noRd mod_waiting_list_imbalances_server <- function(id, wli_data, params) { - selected_time_profile <- update_time_profile <- NULL - # nolint start: object_usage_linter. - c(selected_time_profile, update_time_profile) %<-% - mod_time_profile_server( - shiny::NS(id, "time_profile"), - params - ) - # nolint end - mod_reasons_server( shiny::NS(id, "reasons"), params, @@ -74,14 +65,6 @@ mod_waiting_list_imbalances_server <- function(id, wli_data, params) { # observers ---- - # update the time profile - shiny::observe({ - params$time_profile_mappings[[ - "waiting_list_adjustment" - ]] <- selected_time_profile() - }) |> - shiny::bindEvent(selected_time_profile()) - # when the module is initialised, load the values from the loaded params file init <- shiny::observe( { @@ -89,11 +72,6 @@ mod_waiting_list_imbalances_server <- function(id, wli_data, params) { params }) - # update the selected time profile - update_time_profile(p$time_profile_mappings[[ - "waiting_list_adjustment" - ]]) - p <- p$waiting_list_adjustment if (length(p$ip) + length(p$op) > 0) { diff --git a/R/mod_waiting_list_imbalances_ui.R b/R/mod_waiting_list_imbalances_ui.R index 7dd196b6..f722e38e 100644 --- a/R/mod_waiting_list_imbalances_ui.R +++ b/R/mod_waiting_list_imbalances_ui.R @@ -32,8 +32,7 @@ mod_waiting_list_imbalances_ui <- function(id) { width = 12, md_file_to_html("app", "text", "waiting_list_imbalances.md") ), - mod_reasons_ui(ns("reasons")), - mod_time_profile_ui(ns("time_profile")) + mod_reasons_ui(ns("reasons")) ), bs4Dash::box( collapsible = FALSE,