From 7ab83016009d683a7f936f21d043643abd670d0c Mon Sep 17 00:00:00 2001 From: memgonzales Date: Wed, 5 Jun 2024 23:58:01 +0800 Subject: [PATCH] Fix display of error message (invalid additional genes) when Reset All Analyses button is clicked --- callbacks/coexpression/callbacks.py | 22 ---------------------- callbacks/homepage/callbacks.py | 29 ++++++++++++++++++++++++++++- callbacks/tf_enrich/callbacks.py | 4 ++-- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/callbacks/coexpression/callbacks.py b/callbacks/coexpression/callbacks.py index 6f7b6f1c..0efd20c3 100644 --- a/callbacks/coexpression/callbacks.py +++ b/callbacks/coexpression/callbacks.py @@ -233,28 +233,6 @@ def display_coexpression_output(coexpression_is_submitted): else: return {"display": "none"} - @app.callback( - Output("coexpression-addl-genes-error", "style"), - Output("coexpression-addl-genes-error", "children"), - Input("homepage-is-resetted", "data"), - ) - def clear_coexpression_error_messages(homepage_is_resetted): - """ - Clears coexpression input error - - Parameters: - - homepage_is_resetted: Saved boolean value of resetted analysis - - Returns: - - ('coexpression-addl-genes-error', 'style'): {'display': 'block'} for displaying the coexpression error container; otherwise {'display': 'none'} - - ('coexpression-addl-genes-error', 'children'): None for no error message - """ - - if homepage_is_resetted: - return {"display": "none"}, None - - raise PreventUpdate - @app.callback( Output("coexpression-submit", "disabled"), Input("coexpression-submit", "n_clicks"), diff --git a/callbacks/homepage/callbacks.py b/callbacks/homepage/callbacks.py index f4ae8295..0b45be7c 100644 --- a/callbacks/homepage/callbacks.py +++ b/callbacks/homepage/callbacks.py @@ -89,6 +89,10 @@ def display_specific_analysis_page( Output("session-container", "children", allow_duplicate=True), Output("input-error", "children"), Output("input-error", "style"), + Output("coexpression-addl-genes-error", "children", allow_duplicate=True), + Output("coexpression-addl-genes-error", "style", allow_duplicate=True), + Output("tfbs-addl-genes-error", "children", allow_duplicate=True), + Output("tfbs-addl-genes-error", "style", allow_duplicate=True), Output("homepage-is-submitted", "data"), Output("homepage-submitted-genomic-intervals", "data"), Output("homepage-is-resetted", "data"), @@ -132,7 +136,18 @@ def parse_input(nb_intervals_str, n_clicks, n_submit, dccStore_children, *_): # clear data for items in dcc.Store found in session-container dccStore_children = clear_specific_dccStore_data(dccStore_children, "") - return dccStore_children, None, {"display": "none"}, False, "", True + return ( + dccStore_children, + None, + {"display": "none"}, + None, + {"display": "none"}, + None, + {"display": "none"}, + False, + "", + True, + ) # Parses the genomic interval input if n_submit >= 1 or ("homepage-submit" == ctx.triggered_id and n_clicks >= 1): @@ -148,6 +163,10 @@ def parse_input(nb_intervals_str, n_clicks, n_submit, dccStore_children, *_): get_error_message(intervals[0]), ], {"display": "block"}, + None, + {"display": "none"}, + None, + {"display": "none"}, False, nb_intervals_str, True, @@ -162,6 +181,10 @@ def parse_input(nb_intervals_str, n_clicks, n_submit, dccStore_children, *_): dccStore_children, None, {"display": "none"}, + None, + {"display": "none"}, + None, + {"display": "none"}, True, nb_intervals_str, True, @@ -171,6 +194,10 @@ def parse_input(nb_intervals_str, n_clicks, n_submit, dccStore_children, *_): dccStore_children, [f"Error: Input for genomic interval should not be empty."], {"display": "block"}, + None, + {"display": "none"}, + None, + {"display": "none"}, False, nb_intervals_str, True, diff --git a/callbacks/tf_enrich/callbacks.py b/callbacks/tf_enrich/callbacks.py index 30d3556d..171476e5 100644 --- a/callbacks/tf_enrich/callbacks.py +++ b/callbacks/tf_enrich/callbacks.py @@ -54,8 +54,8 @@ def display_input(nb_intervals_str, homepage_is_submitted, *_): Output("tfbs-combined-genes", "data", allow_duplicate=True), Output("tfbs-submitted-set", "data", allow_duplicate=True), Output("tfbs-submitted-prediction-technique", "data", allow_duplicate=True), - Output("tfbs-addl-genes-error", "style"), - Output("tfbs-addl-genes-error", "children"), + Output("tfbs-addl-genes-error", "style", allow_duplicate=True), + Output("tfbs-addl-genes-error", "children", allow_duplicate=True), Input("tfbs-submit", "n_clicks"), State("homepage-is-submitted", "data"), State("homepage-submitted-genomic-intervals", "data"),