From 557428ce5c4df45f1f5b731df93e173770feb86c Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 25 Oct 2019 13:20:32 -0500 Subject: Added sub-categories to drop-down menu for Group option --- wqflask/wqflask/api/gen_menu.py | 9 +++-- .../new/javascript/dataset_select_menu_orig.js | 46 +++++++++++++++++++--- 2 files changed, 45 insertions(+), 10 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py index 078e3782..1b2818ca 100644 --- a/wqflask/wqflask/api/gen_menu.py +++ b/wqflask/wqflask/api/gen_menu.py @@ -71,15 +71,16 @@ def get_groups(species): # GROUP by InbredSet.Name # ORDER BY InbredSet.FullName""".format(species_name)).fetchall() - results = g.db.execute("""SELECT InbredSet.Name, InbredSet.FullName + results = g.db.execute("""SELECT InbredSet.Name, InbredSet.FullName, IFNULL(InbredSet.Family, 'None') FROM InbredSet, Species WHERE Species.Name = '{}' AND InbredSet.SpeciesId = Species.Id GROUP by InbredSet.Name - ORDER BY InbredSet.FullName""".format(species_name)).fetchall() + ORDER BY IFNULL(InbredSet.Family, InbredSet.FullName) ASC, InbredSet.FullName ASC""".format(species_name)).fetchall() for result in results: - groups[species_name].append([str(result[0]), str(result[1])]) + family_name = "Family:" + str(result[2]) + groups[species_name].append([str(result[0]), str(result[1]), family_name]) return groups @@ -89,7 +90,7 @@ def get_types(groups): for species, group_dict in groups.iteritems(): types[species] = {} - for group_name, _group_full_name in group_dict: + for group_name, _group_full_name, _family_name in group_dict: if phenotypes_exist(group_name): types[species][group_name] = [("Phenotypes", "Phenotypes")] if genotypes_exist(group_name): diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js index b80539bd..93964916 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js @@ -61,12 +61,45 @@ redo_dropdown = function(dropdown, items) { console.log("in redo:", dropdown, items); dropdown.empty(); _results = []; - for (_i = 0, _len = items.length; _i < _len; _i++) { - item = items[_i]; - if (item.length > 2){ - _results.push(dropdown.append($("") + } else if (current_family != "" && item[2] == current_family){ + this_opt_group.append($("") + } else { + _results.push(dropdown.append($("