Skip to content

Commit

Permalink
Merge pull request #412 from NCC-CNC/dev
Browse files Browse the repository at this point in the history
WTW v1.2.3, PR #411, #408, #406, #404,  #403
DanWismer authored Dec 13, 2024
2 parents 159cb82 + e6e546b commit e601653
Showing 156 changed files with 335 additions and 248 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wheretowork
Title: Interactive Systematic Conservation Planning Application
Version: 1.1.3
Version: 1.2.3
Description:
Launch an interactive web application for systematic conservation planning.
Data can be accessed using projects available on disk, uploaded using
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# wheretowork 1.2.3

### Minor changes and bug fixes
- Added `data_prep_date` attribute on `write_project`
- Solution setting tab names back to "single goals" and "group goal".
- Fixed update solution bug (multi-theme and single-theme status logic).
- Thousand comma separated values in charts and tables.
- Activated the pointer cursor on the colour picker. Thanks @XavierCLL.
- Adjusted tooltip position of solution charts. Thanks @XavierCLL.

# wheretowork 1.1.3

### Minor changes and bug fixes
54 changes: 39 additions & 15 deletions R/class_Solution.R
Original file line number Diff line number Diff line change
@@ -335,8 +335,12 @@ Solution <- R6::R6Class(
rd$value_text <- rd$value
rd$value_text <- dplyr::if_else(
!is.na(rd$units) & nchar(rd$units) > 0,
paste(round(rd$value_text,2), rd$units, sep = " "),
paste(round(rd$value_text, 2))) # add units if present
paste(
prettyNum(round(rd$value_text, 2), big.mark = ","),
rd$units, sep = " " # add units if present
),
prettyNum(round(rd$value_text, 2), big.mark = ",")
)
rd$value_text <- dplyr::if_else(
!is.na(rd$proportion),
paste0(rd$value_text, " (", round(rd$proportion*100), "%)"),
@@ -371,23 +375,22 @@ Solution <- R6::R6Class(
Feature = x$feature_name,
Status = dplyr::if_else(x$feature_status, "Enabled", "Disabled"),
`Total (units)` = paste(
round(x$feature_total_amount, 2), x$units
prettyNum(round(x$feature_total_amount, 2), big.mark = ","),
x$units
),
`Current (%)` = round(x$feature_current_held * 100, 2),
`Current (units)` = paste(
round(x$feature_current_held * x$feature_total_amount, 2),
prettyNum(round(x$feature_current_held * x$feature_total_amount, 2), big.mark = ","),
x$units
),
`Goal (%)` = round(x$feature_status * x$feature_goal * 100, 2),
`Goal (units)` = paste(
round(
x$feature_status * x$feature_goal * x$feature_total_amount, 2
),
prettyNum(round(x$feature_status * x$feature_goal * x$feature_total_amount, 2), big.mark = ","),
x$units
),
`Solution (%)` = round(x$feature_solution_held * 100, 2),
`Solution (units)` = paste(
round(x$feature_solution_held * x$feature_total_amount, 2),
prettyNum(round(x$feature_solution_held * x$feature_total_amount, 2), big.mark = ","),
x$units
),
`Met` = dplyr::case_when(
@@ -415,11 +418,20 @@ Solution <- R6::R6Class(
Weight = x$name,
Status = dplyr::if_else(x$status, "Enabled", "Disabled"),
Factor = round(x$factor, 2),
`Total (units)` = paste(round(x$total, 2), x$units),
`Total (units)` = paste(
prettyNum(round(x$total, 2), big.mark = ","),
x$units
),
`Current (%)` = round(x$current * 100, 2),
`Current (units)` = paste(round(x$current * x$total, 2), x$units),
`Current (units)` = paste(
prettyNum(round(x$current * x$total, 2), big.mark = ","),
x$units
),
`Solution (%)` = round(x$held * 100, 2),
`Solution (units)` = paste(round(x$held * x$total, 2), x$units),
`Solution (units)` = paste(
prettyNum(round(x$held * x$total, 2), big.mark = ","),
x$units
),
)
} else {
## if no weights are present, then use return
@@ -446,9 +458,15 @@ Solution <- R6::R6Class(
out <- tibble::tibble(
Include = x$name,
Status = dplyr::if_else(x$status, "Enabled", "Disabled"),
`Total (units)` = paste(round(x$total, 2), x$units),
`Total (units)` = paste(
prettyNum(round(x$total, 2), big.mark = ","),
x$units
),
`Solution (%)` = round(x$held * 100, 2),
`Solution (units)` = paste(round(x$held * x$total, 2), x$units)
`Solution (units)` = paste(
prettyNum(round(x$held * x$total, 2), big.mark = ","),
x$units
)
)
} else {
## if no weights are present, then use return
@@ -475,9 +493,15 @@ Solution <- R6::R6Class(
out <- tibble::tibble(
Exclude = x$name,
Status = dplyr::if_else(x$status, "Enabled", "Disabled"),
`Total (units)` = paste(round(x$total, 2), x$units),
`Total (units)` = paste(
prettyNum(round(x$total, 2), big.mark = ","),
x$units
),
`Solution (%)` = round(x$held * 100, 2),
`Solution (units)` = paste(round(x$held * x$total, 2), x$units)
`Solution (units)` = paste(
prettyNum(round(x$held * x$total, 2), big.mark = ","),
x$units
)
)
} else {
## if no weights are present, then use return
2 changes: 2 additions & 0 deletions R/fct_write_project.R
Original file line number Diff line number Diff line change
@@ -143,6 +143,8 @@ write_project <- function(x, dataset, path, name,
params$author_name <- author_name
params$author_email <- author_email
}
## add data prep date
params$data_prep_date <- as.character(Sys.Date())
## add wheretowork version
params$wheretowork_version <- as.character(utils::packageVersion("wheretowork"))
## add prioritizr version
30 changes: 21 additions & 9 deletions R/server_update_solution_settings.R
Original file line number Diff line number Diff line change
@@ -54,11 +54,22 @@ server_update_solution_settings <- quote({
animation = TRUE
)
} else {
### update theme/feature status
### update multi and single theme status
vapply(app_data$themes, FUN.VALUE = logical(1), function(x) {
if ((!all(x$get_feature_status())) &
(length(x$get_feature_status()) > 1)) {
### update group status
#### multi-theme status: TRUE
if (any(x$get_feature_status()) & (length(x$get_feature_status()) > 1)) {
updateSolutionSettings(
inputId = "newSolutionPane_settings",
value = list(
id = x$id,
setting = "status",
value = TRUE,
type = "theme"
)
)
}
#### multi-theme status: FALSE
if (all(!x$get_feature_status()) & (length(x$get_feature_status()) > 1)) {
updateSolutionSettings(
inputId = "newSolutionPane_settings",
value = list(
@@ -68,8 +79,9 @@ server_update_solution_settings <- quote({
type = "theme"
)
)
} else {
### update feature status
}
#### single-theme status set via get method
if (length(x$get_feature_status()) == 1) {
updateSolutionSettings(
inputId = "newSolutionPane_settings",
value = list(
@@ -83,11 +95,11 @@ server_update_solution_settings <- quote({
#### return success
TRUE
})
### update theme/feature goal
### update theme/feature goal and view
vapply(app_data$themes, FUN.VALUE = logical(1), function(x) {
#### update group goal when all features have the same goal
if ((length(unique(x$get_feature_goal())) == 1) &
(length(x$get_feature_goal()) > 1)) {
#### update group goal
updateSolutionSettings(
inputId = "newSolutionPane_settings",
value = list(
@@ -97,7 +109,7 @@ server_update_solution_settings <- quote({
type = "theme"
)
)
### update view to group tab
### update group view when all features have the same goal
updateSolutionSettings(
inputId = "newSolutionPane_settings",
value = list(
2 changes: 1 addition & 1 deletion R/ui_importModal.R
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ importModal <- function(id) {
shiny::modalDialog(
title = htmltools::tags$p(
"Where To Work",
htmltools::tags$span("v1.1.3", style = "font-size:12px"),
htmltools::tags$span("v1.2.3", style = "font-size:12px"),
style = "text-align:center"
),
easyClose = FALSE,
6 changes: 4 additions & 2 deletions R/utils_write_excel_workbook.R
Original file line number Diff line number Diff line change
@@ -50,8 +50,10 @@ write_excel_workbook <- function(x, path) {
wb <- openxlsx::createWorkbook("data")

# set style for numbers
number_style <- openxlsx::createStyle(numFmt = "NUMBER")
text_style <- openxlsx::createStyle(numFmt = "TEXT")
number_style <- openxlsx::createStyle(
numFmt = openxlsx::openxlsx_getOp("numFmt", "NUMBER"))
text_style <- openxlsx::createStyle(
numFmt = openxlsx::openxlsx_getOp("numFmt", "TEXT"))

# save data to sheets
for (i in seq_along(x)) {
4 changes: 2 additions & 2 deletions R/widget_solutionSettings_ui.R
Original file line number Diff line number Diff line change
@@ -445,15 +445,15 @@ solutionSettings_html <- function(id, style, class, ...) {
id = "view",
## single view
shiny::tabPanel(
title = "optimize single goals",
title = "single goals",
value = "single",
htmltools::tags$div(
class = "single-view"
)
),
## group view panel
shiny::tabPanel(
title = "optimize group goal",
title = "group goal",
value = "group",
htmltools::tags$div(
class = "group-view",
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/wheretowork.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/wtw_data.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/wtw_optimization.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/wtw_theory.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ articles:
wtw_data: wtw_data.html
wtw_optimization: wtw_optimization.html
wtw_theory: wtw_theory.html
last_built: 2024-11-07T20:30Z
last_built: 2024-12-12T21:37Z
urls:
reference: https://ncc-cnc.github.io/wheretowork/reference
article: https://ncc-cnc.github.io/wheretowork/articles
2 changes: 1 addition & 1 deletion docs/reference/CategoricalLegend.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/ContinuousLegend.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/Dataset.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/Exclude.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e601653

Please sign in to comment.