From a342d2a68a775e772091493aeae839515c9b272c Mon Sep 17 00:00:00 2001
From: thierrychambert <thierry.chambert@gmail.com>
Date: Tue, 17 Aug 2021 15:48:11 +0200
Subject: [PATCH] cleaned pop "trend/strength" stuff : show/hide and english
 name in code

---
 inst/ShinyApp/server.R | 74 ++++++++++++++++++++++++------------------
 inst/ShinyApp/ui.R     | 23 +++++++------
 2 files changed, 56 insertions(+), 41 deletions(-)

diff --git a/inst/ShinyApp/server.R b/inst/ShinyApp/server.R
index 3384b93..67ec156 100644
--- a/inst/ShinyApp/server.R
+++ b/inst/ShinyApp/server.R
@@ -59,6 +59,9 @@ server <- function(input, output, session){
   ##--------------------------------------------
   observe({
 
+    #------------
+    # Hide all
+    #------------
     #shinyjs::hide("fatal_constant")
     #shinyjs::hide("fatalities_input_type")
     shinyjs::hide("fatalities_mean")
@@ -91,9 +94,10 @@ server <- function(input, output, session){
 
     shinyjs::hide("mat_fill_vr")
 
-
-    # Show fatalities part
-
+    #------------
+    # Show some
+    #------------
+    # Show inputs for fatalities part
     if(input$button_fatalities%%2 == 1){
       #shinyjs::show("fatal_constant")
 
@@ -122,7 +126,6 @@ server <- function(input, output, session){
     }
 
     # Show inputs for population size part
-
     if(input$button_pop_size%%2 == 1){
       #shinyjs::show("pop_size_unit")
       shinyjs::show("pop_size_input_type")
@@ -136,21 +139,7 @@ server <- function(input, output, session){
       }
     }
 
-    # Show inputs for carrying capacity part
-
-    if(input$button_carrying_cap%%2 == 1){
-      shinyjs::show("carrying_cap_input_type")
-      if(input$carrying_cap_input_type == "val"){
-        shinyjs::show("carrying_capacity")
-      }
-      if(input$carrying_cap_input_type == "eli_exp"){
-        shinyjs::show("carrying_cap_mat_expert")
-        shinyjs::show("carrying_cap_run_expert")
-      }
-    }
-
-    # Show inputs for population trend part
-
+    # Show inputs for population trend/growth part
     if(input$button_pop_growth%%2 == 1){
       shinyjs::show("pop_growth_input_type")
       if(input$pop_growth_input_type == "val"){
@@ -163,12 +152,25 @@ server <- function(input, output, session){
       }
       if(input$pop_growth_input_type == "trend"){
         shinyjs::show("pop_trend")
-        shinyjs::show("pop_trend_strength")
+        if(input$pop_trend != "stable"){
+          shinyjs::show("pop_trend_strength")
+        }
       }
     }
 
-    # Show inputs vital rates part
+    # Show inputs for carrying capacity part
+    if(input$button_carrying_cap%%2 == 1){
+      shinyjs::show("carrying_cap_input_type")
+      if(input$carrying_cap_input_type == "val"){
+        shinyjs::show("carrying_capacity")
+      }
+      if(input$carrying_cap_input_type == "eli_exp"){
+        shinyjs::show("carrying_cap_mat_expert")
+        shinyjs::show("carrying_cap_run_expert")
+      }
+    }
 
+    # Show inputs vital rates part
     if(input$button_vital_rates%%2 == 1){
       shinyjs::show("mat_fill_vr")
     }
@@ -255,6 +257,8 @@ server <- function(input, output, session){
   ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
 
 
+  #####
+
   ##--------------------------------------------
   ##  Display parameter distribution
   ##--------------------------------------------
@@ -396,6 +400,9 @@ server <- function(input, output, session){
 
 
 
+
+  #####
+
   ##--------------------------------------------
   ##  Run expert elicitation                  --
   ##--------------------------------------------
@@ -480,6 +487,7 @@ server <- function(input, output, session){
   },{
     if(all(!is.na(input$carrying_cap_mat_expert))) {
 
+      ## run elicitation analysis
       param$carrying_cap_eli_result <- func_eli(input$carrying_cap_mat_expert)
 
       ## run elicitation analysis
@@ -490,15 +498,18 @@ server <- function(input, output, session){
       print("missing value")
     } # end if
   }) # end observeEvent
-  ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
 
+  ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
 
+  #####
 
   ##--------------------------------------------
   ## Select parameter values for simulations  --
   ##--------------------------------------------
 
-  ## Cumulated impacts or not ? ###~~~~~~~~~~~~~~~~~~~~~~~~~~###
+  ##-------------------------------
+  ## Cumulated impacts or not ?
+  ##-------------------------------
   observeEvent({
     input$run
   }, {
@@ -510,8 +521,9 @@ server <- function(input, output, session){
   }) # end observeEvent
 
 
-  ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
-  ## Fatalities ###~~~~~~~~~~~~~~~~~~~~~~~~~~###
+  ##-------------------------------
+  ## Fatalities
+  ##-------------------------------
   observeEvent({
     input$run
   }, {
@@ -596,18 +608,18 @@ server <- function(input, output, session){
       # Case 2 : Trend information
     } else if(input$pop_growth_input_type == "trend"){
 
-      if(input$pop_trend == "Croissance") {
-        if(input$pop_trend_strength == "Faible") {
+      if(input$pop_trend == "growth") {
+        if(input$pop_trend_strength == "weak") {
           param$pop_growth_mean <- 1.01
-        } else if(input$pop_trend_strength == "Moyen"){
+        } else if(input$pop_trend_strength == "average"){
           param$pop_growth_mean <- 1.03
         } else {
           param$pop_growth_mean <- 1.06
         }
-      } else if(input$pop_trend == "Déclin"){
-        if(input$pop_trend_strength == "Faible") {
+      } else if(input$pop_trend == "decline"){
+        if(input$pop_trend_strength == "weak") {
           param$pop_growth_mean <- 0.99
-        } else if(input$pop_trend_strength == "Moyen"){
+        } else if(input$pop_trend_strength == "average"){
           param$pop_growth_mean <- 0.97
         } else {
           param$pop_growth_mean <- 0.94
diff --git a/inst/ShinyApp/ui.R b/inst/ShinyApp/ui.R
index 7f2ddd4..d43e7bd 100644
--- a/inst/ShinyApp/ui.R
+++ b/inst/ShinyApp/ui.R
@@ -131,7 +131,6 @@ rm(list = ls(all.names = TRUE))
   # Head Panel 2 : Model parameters
   {wellPanel(
 
-    #h2("Saisie des paramètres"),
     p("Saisie des paramètres", style="font-size:28px"),
 
     {fluidRow(
@@ -187,7 +186,7 @@ rm(list = ls(all.names = TRUE))
 
                                            matrixInput(inputId = "fatalities_mat_cumulated",
                                                        value = matrix(init_cumul, 3, 3,
-                                                                      dimnames = list(c(paste0("Parc n°", c(1:3))),
+                                                                      dimnames = list(c(paste0("Parc num.", c(1:3))),
                                                                                       c("Moyenne",
                                                                                         "Erreur-type",
                                                                                         "Année de mise en service du parc"))),
@@ -253,7 +252,7 @@ rm(list = ls(all.names = TRUE))
 
               )}, # close conditional panel
 
-      )}, # end column "mortalité"
+      )}, # end column "mortalite"
       ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
 
 
@@ -307,14 +306,18 @@ rm(list = ls(all.names = TRUE))
                                              column(6,
                                                     radioButtons(inputId = "pop_trend",
                                                                  label = "Tendance",
-                                                                 choices = c("Croissance", "Stable", "Déclin")),
+                                                                 choices = c("Croissance" = "growth",
+                                                                             "Stable" = "stable",
+                                                                             "Déclin" = "decline")),
                                              ),
 
                                              # Strength of trend
                                              column(6,
                                                     radioButtons(inputId = "pop_trend_strength",
                                                                  label = "Force",
-                                                                 choices = c("Faible", "Moyen", "Fort")),
+                                                                 choices = c("Faible" = "weak",
+                                                                             "Moyen" = "average",
+                                                                             "Fort" = "strong")),
                                              ),
                                            )}, # close fluidRow
 
@@ -322,7 +325,7 @@ rm(list = ls(all.names = TRUE))
 
               )}, # close conditional panel
 
-      )}, # end column "mortalité"
+      )}, # end column "mortalite"
       ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
 
 
@@ -370,7 +373,7 @@ rm(list = ls(all.names = TRUE))
 
               )}, # close conditional panel
 
-      )}, # end column "mortalité"
+      )}, # end column "fatalities"
       ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
 
 
@@ -388,7 +391,7 @@ rm(list = ls(all.names = TRUE))
 
       p("Valeurs utilisées", style="font-size:28px"),
 
-      # Mortalités annuelles
+      # Mortalites annuelles
       {wellPanel(style = "background:#DCDCDC",
                  p("Mortalités annuelles", style="font-size:20px; font-weight: bold"),
                  span(textOutput(outputId = "fatalities_mean_info"), style="font-size:16px"),
@@ -412,7 +415,7 @@ rm(list = ls(all.names = TRUE))
                  span(textOutput(outputId = "pop_growth_se_info"), style="font-size:16px"),
       )},
 
-      # Capacité de charge
+      # Capacite de charge
       {wellPanel(style = "background:#DCDCDC",
                  p("Capacité de charge", style="font-size:20px; font-weight: bold"),
                  span(textOutput(outputId = "carrying_capacity_info"), style="font-size:16px"),
@@ -434,7 +437,7 @@ rm(list = ls(all.names = TRUE))
                  br(),
                  hr(),
 
-                 #h3("Mortalités annuelles", align = "center"),
+                 #h3("Mortalites annuelles", align = "center"),
                  span(textOutput(outputId = "title_distri_plot"), style="font-size:24px; font-weight:bold"),
                  plotOutput(outputId = "distri_plot"),
 
-- 
GitLab