Skip to content

Commit

Permalink
Multiple updates to ui elements, started with study region implementa…
Browse files Browse the repository at this point in the history
…tion #2
  • Loading branch information
Martin-Jung committed Mar 24, 2024
1 parent 55142ea commit 0fac477
Show file tree
Hide file tree
Showing 18 changed files with 365 additions and 83 deletions.
13 changes: 8 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ Imports:
DT,
waiter,
dplyr,
readr,
leaflet,
sf,
terra,
readr
Suggests:
markdown,
rmarkdown
rmarkdown,
spelling,
testthat (>= 3.0.0)
Encoding: UTF-8
Language: en-US
LazyData: true
RoxygenNote: 7.3.1
URL: https://github.com/iiasa/ODPSCP
BugReports: https://github.com/iiasa/ODPSCP/issues
Suggests:
spelling,
testthat (>= 3.0.0)
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Incorporated Expert-Feedback and updated the protocol with additional fields and explanations.
* Added glossary, to be further expanded in future versions #4
* Added tooltip to the protocol for each fields (can be toggled off) #6
* Added option for enabling study region delineation #2
* Added option to export a word or pdf summary of the protocol #5
* Added a bookmark option to store the current setting of the protocol as server id (experimental)

## Version 0.2
Expand Down
14 changes: 14 additions & 0 deletions R/ODPSCP-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' @title ODPSCP
#'
#' @description
#' The ODPSCP shiny interface comes in a series of UI and server plus helper functions
#' that support the standardized reporting of prioritization results.
#'
#' @name ODPSCP
#' @docType package
#' @keywords internal
"_PACKAGE"

