From 0a648f92f033c29759f8b0927ecbfd3a2622468c Mon Sep 17 00:00:00 2001 From: Craig Williams Date: Tue, 10 Feb 2026 16:20:54 +0000 Subject: [PATCH] Bug fixes: - Fixed hover style of selected table row - Fixed loading and saving of db actuals location - Fixed approved checks for organsiations - Fixed what_if name for application state --- R/db_actuals.R | 30 +++++++++++++++++------------- R/db_applications.R | 2 +- R/db_organisations.R | 5 +++++ inst/www/css/mnr-shiny.css | 6 +++++- inst/www/css/mnr.css | 12 +++++++----- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/R/db_actuals.R b/R/db_actuals.R index 6dad327..cf67ac7 100644 --- a/R/db_actuals.R +++ b/R/db_actuals.R @@ -21,18 +21,15 @@ MNR.DB.Actuals <- R6::R6Class( geom, date = occurrence_date ) %>% + dplyr::arrange(proposed_activity_ref, dplyr::desc(date)) %>% dplyr::collect() %>% dplyr::glimpse() }, selectProposedActuals = function(refs) { partA <- private$db_client$table("proposed_activities") %>% + dplyr::filter(is.null(deleted_at), is.null(cancelled_at)) %>% dplyr::filter(ref %in% !!refs) %>% - dplyr::select(ref, application_id) %>% - dplyr::left_join( - private$db_client$table("applications") %>% - dplyr::select(id, location_id), - by = c(application_id = "id") - ) %>% + dplyr::select(ref, application_id, location_id) %>% dplyr::inner_join( private$db_client$table("locations") %>% dplyr::filter( @@ -57,13 +54,9 @@ MNR.DB.Actuals <- R6::R6Class( geom = geom ) partB <- private$db_client$table("proposed_activities") %>% + dplyr::filter(is.null(deleted_at), is.null(cancelled_at)) %>% dplyr::filter(ref %in% !!refs) %>% - dplyr::select(ref, application_id) %>% - dplyr::left_join( - private$db_client$table("applications") %>% - dplyr::select(id, location_id), - by = c(application_id = "id") - ) %>% + dplyr::select(ref, application_id, location_id) %>% dplyr::inner_join( private$db_client$table("locations") %>% dplyr::filter(area_type == "Shapefile"), @@ -83,7 +76,7 @@ MNR.DB.Actuals <- R6::R6Class( geom = tolower( sf::st_as_binary(geom.sf, EWKB = TRUE, hex = TRUE, srid = 4326) ), - geom = set_class(geom, "pq_geometry"), + geom = magrittr::set_class(geom, "pq_geometry"), geom.sf = NULL ) %>% dplyr::transmute( @@ -105,8 +98,14 @@ MNR.DB.Actuals <- R6::R6Class( self$deleteActuals(unique(actuals.sf$ref)) + refs_with_actuals <- actuals.sf %>% + tidyr::unnest(dates) %>% + dplyr::filter(!is.na(dates)) %>% + dplyr::pull(ref) + actuals <- actuals.sf %>% tibble::as_tibble() %>% + dplyr::filter(ref %in% refs_with_actuals) %>% dplyr::mutate( area_type = dplyr::if_else( sf::st_is_empty(geom), "O&G Blocks", "Coordinates" @@ -114,6 +113,11 @@ MNR.DB.Actuals <- R6::R6Class( geom = sf::st_as_binary(geom, EWKB = TRUE, hex = TRUE) ) + if (nrow(actuals) == 0) { + cat("## No actuals to insert\n") + return(TRUE) + } + cat("## Inserting locations for actuals\n") location_rows <- actuals %>% dplyr::select(area_type, geom) %>% diff --git a/R/db_applications.R b/R/db_applications.R index c5612f2..b66f199 100644 --- a/R/db_applications.R +++ b/R/db_applications.R @@ -166,7 +166,7 @@ MNR.DB.Applications <- R6::R6Class( closed = FALSE, cancelled = FALSE, deleted = FALSE, - whatif = FALSE, + what_if = FALSE, voluntary = FALSE, consented = FALSE, multiyear = FALSE, diff --git a/R/db_organisations.R b/R/db_organisations.R index 99558b9..00b97cd 100644 --- a/R/db_organisations.R +++ b/R/db_organisations.R @@ -90,11 +90,13 @@ MNR.DB.Organisations <- R6::R6Class( dplyr::mutate(known_as = paste(first_name, last_name)) %>% dplyr::left_join( private$db_client$table("organisation_members") %>% + dplyr::filter(flag_approved == TRUE) %>% dplyr::select(user_id, organisation_id), by = c(id = "user_id") ) %>% dplyr::inner_join( private$db_client$table("organisations") %>% + dplyr::filter(flag_approved == TRUE) %>% dplyr::filter((id == !!org_id) | (name == !!org_name)) %>% dplyr::select(id), by = c(organisation_id = "id") @@ -169,6 +171,7 @@ MNR.DB.Organisations <- R6::R6Class( dplyr::filter(flag_approved == TRUE) %>% dplyr::inner_join( private$db_client$table("organisation_agents") %>% + dplyr::filter(flag_approved == TRUE) %>% dplyr::filter(organisation_id %in% !!org_ids) %>% dplyr::select(agent_id) %>% dplyr::collapse(), @@ -198,6 +201,7 @@ MNR.DB.Organisations <- R6::R6Class( dplyr::filter(flag_approved == TRUE) %>% dplyr::inner_join( private$db_client$table("organisation_agents") %>% + dplyr::filter(flag_approved == TRUE) %>% dplyr::filter(agent_id %in% !!org_id) %>% dplyr::select(organisation_id) %>% dplyr::collapse(), @@ -227,6 +231,7 @@ MNR.DB.Organisations <- R6::R6Class( dplyr::filter(flag_approved == TRUE) %>% dplyr::left_join( private$db_client$table("organisation_members") %>% + dplyr::filter(flag_approved == TRUE) %>% dplyr::select(user_id, organisation_id), by = c(id = "organisation_id") ) %>% diff --git a/inst/www/css/mnr-shiny.css b/inst/www/css/mnr-shiny.css index 8199d90..fb8fee6 100644 --- a/inst/www/css/mnr-shiny.css +++ b/inst/www/css/mnr-shiny.css @@ -1,8 +1,12 @@ div.selectize-input > div.item { - line-height: 41px; + line-height: 27px; } input[type="text"], input[type="password"], input[type="number"] { font-size: 12pt !important; height: 41px !important; +} + +.selectize-input input[type="text"] { + height: 27px !important; } \ No newline at end of file diff --git a/inst/www/css/mnr.css b/inst/www/css/mnr.css index d528843..bac7ae5 100644 --- a/inst/www/css/mnr.css +++ b/inst/www/css/mnr.css @@ -85,17 +85,19 @@ h6 { } -.table.dataTable tbody td.active, -.table.dataTable tbody tr.active td { +.table.dataTable > tbody > td.active, +.table.dataTable > tbody > tr.active td { background-color: #3f9c35 !important; } -table.dataTable tbody tr.selected > * { +table.dataTable > tbody > tr.selected > * { box-shadow: inset 0 0 0 9999px #3f9c35 !important; } -table.dataTable.hover tbody tr.selected:hover > *, -table.dataTable.display tbody tr.selected:hover > * { +table.dataTable.hover > tbody > tr.even.selected:hover > *, +table.dataTable.display > tbody > tr.even.selected:hover > *, +table.dataTable.hover > tbody > tr.odd.selected:hover > *, +table.dataTable.display > tbody > tr.odd.selected:hover > * { box-shadow: inset 0 0 0 9999px #44a939 !important; }