Skip to content

Commit 0924177

Browse files
committed
Update defaults and fix first drop-down
1 parent 792223e commit 0924177

1 file changed

Lines changed: 25 additions & 60 deletions

File tree

R/mod_edish.R

Lines changed: 25 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,6 @@ edish_UI <- function(module_id,
7373

7474
ns <- shiny::NS(module_id)
7575

76-
drop_menu_options <- shinyWidgets::dropMenuOptions(
77-
popperOptions = list(
78-
modifiers = list(
79-
preventOverflow = list(
80-
enabled = TRUE,
81-
boundariesElement = "scrollParent",
82-
priority = list("left", "right", "bottom", "top")
83-
)
84-
)
85-
)
86-
)
87-
88-
drop_menu_style <- "max-height: 85vh; overflow-y: auto; overflow-x: hidden; padding: 10px;"
89-
9076
drop_menu <- shinyWidgets::dropMenu(
9177
tag = shiny::actionButton(
9278
inputId = ns(EDISH$PLOT_OPTIONS_ID),
@@ -104,11 +90,23 @@ edish_UI <- function(module_id,
10490
choices = arm_default_vals,
10591
selected = arm_default_vals,
10692
multiple = TRUE
107-
),
108-
options = drop_menu_options,
109-
style = drop_menu_style
93+
)
11094
)
11195

96+
drop_menu_options <- shinyWidgets::dropMenuOptions(
97+
popperOptions = list(
98+
modifiers = list(
99+
preventOverflow = list(
100+
enabled = TRUE,
101+
boundariesElement = "scrollParent",
102+
priority = list("left", "right", "bottom", "top")
103+
)
104+
)
105+
)
106+
)
107+
108+
drop_menu_style <- "max-height: 85vh; overflow-y: auto; overflow-x: hidden; padding: 10px;"
109+
112110
drop_menu_x <- shinyWidgets::dropMenu(
113111
tag = shiny::actionButton(
114112
inputId = ns(EDISH$X_OPTIONS_ID),
@@ -320,18 +318,10 @@ edish_server <- function(
320318
ref_lines <- if (input[[EDISH$X_ABS_ID]]) abs_ref_lines else norm_ref_lines
321319
ref_val <- as.list(ref_lines)[[input[[EDISH$X_AXIS_ID]]]]
322320

323-
# Deal with cases without look-up values
324-
if (is.null(ref_val)) {
325-
if (!input[[EDISH$X_ABS_ID]] && is.null(norm_ref_lines)) {
326-
# Use default when normalized reference line values not provided
327-
ref_val <- EDISH$DEFAULT_X_REF_NORM
328-
} else if (input[[EDISH$X_ABS_ID]] && is.null(abs_ref_lines)) {
329-
# Use default when absolute reference line values not provided
330-
ref_val <- EDISH$DEFAULT_X_REF_ABS
331-
} else {
332-
ref_val <- NA
333-
}
334-
}
321+
# Assign default for cases without look-up values
322+
if (is.null(ref_val)) ref_val <- ifelse(input[[EDISH$X_ABS_ID]],
323+
EDISH$DEFAULT_X_REF_ABS,
324+
EDISH$DEFAULT_X_REF_NORM)
335325
}
336326

337327
unit_text <- {
@@ -359,18 +349,10 @@ edish_server <- function(
359349
ref_lines <- if (input[[EDISH$Y_ABS_ID]]) abs_ref_lines else norm_ref_lines
360350
ref_val <- as.list(ref_lines)[[input[[EDISH$Y_AXIS_ID]]]]
361351

362-
# Deal with cases without look-up values
363-
if (is.null(ref_val)) {
364-
if (!input[[EDISH$Y_ABS_ID]] && is.null(norm_ref_lines)) {
365-
# Use default when normalized reference line values not provided
366-
ref_val <- EDISH$DEFAULT_Y_REF_NORM
367-
} else if (input[[EDISH$Y_ABS_ID]] && is.null(abs_ref_lines)) {
368-
# Use default when absolute reference line values not provided
369-
ref_val <- EDISH$DEFAULT_Y_REF_ABS
370-
} else {
371-
ref_val <- NA
372-
}
373-
}
352+
# Assign default for cases without look-up values
353+
if (is.null(ref_val)) ref_val <- ifelse(input[[EDISH$Y_ABS_ID]],
354+
EDISH$DEFAULT_Y_REF_ABS,
355+
EDISH$DEFAULT_Y_REF_NORM)
374356
}
375357

376358
unit_text <- {
@@ -397,15 +379,8 @@ edish_server <- function(
397379
} else {
398380
ref_val <- as.list(uln_multiples)[[input[[EDISH$X_AXIS_ID]]]]
399381

400-
# Deal with cases without look-up values
401-
if (is.null(ref_val)) {
402-
if (is.null(uln_multiples)) {
403-
# Use default when ULN multiples not provided
404-
ref_val <- EDISH$DEFAULT_ULN_MULTIPLE
405-
} else {
406-
ref_val <- NA
407-
}
408-
}
382+
# Assign default for cases without look-up values
383+
if (is.null(ref_val)) ref_val <- EDISH$DEFAULT_ULN_MULTIPLE
409384
}
410385

411386
shinyWidgets::updateNumericInputIcon(
@@ -468,16 +443,6 @@ edish_server <- function(
468443

469444
shiny::onRestore(function(state) {
470445

471-
if (FALSE) {
472-
formatted_text <- paste(capture.output(print(state$input)), collapse = "\n")
473-
shiny::showModal(shiny::modalDialog(
474-
title = "Session Restored!",
475-
tags$pre(formatted_text),
476-
easyClose = TRUE,
477-
footer = modalButton("Got it")
478-
))
479-
}
480-
481446
if (length(state$input) > 0) {
482447

483448
# Store arm selections from restored bookmarked state, to be applied after work data has been created

0 commit comments

Comments
 (0)