From 69a8326fbc3f69f150dd30048c889d99dec995a5 Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Tue, 2 Nov 2021 14:42:52 +0100 Subject: [PATCH] presets: Improve performance --- R/preset_editor.R | 67 +++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/R/preset_editor.R b/R/preset_editor.R index aa66bb1..b24384d 100644 --- a/R/preset_editor.R +++ b/R/preset_editor.R @@ -18,35 +18,40 @@ preset_editor_ui <- function(id) { "Customize" = "custom" ) ), - conditionalPanel( - sprintf("input['%s'] == 'custom'", NS(id, "preset")), - shinyWidgets::pickerInput( - inputId = NS(id, "species"), - label = "Included species", - choices = species_choices, - selected = species_replicative, - options = list( - "actions-box" = TRUE, - "live-search" = TRUE + tabsetPanel( + id = NS(id, "customization"), + type = "hidden", + tabPanelBody(value = "none"), + tabPanelBody( + value = "custom", + shinyWidgets::pickerInput( + inputId = NS(id, "species"), + label = "Included species", + choices = species_choices, + selected = species_replicative, + options = list( + "actions-box" = TRUE, + "live-search" = TRUE + ), + multiple = TRUE ), - multiple = TRUE - ), - shinyWidgets::pickerInput( - inputId = NS(id, "reference_genes"), - label = "Reference genes", - choices = gene_choices, - selected = genes_tpe_old, - options = list( - "actions-box" = TRUE, - "live-search" = TRUE + shinyWidgets::pickerInput( + inputId = NS(id, "reference_genes"), + label = "Reference genes", + choices = gene_choices, + selected = genes_tpe_old, + options = list( + "actions-box" = TRUE, + "live-search" = TRUE + ), + multiple = TRUE ), - multiple = TRUE - ), - actionButton( - NS(id, "apply_button"), - "Perform analysis", - class = "btn-primary", - style = "margin-top: 16px; margin-bottom: 16px" + actionButton( + NS(id, "apply_button"), + "Perform analysis", + class = "btn-primary", + style = "margin-top: 16px; margin-bottom: 16px" + ) ) ) ) @@ -62,11 +67,17 @@ preset_editor_server <- function(id) { result <- reactiveVal(preset_replicative_species) observeEvent(input$preset, { - if (input$preset == "replicative") { + panel <- if (input$preset == "replicative") { result(preset_replicative_species) + "none" } else if (input$preset == "all") { result(preset_all_species) + "none" + } else { + "custom" } + + updateTabsetPanel(session, "customization", selected = panel) }) observeEvent(input$apply_button, {