Commit dbae4eee91c4a5bdc46eee8707607887a216ae45
Committed by
Paulo Meireles
1 parent
e8569682
Exists in
master
and in
28 other branches
[Mezuro] Added validation to reading
Showing
4 changed files
with
19 additions
and
4 deletions
Show diff stats
plugins/mezuro/public/javascripts/validations.js
... | ... | @@ -2,6 +2,7 @@ jQuery(function (){ |
2 | 2 | jQuery('#range_submit').live("click", validate_new_range_configuration); |
3 | 3 | jQuery('#metric_configuration_submit').live("click", validate_metric_configuration); |
4 | 4 | jQuery('#repository_submit').live("click", validate_new_repository); |
5 | + jQuery('#reading_submit').live("click", validate_new_reading); | |
5 | 6 | }); |
6 | 7 | |
7 | 8 | function validate_code(code){ |
... | ... | @@ -19,6 +20,17 @@ function allRequiredFieldsAreFilled() { |
19 | 20 | return true; |
20 | 21 | } |
21 | 22 | |
23 | +function validate_new_reading() { | |
24 | + var name = jQuery('#reading_label').val(); | |
25 | + var grade = jQuery('#reading_grade').val(); | |
26 | + var color = jQuery('#reading_color').val(); | |
27 | + if (is_null(name) || is_null(grade) || is_null(color)){ | |
28 | + alert("Please fill all fields marked with (*)."); | |
29 | + return false; | |
30 | + } | |
31 | + return true; | |
32 | +} | |
33 | + | |
22 | 34 | function validate_new_repository() { |
23 | 35 | if (allRequiredFieldsAreFilled()) { |
24 | 36 | return addressAndTypeMatch(); | ... | ... |
plugins/mezuro/views/mezuro_plugin_reading/_form.html.erb
1 | 1 | <%= hidden_field_tag :id, @reading_group_content.id %> |
2 | 2 | |
3 | -<%= required labelled_form_field _('label:'), f.text_field(:label) %> | |
3 | +<%= required labelled_form_field _('Label:'), f.text_field(:label) %> | |
4 | 4 | |
5 | -<%= required labelled_form_field _('grade:'), | |
6 | -f.text_field(:grade) %> | |
5 | +<%= required labelled_form_field _('Grade:'), f.text_field(:grade) %> | |
7 | 6 | |
8 | -<%= required labelled_form_field _('color:'), | |
7 | +<%= required labelled_form_field _('Color:'), | |
9 | 8 | colorpicker_field(:reading, :color) %>Click in the field to change Color |
10 | 9 | |
11 | 10 | <p><%= f.submit "Save" %></p> | ... | ... |
plugins/mezuro/views/mezuro_plugin_reading/edit.html.erb
1 | 1 | <script src="/javascripts/colorpicker.js" type="text/javascript"></script> |
2 | 2 | <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> |
3 | +<script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script> | |
4 | + | |
3 | 5 | <h2><%= link_to("#{@reading_group_content.name} Reading Group", @reading_group_content.view_url) %></h2> |
4 | 6 | |
5 | 7 | <% form_for :reading, :url => {:action =>"save", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_reading/new.html.erb
1 | 1 | <script src="/javascripts/colorpicker.js" type="text/javascript"></script> |
2 | 2 | <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> |
3 | +<script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script> | |
4 | + | |
3 | 5 | <h2><%= link_to("#{@reading_group_content.name} Reading Group", @reading_group_content.view_url) %></h2> |
4 | 6 | |
5 | 7 | <% form_for :reading, :url => {:action =>"save", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> | ... | ... |