From 1c6fd4dea9a4650966ae1b902897fb75a67d287c Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 10 Oct 2012 15:50:16 -0500 Subject: Got a rudimentary version of the validation code for block samples by index completed --- .../static/new/javascript/show_trait.coffee | 31 ++-------------------- .../wqflask/static/new/javascript/show_trait.js | 14 ---------- .../static/new/javascript/validation.coffee | 19 +++++++++++++ wqflask/wqflask/templates/base.html | 6 ++--- wqflask/wqflask/templates/show_trait.html | 13 ++++++--- 5 files changed, 33 insertions(+), 50 deletions(-) create mode 100644 wqflask/wqflask/static/new/javascript/validation.coffee diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee index 9498a1bb..a22a3beb 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee @@ -9,7 +9,7 @@ $ -> for x in [start..10] $("#stats_tabs" + x).hide() - hide_tabs(1) + #hide_tabs(1) # Changes stats table between all, bxd only and non-bxd, etc. stats_mdp_change = -> @@ -17,7 +17,7 @@ $ -> hide_tabs(0) $("#stats_tabs" + selected).show() - $(".stats_mdp").change(stats_mdp_change) + #$(".stats_mdp").change(stats_mdp_change) change_stats_value = (sample_sets, category, value_type, decimal_places)-> id = "#" + process_id(category, value_type) @@ -238,33 +238,6 @@ $ -> $('#Other_'+index.toString()).find('.trait_value_input').val("x") $('#block_by_index').click(block_by_index) - - #validate_block_index = -> - # $('#remove_samples_field').valid( - # rules: - # field: - # required: true - # number: true - # messages: - # field: - # "Please check that your input is valid." - # ) - - $('#trait_data_form').validate() - - $('#remove_samples_field').valid( - rules: - field: - required: true - number: true - messages: - field: - "Please check that your input is valid." - ) - - #$('#remove_samples_field').change(validate_block_index) - - ##End Block Samples By Index Code diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 5704e183..d6c5226f 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -20,14 +20,12 @@ } return _results; }; - hide_tabs(1); stats_mdp_change = function() { var selected; selected = $(this).val(); hide_tabs(0); return $("#stats_tabs" + selected).show(); }; - $(".stats_mdp").change(stats_mdp_change); change_stats_value = function(sample_sets, category, value_type, decimal_places) { var current_value, id, in_box, the_value; id = "#" + process_id(category, value_type); @@ -281,18 +279,6 @@ return _results; }; $('#block_by_index').click(block_by_index); - $('#trait_data_form').validate(); - $('#remove_samples_field').valid({ - rules: { - field: { - required: true, - number: true - } - }, - messages: { - field: "Please check that your input is valid." - } - }); hide_no_value = function() { var _this = this; return $('.value_se').each(function(index, element) { diff --git a/wqflask/wqflask/static/new/javascript/validation.coffee b/wqflask/wqflask/static/new/javascript/validation.coffee new file mode 100644 index 00000000..f389254e --- /dev/null +++ b/wqflask/wqflask/static/new/javascript/validation.coffee @@ -0,0 +1,19 @@ +$ -> + + remove_samples_is_valid = (input)-> + return $.isNumeric(input) + + #invalidate_block_by_index = -> + # $('#remove_samples_invalid').show() + + validate_remove_samples = -> + input = $('#remove_samples_field').val() + console.log("input is:", input) + $('#remove_samples_invalid').hide() + if remove_samples_is_valid(input) + console.log("input is valid") + else + console.log("input isn't valid") + $('#remove_samples_invalid').show() + + $('#remove_samples_field').change(validate_remove_samples) \ No newline at end of file diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 2e30b1b2..f52041b1 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -12,22 +12,22 @@ + - + - + - @@ -817,7 +817,7 @@
@@ -1214,8 +1214,12 @@