globalVariables(c(
"element"
))
5 changes: 3 additions & 2 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ app_ui <- function(request) {
color = "primary",
opacity = 0,
href = NULL,
image = shiny::img(src = "www/logo.png", height = "20px")
image = shiny::img(src = base::normalizePath(system.file("app/www/logo.png", package = "ODPSCP")),
height = "20px")
),
status = "white",
border = TRUE,
compact = FALSE,
leftUi = NULL, rightUi = NULL,
shiny::div(style="position:relative; left:calc(65%);",
shiny::div(style="position:relative; left:calc(5%);",
shinyWidgets::actionBttn(
inputId = "bookmark",
label = "Save settings",
Expand Down
24 changes: 16 additions & 8 deletions R/mod_Design.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod_Design_ui <- function(id){
design elements of the study. These elements usually do not
consider methodological specifications of the planning, but
rather the conceptual understanding of the aims, purpose, and
framework underlying a study."
any framework underlying a study."
),
shiny::hr()
)
Expand Down Expand Up @@ -74,10 +74,11 @@ mod_Design_ui <- function(id){
# Study framework
shiny::p("Does the study follow an analytical framework, either explicitly
defined within the study or through a reference to previous
work? This could for example also be a specific planning protocol."),
work? This could for example also be a specific planning protocol or established
approaches such as structure decision making or adapative management."),
shiny::p("Example framework references:"),
shiny::p("Pressey, R. L., & Bottrill, M. C. (2009). Approaches to landscape-and seascape-scale conservation planning: convergence, contrasts and challenges. Oryx, 43(4), 464-475."),
shiny::p("Álvarez-Romero, J. G., Adams, V. M., Pressey, R. L., Douglas, M., Dale, A. P., Augé, A. A., ... & Perdrisat, I. (2015). Integrated cross-realm planning: A decision-makers' perspective. Biological Conservation, 191, 799-808."),
shiny::p("Alvarez-Romero, J. G., Adams, V. M., Pressey, R. L., Douglas, M., Dale, A. P., Auge, A. A., ... & Perdrisat, I. (2015). Integrated cross-realm planning: A decision-makers' perspective. Biological Conservation, 191, 799-808."),
shiny::p("Niemiec, R. M., Gruby, R., Quartuch, M., Cavaliere, C. T., Teel, T. L., Crooks, K., ... & Manfredo, M. (2021). Integrating social science into conservation planning. Biological Conservation, 262, 109298."),
shinyWidgets::pickerInput(
inputId = ns("studyframework"),
Expand Down Expand Up @@ -134,11 +135,14 @@ mod_Design_ui <- function(id){
such as the identification of areas to be placed under
conservation management (e.g. Protected areas)"),
shiny::selectizeInput(inputId = ns("studypurpose"),
label = "Identify or add a primary purpose",
choices = c("","Area-based allocation", "Management improvement",
"Action-based planning", "Monitoring and evaluation",
"Land-use allocation"),
multiple = FALSE,
label = "Identify or add primary purpose(s)",
choices = c("","Area-based allocation",
"Management evaluation",
"Management improvement",
"Action-based planning",
"Monitoring and evaluation"
),
multiple = TRUE,
options = list(create = TRUE,
placeholder = "Choose from list, or type and click to add a new option."))
),
Expand Down Expand Up @@ -265,6 +269,10 @@ mod_Design_ui <- function(id){
solidHeader = TRUE,
status = "secondary",
collapsible = FALSE,
shiny::p("Select or add broad groups of who was engaged.
Note that co-authors are generally not considered stakeholders
unless co-authorship is given due to co-design of the
whole planning study."),
shiny::selectizeInput(inputId = ns("stakeholdertype"),
label = "Who was engaged?",
choices = c("Policy makers (International)",
Expand Down
55 changes: 48 additions & 7 deletions R/mod_Export.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,45 @@ mod_Export_ui <- function(id){
width = 12,
solidHeader = TRUE,
collapsible = FALSE,
"All protocol entries can be exported in a Range of different formats
for further use. Currently supported are the compressed 'rData', 'csv' and
'yaml' format.
",
shiny::p(
"All protocol entries can be exported in a range of different formats
for further use such as appending them to a manuscript.
It should be noted that only 'rData', 'csv' and 'yaml' are
machine-readable formats and be imported again by ODPSCP.
"
),
shiny::br(),
# Output format
shinyWidgets::radioGroupButtons(
inputId = ns("downloadFormat"),
label = "Output Format",
individual = TRUE,
justified = TRUE,
size = "lg",
status = "info",
choices = c('rData', 'csv', 'yaml'),
selected = 'rData'
choices = c('docx', 'pdf', 'rData', 'csv', 'yaml'),
selected = 'rData',
checkIcon = list(
yes = shiny::icon("circle-down"),
no = NULL
)
),
shiny::br(),
# Conditional info
shiny::conditionalPanel(
condition = "input.downloadFormat == 'docx'",
ns = ns,
shiny::p("Protocol will be rendered as docx Word document, which
can be easily modified as well. Suitabile for manuscript
appendices or personal records.")
),
shiny::conditionalPanel(
condition = "input.downloadFormat == 'pdf'",
ns = ns,
shiny::p("Protocol will be rendered as document and then converted
to a PDF format. This is the most convenient format for
appending the protocol to any publications for example.")
),
shiny::conditionalPanel(
condition = "input.downloadFormat == 'rData'",
ns = ns,
Expand All @@ -66,12 +90,16 @@ mod_Export_ui <- function(id){
any text editor and loaded as lists into R via yaml::read_yaml(file).")
),
shiny::br(),
shiny::hr(),
shiny::div(id = ns("missing"), class = 'missing',
shiny::textOutput(outputId = ns("missingtext"))),
shiny::br(),
# Button
shiny::downloadButton(ns("downloadData"), "Download the protocol")
)
),
shiny::tabPanel(
title = "Render protocol",
title = "Render protocol table",
icon = shiny::icon("list-alt",lib = "glyphicon"),
bs4Dash::box(
title = "Protocol",
Expand Down Expand Up @@ -107,6 +135,13 @@ mod_Export_server <- function(id, results){
editable = FALSE)
})

# Get mandatory protocol entries
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()

# Get output format
oftype <- shiny::reactive({input$downloadFormat})

Expand Down Expand Up @@ -136,6 +171,12 @@ mod_Export_server <- function(id, results){
protocol <- format_protocol(results, format = "list")
yaml::write_yaml(protocol, file = file)
# yaml::read_yaml("../../../Downloads/test.yaml")
} else if(oftype() == "docx"){
# Create document from results
message("Not yet implemented...")
} else if(oftype() == "pdf"){
# Create document from results
message("Not yet implemented...")
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion R/mod_Glossary.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod_Glossary_server <- function(id){
package = "ODPSCP",
mustWork = TRUE)
output$glossary_table <- DT::renderDataTable(
read.csv(ppath, sep = ",",header = TRUE) |>
utils::read.csv(ppath, sep = ",",header = TRUE) |>
DT::datatable(filter = "none", rownames = FALSE,
editable = FALSE)
)
Expand Down
39 changes: 28 additions & 11 deletions R/mod_Home.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ mod_Home_ui <- function(id){
from a range of scientific disciplines.",
style= "font-size: 18px;"),

shiny::p("Area-based and action-based conservation planning are critical scientific
tools in reaching conservation policy objectives across scales.
Yet despite decades of research and numerous scientific advances
in Europe ",shiny::a(href = 'https://osf.io/8x2ug/', '(Jung et al. 2023)',
shiny::p("Area-based and action-based conservation planning are critical
in reaching conservation policy objectives across scales. Yet
despite decades of research and numerous scientific advances
in Europe ",shiny::a(href = 'https://osf.io/8x2ug/', '(Jung et al. 2023)',
target = "_blank", .noWS = "outside"),".",
" and globally ",shiny::a(href = 'https://www.annualreviews.org/doi/10.1146/annurev-environ-102016-060902',
'(McIntosh et al. 2017)',
target = "_blank", .noWS = "outside"),
", it often remains incomprehensible for those unfamiliar with the
planning how decisions where reached or what factors were considered
influential in determining the identified outcomes.",
" and globally ",shiny::a(href = 'https://www.annualreviews.org/doi/10.1146/annurev-environ-102016-060902', '(McIntosh et al. 2017)', target = "_blank", .noWS = "outside"),
", it often remains incomprehensible for those unfamiliar with the
planning how decisions where reached or what factors were considered
influential in determining the identified outcomes.",
style= "font-size: 18px;"),

# img(src = "", width = "60%", style="display: block; margin-left: auto; margin-right: auto;
Expand All @@ -54,7 +52,26 @@ mod_Home_ui <- function(id){
expert evaluation of the conducted planning. Third, it helps study
authors and decision makers to identify key strength, but also
weaknesses of a systematic planning exercise. ", style= "font-size: 18px;"),

# --- #
shiny::hr(),
shinyWidgets::prettyCheckboxGroup(
inputId = ns("eligibility"),
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! *",
"Use an algorithic prioritization to identify best areas or actions! **"),
icon = shiny::icon("thumbs-up"),
status = "primary",
outline = TRUE,
inline = TRUE,
plain = TRUE,
animation = "jelly"
),
shiny::helpText("* This is not say that non-biodiversity focussed planning studies (such as optimal cropland management allocation) can not be entered per se."),shiny::br(),
shiny::helpText("** Studies presenting methodological advances are not suitable for the protocol,
unless they are demonstrated in an applied scenario."),
shiny::hr(),
shiny::p("This Shiny web application helps to implement the protocol through
an easy understandable user interface and allows export the created
protocols in a range of formats for further usages. We encourage the
Expand Down
Loading

0 comments on commit 0fac477

Please sign in to comment.