Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Disallow user to check NCA / Outputs tabs without mapping data #152

Merged
merged 7 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions inst/shiny/modules/column_mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
purrr::walk(c("nca", "visualisation", "tlg"), \(tab) {
shinyjs::enable(selector = paste0("#page li a[data-value=", tab, "]"))
})

req(data())
dataset <- data()

Expand Down Expand Up @@ -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(
Expand Down
28 changes: 21 additions & 7 deletions inst/shiny/modules/tab_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ 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")),
id = ns("data_navset-review"),
uiOutput(ns("reviewDataContent")),
tags$script(HTML("
$(document).ready(function(){
$('[data-toggle=\"tooltip\"]').tooltip();
});
"))
$(document).ready(function(){
$('[data-toggle=\"tooltip\"]').tooltip();
});
")
)
)
)

Expand Down Expand Up @@ -121,6 +121,20 @@ tab_data_server <- function(id) {
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

Expand Down
5 changes: 5 additions & 0 deletions inst/shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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=tlg]")

# DATA ----
data_module <- tab_data_server("data")
# Data set for analysis
Expand Down
7 changes: 4 additions & 3 deletions inst/shiny/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),

Expand Down Expand Up @@ -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 = "tlg",
tab_tlg_ui("tlg")
)
),
Expand Down
Loading