Commit f6e2305dcd826aeedb6fc2312b413db0e345b31f
Committed by
Diego Camarinha
1 parent
78a21cb7
Exists in
master
and in
29 other branches
[Mezuro] Finished validating fields for new range and metric configuration.
Showing
4 changed files
with
18 additions
and
12 deletions
Show diff stats
plugins/mezuro/public/javascripts/validations.js
1 | +jQuery(function (){ | |
2 | + jQuery('#range_submit').live("click", validate_new_range_configuration); | |
3 | + jQuery('#metric_configuration_submit').live("click", validate_metric_configuration); | |
4 | +}); | |
5 | + | |
6 | + | |
7 | + | |
1 | 8 | function validate_metric_configuration(){ |
2 | - var code=document.forms["configuration_form"]["metric_configuration[code]"].value; | |
9 | + var code = jQuery('#metric_configuration_code').val(); | |
3 | 10 | if (is_null(code)) |
4 | 11 | { |
5 | 12 | alert("Code must be filled out"); |
6 | 13 | return false; |
7 | 14 | } |
15 | + return true; | |
8 | 16 | } |
9 | 17 | |
10 | 18 | function is_null(value){ |
... | ... | @@ -30,14 +38,12 @@ function IsNotHexadecimal(value){ |
30 | 38 | return true; |
31 | 39 | } |
32 | 40 | |
33 | -function validate_new_range_configuration(){ | |
34 | - var label = document.forms["new_range_form"]["range[label]"].value; | |
35 | - var beginning = document.forms["new_range_form"]["range[beginning]"].value; | |
36 | - var end = document.forms["new_range_form"]["range[end]"].value; | |
37 | - var color = document.forms["new_range_form"]["range[color]"].value; | |
38 | - var grade = document.forms["new_range_form"]["range[grade]"].value; | |
39 | - | |
40 | - return false; | |
41 | +function validate_new_range_configuration(event){ | |
42 | + var label = jQuery("#range_label").val(); | |
43 | + var beginning = jQuery("#range_beginning").val(); | |
44 | + var end = jQuery("#range_end").val(); | |
45 | + var color = jQuery("#range_color").val(); | |
46 | + var grade = jQuery("#range_grade").val(); | |
41 | 47 | |
42 | 48 | if (is_null(label) || is_null(beginning) || is_null(end) || is_null(color) || is_null(grade)) |
43 | 49 | { | ... | ... |
plugins/mezuro/views/mezuro_plugin_myprofile/_edit_range.html.erb
1 | -<% remote_form_for :range, :url => {:action =>"update_range", :controller => "mezuro_plugin_myprofile"}, :method => :get, :html => { :name => "new_range_form", :onSubmit => 'return validate_new_range_configuration()'} do |f| %> | |
1 | +<% remote_form_for :range, :url => {:action =>"update_range", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> | |
2 | 2 | <%= hidden_field_tag :beginning_id, beginning_id %> |
3 | 3 | <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :configuration_name => configuration_name, :beginning_id => beginning_id, :range => range } %> |
4 | 4 | <% end %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_myprofile/_new_range.html.erb
1 | -<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_myprofile"}, :method => :get, :html => { :name => "new_range_form", :onSubmit => 'return validate_new_range_configuration()'} do |f| %> | |
1 | +<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> | |
2 | 2 | <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :configuration_name => configuration_name } %> |
3 | 3 | <% end %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_myprofile/new_metric_configuration.html.erb
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | |
4 | 4 | <h2><%= @configuration_name %> Configuration</h2> |
5 | 5 | |
6 | -<% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get, :html => { :name => "configuration_form", :onSubmit => 'return validate_metric_configuration()'} do |f| %> | |
6 | +<% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> | |
7 | 7 | <%= hidden_field_tag :configuration_name, @configuration_name %> |
8 | 8 | <%= hidden_field_tag :scope, @metric.scope %> |
9 | 9 | ... | ... |