Skip to content

Commit

Permalink
Multiple smaller fixes and addition of threats
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Jung committed Apr 2, 2024
1 parent 0fac477 commit 6305cf9
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 19 deletions.
1 change: 1 addition & 0 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ golem_add_external_resources <- function() {
sever::useSever(),
waiter::use_waiter(),
shinyFeedback::useShinyFeedback(),
shinyWidgets::useSweetAlert(),
shinyjs::useShinyjs()
)
}
9 changes: 7 additions & 2 deletions R/mod_Design.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ mod_Design_ui <- function(id){
parameters or input data. Examples include planning approaches
that account for various climate scenarios or assumptions regarding
constraints. Please record whether there multiple scenarios
or variants have been explored."),
or variants have been explored and how"),
shiny::br(),
shiny::helpText("What does not qualify here: 'Scenarios' that
are essentially sensitivity checks or parameter
calibrations. Only select Yes if multiple outputs are
presented in the work."),
shinyWidgets::awesomeRadio(
inputId = ns("checkscenarios"),
label = "Are there multiple variants or scenarios explored in the planning?",
Expand Down Expand Up @@ -254,7 +259,7 @@ mod_Design_ui <- function(id){
shinyWidgets::pickerInput(
inputId = ns("stakeholderint"),
label = "Types of stakeholder interactions:",
choices = c("Informed","Consulted","Involved",
choices = c("Informed","Consulted","Dialogue","Involved",
"Collaborated","Co-design"),
multiple = TRUE,
options = list(
Expand Down
11 changes: 9 additions & 2 deletions R/mod_Export.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ mod_Export_server <- function(id, results){
mand <- get_protocol_mandatory()

# Check for mandatory outputs and highlight them in text
output$missingtext <- shiny::renderText("Highlight here all entries not yet filled!")
# observeEvent()
shiny::observeEvent(input$downloadData, {
# # Check the value of all mandatory fields
# output$missingtext <- shiny::renderText({
# # validate(
# # need(input$sldr > 5,"Require > 5")
# # )
# test
# })
})

# Get output format
oftype <- shiny::reactive({input$downloadFormat})
Expand Down
2 changes: 1 addition & 1 deletion R/mod_Home.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod_Home_ui <- function(id){
label = "In order for a planning study to be eligible for the protocol they should:",
choices = c("Make use of decision theoretic or multiple-criteria-based approaches!",
"Are spatial, spatial-temporal or at least use spatial input!",
"Have a biodiversity and/or conservation focus or angle! *",
"Have a biodiversity and/or conservation objective! *",
"Use an algorithic prioritization to identify best areas or actions! **"),
icon = shiny::icon("thumbs-up"),
status = "primary",
Expand Down
6 changes: 3 additions & 3 deletions R/mod_Overview.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ mod_Overview_ui <- function(id){
collapsed = FALSE,
collapsible = TRUE,
# icon = icon("magnifying-glass-chart"),
shiny::imageOutput(ns("peng2011"),inline = TRUE,fill = TRUE),
shiny::imageOutput(ns("peng2011"),inline = TRUE,fill = FALSE),
shiny::br(),
shiny::helpText("Source: Peng, R. D. (2011). Reproducible research in computational science. Science, 334(6060), 1226-1227."),
shiny::br(),
Expand Down Expand Up @@ -484,8 +484,8 @@ mod_Overview_server <- function(id, results, parentsession){
)
# Return a list containing the filename and alt text
list(src = path_figure,
width = "80%",
height = "50%",
width = "300px",
height = "120px",
alt = paste("Peng 2011, Reproducible Research in Computational Science, Science"))

}, deleteFile = FALSE)
Expand Down
11 changes: 6 additions & 5 deletions R/mod_Prioritization.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ mod_Prioritization_ui <- function(id){
chosen representative indicators or values.",
"An example would be for example summarizing the average amount of
a threatened species range covered, or overlap with other spatial layers."),
DT::DTOutput(outputId = ns("perfidenticators")),
shiny::br(),
DT::DTOutput(outputId = ns("evalperformance")),
shiny::actionButton(inputId = ns("add_indicator"), label = "Add a new indicator",
icon = shiny::icon("plus")),
shiny::actionButton(inputId = ns("remove_indicator"), label = "Remove last indicator",
Expand Down Expand Up @@ -239,7 +240,7 @@ mod_Prioritization_server <- function(id, results, parentsession){
ids <- get_protocol_ids(group = "prioritization")
shiny::observe({
for(id in ids){
if(id == "perfidenticators"){
if(id == "evalperformance"){
results[[id]] <- data.frame(indicators()) |> asplit(MARGIN = 1)
} else {
results[[id]] <- input[[id]]
Expand Down Expand Up @@ -293,15 +294,15 @@ mod_Prioritization_server <- function(id, results, parentsession){
})

#output the datatable based on the dataframe (and make it editable)
output$perfidenticators <- DT::renderDT({
output$evalperformance <- DT::renderDT({
DT::datatable(indicators(),rownames = FALSE,
filter = "none", selection = "none",
style = "auto",
editable = TRUE)
})

shiny::observeEvent(input$perfidenticators_cell_edit, {
info <- input$perfidenticators_cell_edit
shiny::observeEvent(input$evalperformance_cell_edit, {
info <- input$evalperformance_cell_edit
modified_data <- indicators()
modified_data[info$row, info$col+1] <- info$value
indicators(modified_data)
Expand Down
94 changes: 93 additions & 1 deletion R/mod_Specification.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ mod_Specification_ui <- function(id){
shiny::p("Planning can be conducted on all land or sea within a given
region, but it can also be specific to certain ecosystems
or land-use types, such as for example forests.",
shiny::strong("Check No if all available land or sea was considered.")),
shiny::strong("Check No if all available land or sea within the study region was considered.")),
shinyWidgets::awesomeRadio(
inputId = ns("checkecosystem"),
label = "Was there any ecosystem specificity?",
Expand Down Expand Up @@ -263,6 +263,98 @@ mod_Specification_ui <- function(id){
)
) # Column end
), # Fluid row end
shiny::br(),
# Entries #
shiny::fluidRow(
shiny::column(width = 2),
shiny::column(width = 12,
# Threats
bs4Dash::box(
title = 'Threats and pressures',
closable = FALSE,
width = 12,
solidHeader = TRUE,
status = "primary",
collapsible = TRUE,
shiny::p("Select any threats or pressures that were targeted in the planning
or that, directly or indirectly, shape the planning outcome.
The threat description broadly follows the IUCN Threat categorization system."),
shiny::br(),
shiny::helpText("IUCN Threat classification: https://www.iucnredlist.org/resources/threat-classification-scheme"),
# Threat types
bs4Dash::box(
title = "Threat or pressure types",
closable = FALSE,
width = 12,
solidHeader = TRUE,
status = "secondary",
collapsible = FALSE,
shinyWidgets::pickerInput(
inputId = ns("threattypes"),
label = "Select/deselect all options",
choices = c(
"None",
"Residential & commercial development",
"Agriculture & Aquaculture",
"Energy production & Mining",
"Transportation & Traffic",
"Biological Resource Use (fishing, harvesting, logging)",
"Human Intrusions & Disturbance (recreation, war)",
"Natural system modification (Fire, Dams)",
"Invasive species, genes or diseases",
"Pollution (Waste water, pollutants)",
"Climate Change and severe weather (droughts, flooding)",
"Geological events (Earthquakes)",
"Other"
),
options = list(`actions-box` = TRUE),
multiple = TRUE
),
shiny::br(),
# Any other types?
shiny::conditionalPanel(
condition = "input.threattypes == 'Other'",
ns = ns,
shiny::textAreaInput(inputId = ns("otherthreattype"), label = "Other types",
placeholder = 'Any other type of threat or pressure not considered? Describe',
height = "45px", width = "100%", resize = "none")
)
), # Threat type box end
shiny::br(),
# How were Threats considered/included?
bs4Dash::box(
title = "How were threats considered in the planning?",
closable = FALSE,
width = 12,
solidHeader = TRUE,
status = "secondary",
collapsible = FALSE,
shiny::p('There are multiple ways of including threats and pressures, for example
by considering them as risk factor in the prioritization,
as cost or penalty in selecting a solution.
Here we record these various options.'),
shinyWidgets::pickerInput(
inputId = ns("threatinclusion"),
label = "Select/deselect all options",
choices = c(
"Feature (aggregated risk)",
"Feature (individual)",
"Cost layer",
"Selection penalty",
"Exclusion area",
"Management zone or feature contribution",
"Other"
),
options = list(`actions-box` = TRUE),
multiple = TRUE
),
shiny::textAreaInput(inputId = ns("threatdetail"), label = "Threat details",
placeholder = 'Elaborate on other ways of including threats in the planning',
height = "60px", width = "100%", resize = "vertical")
)
) # Threats and pressures box end
) # Fluid column end
), # Fluidrow end
shiny::br(),
# Entries #
shiny::fluidRow(
Expand Down
3 changes: 2 additions & 1 deletion R/utils_format_protocol.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ format_protocol <- function(results, format = "data.frame",path_protocol = NULL)
#' List to table
#'
#' @description
#' A helper function that converted
#' A helper function that converts a list to a table. Used internally
#' by format_protocol.
#'
#' @param protocol A filled out protocol in [`list`] format.
#' @return The return value, if any, from executing the utility.
Expand Down
59 changes: 55 additions & 4 deletions inst/01_protocol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ design:
conditional_options:
- Informed
- Consulted
- Dialogue
- Involved
- Collaborated
- Co-design
Expand Down Expand Up @@ -338,8 +339,8 @@ specification:
- m2
- km2
- ha
- ft2,
- yd2,
- ft2
- yd2
- mi2
- acre
mandatory: false
Expand Down Expand Up @@ -408,6 +409,54 @@ specification:
mandatory: true
popexample: "Existing protected areas were considered to be part of every solution (included)."

threattypes:
render-nr: 1
render-id: 'threattypes'
render-group: 'threatpressures'
question: 'What types of threats or pressures are included in the planning?'
description: 'Select any threats or pressures that were targeted in the planning or that, directly or indirectly, shape the planning outcome. The threat description broadly follows the IUCN Threat categorization system.'
fieldtype: 'multiplechoice'
options:
- None
- Residential & commercial development
- Agriculture & Aquaculture
- Energy production & Mining
- Transportation & Traffic
- Biological Resource Use (fishing, harvesting, logging)
- Human Intrusions & Disturbance (recreation, war)
- Natural system modification (Fire, Dams)
- Invasive species, genes or diseases
- Pollution (Waste water, pollutants)
- Climate Change and severe weather (droughts, flooding)
- Geological events (Earthquakes)
- Other
fieldtype_conditional_render-id: 'otherthreattype'
fieldtype_conditional: 'textbox'
mandatory: true
popexample: "Select any type of pressure or threat considered in this work."

threatinclusion:
render-nr: 2
render-id: 'threatinclusion'
render-group: 'threatpressures'
question: 'How were threats considered in the planning?'
description: 'There are multiple ways of including threats and pressures, for example
by considering them as risk factor in the prioritization, as cost or penalty in selecting
a solution. Here we record these various options.'
fieldtype: 'multiplechoice'
options:
- Feature (aggregated risk)
- Feature (individual)
- Cost layer
- Selection penalty
- Exclusion area
- Management zone or feature contribution
- Other
fieldtype_conditional_render-id: 'threatdetail'
fieldtype_conditional: 'textbox'
mandatory: false
popexample: "Anthropogenic land-use pressures were considered as a selection penalty"

featuretypes:
render-nr: 1
render-id: 'featuretypes'
Expand Down Expand Up @@ -465,6 +514,8 @@ specification:
popexample: "A description where or how the feature layers came about, if they are
the result of some modelling process or similar."



#### Context ####
context:
decisionvariable:
Expand Down Expand Up @@ -545,8 +596,8 @@ context:
fieldtype: 'selectizedropdown'
options:
- None
- Flat (e.g. 30 percent),
- Log-linear,
- Flat (e.g. 30 percent)
- Log-linear
- Minimum Area of Suitable Habitat
- Other
fieldtype_conditional_render-id: 'targetdetail'
Expand Down

0 comments on commit 6305cf9

Please sign in to comment.