Skip to content

Commit

Permalink
Disable Apply Methods to Dataset button
Browse files Browse the repository at this point in the history
Added logic to disable Apply Methods to Dataset button when the inputs are not complete or the button is not useful.
  • Loading branch information
JamesBisese committed Dec 4, 2024
1 parent decf279 commit 4cd24e4
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions R/mod_censored_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ mod_censored_data_ui <- function(id) {
shiny::fluidRow(
column(
3,
shiny::actionButton(ns("apply_methods"), "Apply Methods to Dataset", style = "color: #fff; background-color: #337ab7; border-color: #2e6da4")
shiny::actionButton(
ns("apply_methods"),
"Apply Methods to Dataset",
disabled = TRUE,
style = "color: #fff; background-color: #337ab7; border-color: #2e6da4")
),
column(3, shiny::uiOutput(ns("undo_methods")))
),
Expand Down Expand Up @@ -99,7 +103,7 @@ mod_censored_data_ui <- function(id) {
mod_censored_data_server <- function(id, tadat) {
shiny::moduleServer(id, function(input, output, session) {
ns <- session$ns

# initialize dropdown values

# reactive values specific to this module
Expand Down Expand Up @@ -162,9 +166,9 @@ mod_censored_data_server <- function(id, tadat) {
if (is.null(init_val)) {
init_val <- 0.5
}
if (input$nd_method == nd_method_options[1]) {
if (input$nd_method == "Multiply detection limit by x") {
shiny::numericInput(ns("nd_mult"),
"Multiplier (x)",
"Non-Detect Multiplier (x)",
value = init_val,
min = 0
)
Expand All @@ -177,9 +181,9 @@ mod_censored_data_server <- function(id, tadat) {
if (is.null(init_val)) {
init_val <- 0.5
}
if (input$od_method == od_method_options[1]) {
if (input$od_method == "Multiply detection limit by x") {
shiny::numericInput(ns("od_mult"),
"Multiplier (x)",
"Over-Detect Multiplier (x)",
value = init_val,
min = 0
)
Expand Down Expand Up @@ -211,18 +215,44 @@ mod_censored_data_server <- function(id, tadat) {
# Make this part more concise?
shiny::observeEvent(input$nd_method, {
tadat$nd_method <- input$nd_method

if ((input$nd_method == "Multiply detection limit by x" && !is.numeric(input$nd_mult))
|| (input$nd_method == "No change" && input$od_method == "No change" )){
shinyjs::disable("apply_methods")
} else {
shinyjs::enable("apply_methods")
}
})

shiny::observeEvent(input$nd_mult, {
tadat$nd_mult <- input$nd_mult

if (input$nd_method == "Multiply detection limit by x" && !is.numeric(input$nd_mult)) {
shinyjs::disable("apply_methods")
} else {
shinyjs::enable("apply_methods")
}
})

shiny::observeEvent(input$od_method, {
tadat$od_method <- input$od_method

if ((input$od_method == "Multiply detection limit by x" && !is.numeric(input$od_mult))
|| (input$nd_method == "No change" && input$od_method == "No change" )){
shinyjs::disable("apply_methods")
} else {
shinyjs::enable("apply_methods")
}
})

shiny::observeEvent(input$od_mult, {
tadat$od_mult <- input$od_mult

if (input$od_method == "Multiply detection limit by x" && !is.numeric(input$od_mult)) {
shinyjs::disable("apply_methods")
} else {
shinyjs::enable("apply_methods")
}
})


Expand Down

0 comments on commit 4cd24e4

Please sign in to comment.