From 7d6a1adca2cedaae31c3345237b022d1deddd0f5 Mon Sep 17 00:00:00 2001 From: Jana Spinner <56519375+js3110@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:23:01 +0100 Subject: [PATCH 1/7] disable tabs until data mapped --- inst/shiny/modules/column_mapping.R | 6 ++++++ inst/shiny/server.R | 5 +++++ inst/shiny/ui.R | 7 ++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/inst/shiny/modules/column_mapping.R b/inst/shiny/modules/column_mapping.R index 827f1812..3064a423 100644 --- a/inst/shiny/modules/column_mapping.R +++ b/inst/shiny/modules/column_mapping.R @@ -277,6 +277,11 @@ column_mapping_server <- function(id, data, manual_units, on_submit) { observeEvent(input$submit_columns, { Sys.sleep(1) # Make this artificially slow to show the loading spinner + # Enable other tabs + shinyjs::enable(selector = "#page li a[data-value=nca]") + shinyjs::enable(selector = "#page li a[data-value=visualisation]") + shinyjs::enable(selector = "#page li a[data-value=tlgs]") + req(data()) dataset <- data() @@ -348,6 +353,7 @@ column_mapping_server <- function(id, data, manual_units, on_submit) { # Execute the callback function to change the tab on_submit() + }) list( diff --git a/inst/shiny/server.R b/inst/shiny/server.R index d9007009..06e60218 100644 --- a/inst/shiny/server.R +++ b/inst/shiny/server.R @@ -3,6 +3,11 @@ function(input, output, session) { log_info("Startup") + # Initially disable all tabs except the 'Data' tab + shinyjs::disable(selector = "#page li a[data-value=nca]") + shinyjs::disable(selector = "#page li a[data-value=visualisation]") + shinyjs::disable(selector = "#page li a[data-value=tlgs]") + # DATA ---- data_module <- tab_data_server("data") # Data set for analysis diff --git a/inst/shiny/ui.R b/inst/shiny/ui.R index 09e0c49d..f2a3e32c 100644 --- a/inst/shiny/ui.R +++ b/inst/shiny/ui.R @@ -23,11 +23,12 @@ fluidPage( # DATA ---- nav_panel( "Data", + value = "data", fluid = TRUE, tab_data_ui("data") ), # NCA ---- - nav_panel("NCA", fluid = TRUE, + nav_panel("NCA", value = "nca", fluid = TRUE, fluidPage( actionButton("nca", "Run NCA", class = "run-nca-btn"), @@ -221,12 +222,12 @@ fluidPage( ), # VISUALISATION ---- - nav_panel("Visualisation", + nav_panel("Visualisation", value = "visualisation", fluid = TRUE, tab_visuals_ui("visuals") ), # New TLG tab - nav_panel("TLG", + nav_panel("TLG", value = "tlgs", tab_tlg_ui("tlg") ) ), From a329d9894a5e382167c29e2b8374670b181f5999 Mon Sep 17 00:00:00 2001 From: Jana Spinner <56519375+js3110@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:26:17 +0100 Subject: [PATCH 2/7] fix lint --- inst/shiny/server.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/shiny/server.R b/inst/shiny/server.R index 06e60218..66c6ee6b 100644 --- a/inst/shiny/server.R +++ b/inst/shiny/server.R @@ -7,7 +7,7 @@ function(input, output, session) { shinyjs::disable(selector = "#page li a[data-value=nca]") shinyjs::disable(selector = "#page li a[data-value=visualisation]") shinyjs::disable(selector = "#page li a[data-value=tlgs]") - + # DATA ---- data_module <- tab_data_server("data") # Data set for analysis From 8f5f0f11a92e14cdd1d6ac9d3933ae20845f15f3 Mon Sep 17 00:00:00 2001 From: Spinner Date: Mon, 6 Jan 2025 16:26:49 +0100 Subject: [PATCH 3/7] fix: minor reformatting --- inst/shiny/modules/column_mapping.R | 6 +++--- inst/shiny/ui.R | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/inst/shiny/modules/column_mapping.R b/inst/shiny/modules/column_mapping.R index 3064a423..6772bb50 100644 --- a/inst/shiny/modules/column_mapping.R +++ b/inst/shiny/modules/column_mapping.R @@ -278,9 +278,9 @@ column_mapping_server <- function(id, data, manual_units, on_submit) { Sys.sleep(1) # Make this artificially slow to show the loading spinner # Enable other tabs - shinyjs::enable(selector = "#page li a[data-value=nca]") - shinyjs::enable(selector = "#page li a[data-value=visualisation]") - shinyjs::enable(selector = "#page li a[data-value=tlgs]") + purrr::walk(c("nca", "visualisation", "tlg"), \(tab) { + shinyjs::disable(selector = paste0("#page li a[data-value=", tab, "]")) + }) req(data()) dataset <- data() diff --git a/inst/shiny/ui.R b/inst/shiny/ui.R index f2a3e32c..6808e4ad 100644 --- a/inst/shiny/ui.R +++ b/inst/shiny/ui.R @@ -227,7 +227,7 @@ fluidPage( tab_visuals_ui("visuals") ), # New TLG tab - nav_panel("TLG", value = "tlgs", + nav_panel("TLG", value = "tlg", tab_tlg_ui("tlg") ) ), From 18ba1799e27d21b618fc0d7de48e6dd2b33cc941 Mon Sep 17 00:00:00 2001 From: Spinner Date: Tue, 7 Jan 2025 09:51:41 +0100 Subject: [PATCH 4/7] feat: conditional review tab --- inst/shiny/modules/column_mapping.R | 2 +- inst/shiny/modules/tab_data.R | 33 ++++++++++++++++++++--------- inst/shiny/server.R | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/inst/shiny/modules/column_mapping.R b/inst/shiny/modules/column_mapping.R index 6772bb50..6bae62d3 100644 --- a/inst/shiny/modules/column_mapping.R +++ b/inst/shiny/modules/column_mapping.R @@ -279,7 +279,7 @@ column_mapping_server <- function(id, data, manual_units, on_submit) { # Enable other tabs purrr::walk(c("nca", "visualisation", "tlg"), \(tab) { - shinyjs::disable(selector = paste0("#page li a[data-value=", tab, "]")) + shinyjs::enable(selector = paste0("#page li a[data-value=", tab, "]")) }) req(data()) diff --git a/inst/shiny/modules/tab_data.R b/inst/shiny/modules/tab_data.R index d61a5ff1..7d125028 100644 --- a/inst/shiny/modules/tab_data.R +++ b/inst/shiny/modules/tab_data.R @@ -8,7 +8,7 @@ source(system.file("/shiny/modules/column_mapping.R", package = "aNCA")) tab_data_ui <- function(id) { ns <- NS(id) - + navset_pill( id = ns("data_navset"), nav_panel("Raw Data Upload", @@ -39,14 +39,13 @@ tab_data_ui <- function(id) { ) ), nav_panel("Review Data", - "This is the data set that will be used for the analysis. - If you want to make any changes, please do so in the Mapping and Filters tab.", - reactableOutput(ns("data_processed")), - tags$script(HTML(" - $(document).ready(function(){ - $('[data-toggle=\"tooltip\"]').tooltip(); - }); - ")) + id = ns("data_navset-review"), + uiOutput(ns("reviewDataContent")), + tags$script(HTML(" + $(document).ready(function(){ + $('[data-toggle=\"tooltip\"]').tooltip(); + }); + ")) ) ) @@ -93,7 +92,7 @@ tab_data_server <- function(id) { height = "98vh" ) }) - + # Column Mapping ---- # Define the manual units for concentration, dose, and time in a format recognized by PKNCA @@ -120,6 +119,20 @@ tab_data_server <- function(id) { manual_units = manual_units, on_submit = change_to_review_tab ) + + output$reviewDataContent <- renderUI({ + if (!is.null(processed_data()) && nrow(processed_data()) > 0) { + tagList( + "This is the data set that will be used for the analysis. + If you would like to make any changes please return to the 'Mapping and Filters' tab.", + reactableOutput(ns("data_processed")) + ) + } else { + div( + "Please map your data in the 'Mapping and Filters' section before reviewing it." + ) + } + }) # Reactive value for the processed dataset processed_data <- column_mapping$processed_data diff --git a/inst/shiny/server.R b/inst/shiny/server.R index 66c6ee6b..25197db5 100644 --- a/inst/shiny/server.R +++ b/inst/shiny/server.R @@ -6,7 +6,7 @@ function(input, output, session) { # Initially disable all tabs except the 'Data' tab shinyjs::disable(selector = "#page li a[data-value=nca]") shinyjs::disable(selector = "#page li a[data-value=visualisation]") - shinyjs::disable(selector = "#page li a[data-value=tlgs]") + shinyjs::disable(selector = "#page li a[data-value=tlg]") # DATA ---- data_module <- tab_data_server("data") From be9a2b59ac4f4a3ef6c19ba5db4169f06d32581f Mon Sep 17 00:00:00 2001 From: Spinner Date: Tue, 7 Jan 2025 11:31:07 +0100 Subject: [PATCH 5/7] lintr fix --- inst/shiny/modules/tab_data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/shiny/modules/tab_data.R b/inst/shiny/modules/tab_data.R index 7d125028..60c8c058 100644 --- a/inst/shiny/modules/tab_data.R +++ b/inst/shiny/modules/tab_data.R @@ -119,7 +119,7 @@ tab_data_server <- function(id) { manual_units = manual_units, on_submit = change_to_review_tab ) - + output$reviewDataContent <- renderUI({ if (!is.null(processed_data()) && nrow(processed_data()) > 0) { tagList( From c04f19eaf4adb3a51abe05dd536cc3a3fc79f770 Mon Sep 17 00:00:00 2001 From: Spinner Date: Tue, 7 Jan 2025 11:39:34 +0100 Subject: [PATCH 6/7] fix lint again --- inst/shiny/modules/tab_data.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inst/shiny/modules/tab_data.R b/inst/shiny/modules/tab_data.R index 60c8c058..08831180 100644 --- a/inst/shiny/modules/tab_data.R +++ b/inst/shiny/modules/tab_data.R @@ -8,7 +8,7 @@ source(system.file("/shiny/modules/column_mapping.R", package = "aNCA")) tab_data_ui <- function(id) { ns <- NS(id) - + navset_pill( id = ns("data_navset"), nav_panel("Raw Data Upload", @@ -45,7 +45,8 @@ tab_data_ui <- function(id) { $(document).ready(function(){ $('[data-toggle=\"tooltip\"]').tooltip(); }); - ")) + ") + ) ) ) @@ -92,7 +93,7 @@ tab_data_server <- function(id) { height = "98vh" ) }) - + # Column Mapping ---- # Define the manual units for concentration, dose, and time in a format recognized by PKNCA From e8da278b79ac78fb18d7d8f7622d7afd0d1c319e Mon Sep 17 00:00:00 2001 From: Spinner Date: Tue, 7 Jan 2025 13:42:35 +0100 Subject: [PATCH 7/7] lint final --- inst/shiny/modules/tab_data.R | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/inst/shiny/modules/tab_data.R b/inst/shiny/modules/tab_data.R index 08831180..8d2b5748 100644 --- a/inst/shiny/modules/tab_data.R +++ b/inst/shiny/modules/tab_data.R @@ -39,14 +39,14 @@ tab_data_ui <- function(id) { ) ), nav_panel("Review Data", - id = ns("data_navset-review"), - uiOutput(ns("reviewDataContent")), - tags$script(HTML(" - $(document).ready(function(){ - $('[data-toggle=\"tooltip\"]').tooltip(); - }); - ") - ) + id = ns("data_navset-review"), + uiOutput(ns("reviewDataContent")), + tags$script(HTML(" + $(document).ready(function(){ + $('[data-toggle=\"tooltip\"]').tooltip(); + }); + ") + ) ) )