From 05ede8b20b88284dae97d632da6e57248053cefd Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 3 Apr 2019 11:39:30 -0500 Subject: Fixed issue where strains could be added twice in the SNP browser, causing some wonky behavior --- wqflask/wqflask/snp_browser/snp_browser.py | 4 ++-- wqflask/wqflask/templates/snp_browser.html | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py index 820551eb..1e28add8 100644 --- a/wqflask/wqflask/snp_browser/snp_browser.py +++ b/wqflask/wqflask/snp_browser/snp_browser.py @@ -479,7 +479,7 @@ class SnpBrowser(object): the_bases = [] for j, item in enumerate(allele_value_list): - if item: + if item and isinstance(item, str): this_base = [item, base_color_dict[item]] else: this_base = "" @@ -614,7 +614,7 @@ class SnpBrowser(object): this_allele_list = [] for item in self.allele_list: - if item and (item.lower() not in this_allele_list) and (item != "-"): + if item and isinstance(item, str) and (item.lower() not in this_allele_list) and (item != "-"): this_allele_list.append(item.lower()) total_allele_count = len(this_allele_list) diff --git a/wqflask/wqflask/templates/snp_browser.html b/wqflask/wqflask/templates/snp_browser.html index 9c549ab5..9d85f767 100644 --- a/wqflask/wqflask/templates/snp_browser.html +++ b/wqflask/wqflask/templates/snp_browser.html @@ -454,17 +454,22 @@ $("input[name=add_strain]").click(function() { var selected_strain = $("select[name=strains] option:selected").val(); - $("#chosen_strains_select").append(""); var current_species = $("#species_select").val(); if (current_species == "Mouse") { stored_strains = $("input[name=chosen_strains_mouse]").val().split(",") - stored_strains.push(selected_strain) - $("input[name=chosen_strains_mouse]").val(stored_strains.join(",")) + if (!(stored_strains.includes(selected_strain))){ + stored_strains.push(selected_strain) + $("input[name=chosen_strains_mouse]").val(stored_strains.join(",")) + $("#chosen_strains_select").append(""); + } } else if (current_species == "Rat") { stored_strains = $("input[name=chosen_strains_rat]").val().split(",") - stored_strains.push(selected_strain) - $("input[name=chosen_strains_rat]").val(stored_strains.join(",")) + if (!(stored_strains.includes(selected_strain))){ + stored_strains.push(selected_strain) + $("input[name=chosen_strains_rat]").val(stored_strains.join(",")) + $("#chosen_strains_select").append(""); + } } }); -- cgit v1.2.3