From cc4fa7e15524ac27d38a40d51136acb9fcb8db3f Mon Sep 17 00:00:00 2001 From: Franck Gaspard <franck.gaspard@developpement-durable.gouv.fr> Date: Wed, 16 Apr 2025 14:00:13 +0200 Subject: [PATCH] modification de R/mod_selection_explorer_mesures.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0 errors ✔ | 0 warnings ✔ | 3 notes ✖ ── R CMD check results ───────────────────────────── pesticides.pdl 0.0.0.9000 ──── Duration: 5m 37.6s ❯ checking package dependencies ... NOTE Imports includes 28 non-default packages. Importing from so many packages makes the package vulnerable to any of them becoming unavailable. Move as many as possible to Suggests and use conditionally. ❯ checking for future file timestamps ... NOTE unable to verify current time ❯ checking dependencies in R code ... NOTE Espaces de noms dans le champ Imports non importés depuis : 'markdown' 'pkgload' All declared Imports should be used. R CMD check succeeded --- R/fct_explorer_mesures.R | 20 +++++----- R/mod_selection_explorer_mesures.R | 60 ++++++++++++++++++++---------- 2 files changed, 51 insertions(+), 29 deletions(-) diff --git a/R/fct_explorer_mesures.R b/R/fct_explorer_mesures.R index 67d270f..7599b31 100644 --- a/R/fct_explorer_mesures.R +++ b/R/fct_explorer_mesures.R @@ -43,11 +43,13 @@ explorer_sage_station_fct <- function(SelectSage, station){ #' #' @export #' @importFrom dplyr filter between select -explorer_data_fct <- function(explorer_SelectStation, - explorer_SelectSage, - matrice, - explorer_SelectAnnee, - explorer_SelectConcentrationmin){ +explorer_data_fct <- function( + explorer_SelectStation, + explorer_SelectSage, + matrice, + explorer_SelectAnnee, + explorer_SelectConcentrationmin + ){ if(length(explorer_SelectStation) > 1){ matrice %>% dplyr::filter( @@ -70,7 +72,7 @@ explorer_data_fct <- function(explorer_SelectStation, resultat_analyse >= explorer_SelectConcentrationmin ) %>% dplyr::select( - annee_prelevement, date_prelevement, code_station,libelle_station,insee_dep, + annee_prelevement, date_prelevement, code_station, libelle_station, insee_dep, nom_parametre, code_remarque, resultat_analyse, Exigenceeaudistribuee ) } @@ -82,7 +84,7 @@ explorer_data_fct <- function(explorer_SelectStation, resultat_analyse >= explorer_SelectConcentrationmin ) %>% dplyr::select( - annee_prelevement, date_prelevement, code_station,libelle_station,insee_dep, + annee_prelevement, date_prelevement, code_station, libelle_station, insee_dep, nom_parametre, code_remarque, resultat_analyse, Exigenceeaudistribuee ) } @@ -94,7 +96,7 @@ explorer_data_fct <- function(explorer_SelectStation, resultat_analyse >= explorer_SelectConcentrationmin ) %>% dplyr::select( - annee_prelevement, date_prelevement, code_station,libelle_station,insee_dep, + annee_prelevement, date_prelevement, code_station, libelle_station, insee_dep, nom_parametre, code_remarque, resultat_analyse, Exigenceeaudistribuee ) } @@ -108,7 +110,7 @@ explorer_data_fct <- function(explorer_SelectStation, resultat_analyse >= explorer_SelectConcentrationmin ) %>% dplyr::select( - annee_prelevement, date_prelevement, code_station,libelle_station,insee_dep, + annee_prelevement, date_prelevement, code_station, libelle_station, insee_dep, nom_parametre, code_remarque, resultat_analyse, Exigenceeaudistribuee ) } diff --git a/R/mod_selection_explorer_mesures.R b/R/mod_selection_explorer_mesures.R index 303c485..705d7a8 100644 --- a/R/mod_selection_explorer_mesures.R +++ b/R/mod_selection_explorer_mesures.R @@ -121,7 +121,7 @@ mod_selection_explorer_mesures_server <- function(input, output, session, global locale$parametres <- parametres_esu } else{ - locale$parametres <- parametres_esu + locale$parametres <- parametres_eso } output$liste_parametre <- shiny::renderUI({ @@ -143,30 +143,50 @@ mod_selection_explorer_mesures_server <- function(input, output, session, global locale$station <- global$station_eso %>% sf::st_drop_geometry() } - }) + }) - shiny::observeEvent(input$explorer_SelectSage, { - locale$sage_station <- explorer_sage_station_fct(input$explorer_SelectSage, locale$station) + shiny::observeEvent(c(input$explorer_SelectSage, input$explorer_SelectCodeNatureEau), { - output$liste_station_sage <- shiny::renderUI({ - shiny::selectizeInput( - inputId = ns("explorer_SelectStation"), - label = "Stations", - choices = locale$station %>% - dplyr::select(code_station, libelle_station) %>% - dplyr::filter(code_station %in% locale$sage_station) %>% - dplyr::mutate(libelle_station = as.character(libelle_station)) %>% - dplyr::arrange(libelle_station) %>% - dplyr::pull(libelle_station) %>% - c("Toutes",.), - selected = "Toutes", - multiple = TRUE, - options = list("plugins" = list("remove_button")) - ) - }) + if(is.null(input$explorer_SelectSage)){ + output$liste_station_sage <- shiny::renderUI({ + shiny::selectizeInput( + inputId = ns("explorer_SelectStation"), + label = "Stations", + choices = locale$station %>% + dplyr::select(code_station, libelle_station) %>% + dplyr::mutate(libelle_station = as.character(libelle_station)) %>% + dplyr::arrange(libelle_station) %>% + dplyr::pull(libelle_station) %>% + c("Toutes",.), + selected = "Toutes", + multiple = TRUE, + options = list("plugins" = list("remove_button")) + ) + }) + }else{ + + locale$sage_station <- explorer_sage_station_fct(input$explorer_SelectSage, locale$station) + + output$liste_station_sage <- shiny::renderUI({ + shiny::selectizeInput( + inputId = ns("explorer_SelectStation"), + label = "Stations", + choices = locale$station %>% + dplyr::select(code_station, libelle_station) %>% + dplyr::filter(code_station %in% locale$sage_station) %>% + dplyr::mutate(libelle_station = as.character(libelle_station)) %>% + dplyr::arrange(libelle_station) %>% + dplyr::pull(libelle_station) %>% + c("Toutes",.), + selected = "Toutes", + multiple = TRUE, + options = list("plugins" = list("remove_button")) + ) + }) + } }) -- GitLab