From 890427d945da9d25b1eb204fac2fd49dd07685c9 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 3 Oct 2012 17:25:42 -0500 Subject: Finishing getting the exclude by attribute value function working --- .../static/new/javascript/show_trait.coffee | 34 +++++++++++-------- .../wqflask/static/new/javascript/show_trait.js | 39 +++++++--------------- wqflask/wqflask/templates/show_trait.html | 16 +++++---- 3 files changed, 42 insertions(+), 47 deletions(-) diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee index e22f1c21..29489fb9 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee @@ -178,7 +178,8 @@ $ -> for own key, attribute_info of js_data.attribute_names sample_attributes[attribute_info.name] = attribute_info.distinct_values console.log("[visa] attributes is:", sample_attributes) - selected_attribute = $('#exclude_menu').val() + selected_attribute = $('#exclude_menu').val().replace("_", " ") + console.log("selected_attribute is:", selected_attribute) for value in sample_attributes[selected_attribute] $(create_value_dropdown(value)) .appendTo($('#attribute_values')) @@ -191,20 +192,27 @@ $ -> ##Block Samples By Attribute Value Code block_by_attribute_value = -> - console.log("in beginning of bbav code") attribute_name = $('#exclude_menu').val() - console.log("attribute_name is:", attribute_name) exclude_by_value = $('#attribute_values').val() - console.log("exclude_by_value is:", exclude_by_value) - sample_lists = js_data['sample_lists'] - console.log("sample_lists is:", sample_lists) - for sample_list in sample_lists - for sample in sample_list - console.log("sample is:", sample) - if sample.extra_attributes[attribute_name] == exclude_by_value - console.log("is exclude_by_value") - sample_row = $('') - + + cell_class = ".column_name-#{attribute_name}" + $(cell_class).each (index, element)=> + if $.trim($(element).text()) == exclude_by_value + row = $(element).parent('tr') + $(row).find(".trait_value_input").val("x") + + #sample_lists = js_data['sample_lists'] + #console.log("sample_lists is:", sample_lists) + #for sample_list in sample_lists + # for sample in sample_list + # console.log("sample is:", sample) + # if sample.extra_attributes[attribute_name] == exclude_by_value + # console.log("is exclude_by_value") + # console.log("sample.name is:", sample.name) + # attr_cell = $('td:contains('+sample.name+')').parent().find('td.column_name-'+ attribute_name) + # console.log("attr_cell is:", attr_cell) + # value_cell = attr_cell.parent().find('td.column_name-Value') + # value_cell.children('input').val("x") $('#exclude_group').click(block_by_attribute_value) diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 65440427..a5582519 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -211,7 +211,8 @@ sample_attributes[attribute_info.name] = attribute_info.distinct_values; } console.log("[visa] attributes is:", sample_attributes); - selected_attribute = $('#exclude_menu').val(); + selected_attribute = $('#exclude_menu').val().replace("_", " "); + console.log("selected_attribute is:", selected_attribute); _ref1 = sample_attributes[selected_attribute]; _results = []; for (_i = 0, _len = _ref1.length; _i < _len; _i++) { @@ -223,34 +224,18 @@ populate_sample_attributes_values_dropdown(); $('#exclude_menu').change(populate_sample_attributes_values_dropdown); block_by_attribute_value = function() { - var attribute_name, exclude_by_value, sample, sample_list, sample_lists, sample_row, _i, _len, _results; - console.log("in beginning of bbav code"); + var attribute_name, cell_class, exclude_by_value, + _this = this; attribute_name = $('#exclude_menu').val(); - console.log("attribute_name is:", attribute_name); exclude_by_value = $('#attribute_values').val(); - console.log("exclude_by_value is:", exclude_by_value); - sample_lists = js_data['sample_lists']; - console.log("sample_lists is:", sample_lists); - _results = []; - for (_i = 0, _len = sample_lists.length; _i < _len; _i++) { - sample_list = sample_lists[_i]; - _results.push((function() { - var _j, _len1, _results1; - _results1 = []; - for (_j = 0, _len1 = sample_list.length; _j < _len1; _j++) { - sample = sample_list[_j]; - console.log("sample is:", sample); - if (sample.extra_attributes[attribute_name] === exclude_by_value) { - console.log("is exclude_by_value"); - _results1.push(sample_row = $('')); - } else { - _results1.push(void 0); - } - } - return _results1; - })()); - } - return _results; + cell_class = ".column_name-" + attribute_name; + return $(cell_class).each(function(index, element) { + var row; + if ($.trim($(element).text()) === exclude_by_value) { + row = $(element).parent('tr'); + return $(row).find(".trait_value_input").val("x"); + } + }); }; $('#exclude_group').click(block_by_attribute_value); console.log("before registering show_hide_outliers"); diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index 0ef86685..f85cf98e 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -1229,10 +1229,11 @@
{% if sample_groups[0].attributes %} -   Block samples by index:     +   Block samples by group:     - + {{ sample.name }} {# Todo: Add IDs #} - + {# Todo: Add IDs #} - + + {{ sample.extra_attributes[sample_type.attributes[attribute].name] }} {% endfor %} -- cgit v1.2.3