aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/api/gen_menu.py9
-rw-r--r--wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js46
2 files changed, 45 insertions, 10 deletions
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($("<option data-id=\""+item[0]+"\" />").val(item[1]).text(item[2])));
- } else {
- _results.push(dropdown.append($("<option />").val(item[0]).text(item[1])));
+
+ if (dropdown.attr('id') == "group"){
+ group_family_list = [];
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
+ item = items[_i];
+ group_family = item[2].split(":")[1]
+ if (group_family != "None"){
+ group_family_list.push([item[0], item[1], group_family, group_family])
+ } else {
+ group_family_list.push([item[0], item[1], group_family, item[1]])
+ }
+ }
+
+ group_family_list.sort(function(a, b){return a[3] > b[3]})
+ current_family = ""
+ this_opt_group = null
+ for (_i = 0, _len = group_family_list.length; _i < _len; _i++) {
+ item = group_family_list[_i];
+ if (item[2] != "None" && current_family == ""){
+ current_family = item[2]
+ this_opt_group = $("<optgroup label=\"" + item[2] + "\">")
+ } else if (current_family != "" && item[2] == current_family){
+ this_opt_group.append($("<option />").val(item[0]).text(item[1]));
+ } else if (current_family != "" && item[2] != "None"){
+ current_family = item[2]
+ _results.push(dropdown.append(this_opt_group))
+ this_opt_group = $("<optgroup label=\"" + item[2] + "\">")
+ } else {
+ _results.push(dropdown.append($("<option />").val(item[0]).text(item[1])));
+ }
+ }
+ } else {
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
+ item = items[_i];
+ if (item.length > 2){
+ _results.push(dropdown.append($("<option data-id=\""+item[0]+"\" />").val(item[1]).text(item[2])));
+ } else {
+ _results.push(dropdown.append($("<option />").val(item[0]).text(item[1])));
+ }
}
}
return _results;
@@ -143,6 +176,7 @@ apply_default = function() {
dataset: "HC_M2_0606_P"
};
}
+
_ref = [['species', 'group'], ['group', 'type'], ['type', 'dataset'], ['dataset', null]];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {