Commit 1c94ea329b53fcc625d27800f3f0765598b7912f
Exists in
master
and in
29 other branches
Merge branch 'mezuro-dev' of gitorious.org:+mezuro/noosfero/mezuro into mezuro-dev
Showing
5 changed files
with
80 additions
and
7 deletions
Show diff stats
@@ -0,0 +1,68 @@ | @@ -0,0 +1,68 @@ | ||
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 | + | ||
8 | +function validate_metric_configuration(){ | ||
9 | + var code = jQuery('#metric_configuration_code').val(); | ||
10 | + if (is_null(code)) | ||
11 | + { | ||
12 | + alert("Code must be filled out"); | ||
13 | + return false; | ||
14 | + } | ||
15 | + return true; | ||
16 | +} | ||
17 | + | ||
18 | +function is_null(value){ | ||
19 | + if(value == "" || value == null){ | ||
20 | + return true; | ||
21 | + } | ||
22 | + return false; | ||
23 | +} | ||
24 | + | ||
25 | +function IsNotNumeric(value){ | ||
26 | + if(value.match(/[0-9]*\.?[0-9]+/)) | ||
27 | + { | ||
28 | + return false; | ||
29 | + } | ||
30 | + return true; | ||
31 | +} | ||
32 | + | ||
33 | +function IsNotHexadecimal(value){ | ||
34 | + if(value.match(/[0-9a-fA-F]{1,8}/)) | ||
35 | + { | ||
36 | + return false; | ||
37 | + } | ||
38 | + return true; | ||
39 | +} | ||
40 | + | ||
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(); | ||
47 | + | ||
48 | + if (is_null(label) || is_null(beginning) || is_null(end) || is_null(color) || is_null(grade)) | ||
49 | + { | ||
50 | + alert("Please fill all fields marked with (*)"); | ||
51 | + return false; | ||
52 | + } | ||
53 | + if (IsNotNumeric(beginning) || IsNotNumeric(end) || IsNotNumeric(grade)) | ||
54 | + { | ||
55 | + alert("Beginning, End and Grade must be numeric values"); | ||
56 | + return false; | ||
57 | + } | ||
58 | + if (beginning > end) | ||
59 | + { | ||
60 | + alert("End must be greater than Beginning"); | ||
61 | + return false; | ||
62 | + } | ||
63 | + if (IsNotHexadecimal(color)){ | ||
64 | + alert("Color must be an hexadecimal value"); | ||
65 | + return false; | ||
66 | + } | ||
67 | + return true; | ||
68 | +} |
plugins/mezuro/views/mezuro_plugin_myprofile/_range_form.html.erb
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <table> | 3 | <table> |
4 | <tr> | 4 | <tr> |
5 | <td> | 5 | <td> |
6 | - <%= f.label :label, "Label:" %> | 6 | + <%= f.label :label, "(*) Label:" %> |
7 | </td> | 7 | </td> |
8 | <td> | 8 | <td> |
9 | <%= f.text_field :label %> | 9 | <%= f.text_field :label %> |
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | </tr> | 11 | </tr> |
12 | <tr> | 12 | <tr> |
13 | <td> | 13 | <td> |
14 | - <%= f.label :beginning, "Beginning:" %> | 14 | + <%= f.label :beginning, "(*) Beginning:" %> |
15 | </td> | 15 | </td> |
16 | <td> | 16 | <td> |
17 | <%= f.text_field :beginning %> | 17 | <%= f.text_field :beginning %> |
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | </tr> | 19 | </tr> |
20 | <tr> | 20 | <tr> |
21 | <td> | 21 | <td> |
22 | - <%= f.label :end, "End:" %> | 22 | + <%= f.label :end, "(*) End:" %> |
23 | </td> | 23 | </td> |
24 | <td> | 24 | <td> |
25 | <%= f.text_field :end %> | 25 | <%= f.text_field :end %> |
@@ -27,7 +27,7 @@ | @@ -27,7 +27,7 @@ | ||
27 | </tr> | 27 | </tr> |
28 | <tr> | 28 | <tr> |
29 | <td> | 29 | <td> |
30 | - <%= f.label :grade, "Grade:" %> | 30 | + <%= f.label :grade, "(*) Grade:" %> |
31 | </td> | 31 | </td> |
32 | <td> | 32 | <td> |
33 | <%= f.text_field :grade %> | 33 | <%= f.text_field :grade %> |
@@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||
35 | </tr> | 35 | </tr> |
36 | <tr> | 36 | <tr> |
37 | <td> | 37 | <td> |
38 | - <%= f.label :color, "Color:" %> | 38 | + <%= f.label :color, "(*) Color:" %> |
39 | </td> | 39 | </td> |
40 | <td> | 40 | <td> |
41 | <%= f.text_field :color %> | 41 | <%= f.text_field :color %> |
plugins/mezuro/views/mezuro_plugin_myprofile/edit_metric_configuration.html.erb
1 | +<script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script> | ||
2 | + | ||
1 | <h2><%= @configuration_name %> Configuration</h2> | 3 | <h2><%= @configuration_name %> Configuration</h2> |
2 | 4 | ||
3 | <% form_for :metric_configuration, :url => {:action =>"update_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> | 5 | <% form_for :metric_configuration, :url => {:action =>"update_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> |
plugins/mezuro/views/mezuro_plugin_myprofile/new_metric_configuration.html.erb
1 | +<script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script> | ||
2 | + | ||
3 | + | ||
1 | <h2><%= @configuration_name %> Configuration</h2> | 4 | <h2><%= @configuration_name %> Configuration</h2> |
2 | 5 | ||
3 | -<% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> | 6 | +<% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> |
4 | <%= hidden_field_tag :configuration_name, @configuration_name %> | 7 | <%= hidden_field_tag :configuration_name, @configuration_name %> |
5 | <%= hidden_field_tag :scope, @metric.scope %> | 8 | <%= hidden_field_tag :scope, @metric.scope %> |
6 | 9 |
plugins/mezuro/views/mezuro_plugin_myprofile/new_range.rjs
1 | -page.replace_html 'range_form', :partial => "new_range", :locals => {:metric_name => @metric_name, :configuration_name => @configuration_name, :beginning_id => "bolinha" } | 1 | +page.replace_html 'range_form', :partial => "new_range", :locals => {:metric_name => @metric_name, :configuration_name => @configuration_name, :beginning_id => "bolinha" } #FIXME |
2 | page.visual_effect :slide_down, "range_form" | 2 | page.visual_effect :slide_down, "range_form" |