Commit c1483b12ca31574a1934c39447d43a71fb94f904
1 parent
afe6caef
Exists in
institution_modal_on_rating
Update organization ratings and gov_user
- Removed confirmation modal for institution creation - Fix institution validation - Fix "add" button behavior Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com> Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
Showing
2 changed files
with
9 additions
and
21 deletions
Show diff stats
src/noosfero-spb/gov_user/lib/ext/organization_rating.rb
@@ -13,7 +13,8 @@ OrganizationRating.class_eval do | @@ -13,7 +13,8 @@ OrganizationRating.class_eval do | ||
13 | def verify_institution | 13 | def verify_institution |
14 | if self.institution != nil | 14 | if self.institution != nil |
15 | institution = Institution.find_by_id self.institution.id | 15 | institution = Institution.find_by_id self.institution.id |
16 | - self.errors.add :institution, _("not found") unless institution | 16 | + self.errors.add :institution, _("institution not found") unless institution |
17 | + return !!institution | ||
17 | end | 18 | end |
18 | end | 19 | end |
19 | 20 |
src/noosfero-spb/gov_user/public/views/create-institution.js
@@ -17,8 +17,8 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -17,8 +17,8 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
17 | }; | 17 | }; |
18 | 18 | ||
19 | function set_institution_field_name(name) { | 19 | function set_institution_field_name(name) { |
20 | - $("#input_institution").attr("value", ""); | ||
21 | $("#input_institution").attr("value", name); | 20 | $("#input_institution").attr("value", name); |
21 | + $("#input_institution").autocomplete("search"); | ||
22 | } | 22 | } |
23 | 23 | ||
24 | function open_create_institution_modal(evt) { | 24 | function open_create_institution_modal(evt) { |
@@ -99,13 +99,14 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -99,13 +99,14 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
99 | var institution_name = response.institution_data.name; | 99 | var institution_name = response.institution_data.name; |
100 | var institution_id = response.institution_data.id; | 100 | var institution_id = response.institution_data.id; |
101 | 101 | ||
102 | - $("#institution_dialog").html("<div class='errorExplanation'><h2>"+response.message+"</h2></div>"); | ||
103 | - $("#create_institution_errors").switchClass("show-field", "hide-field"); | 102 | + set_institution_field_name($("#community_name").val()); |
104 | 103 | ||
104 | + $("#create_institution_errors").switchClass("show-field", "hide-field"); | ||
105 | $(".institution_container").append(get_clone_institution_data(institution_id)); | 105 | $(".institution_container").append(get_clone_institution_data(institution_id)); |
106 | add_selected_institution_to_list(institution_id, institution_name); | 106 | add_selected_institution_to_list(institution_id, institution_name); |
107 | 107 | ||
108 | $(".remove-institution").click(remove_institution); | 108 | $(".remove-institution").click(remove_institution); |
109 | + $('#institution_dialog').dialog('close'); | ||
109 | } else { | 110 | } else { |
110 | var errors = create_error_list(response); | 111 | var errors = create_error_list(response); |
111 | $("#create_institution_errors").switchClass("hide-field", "show-field").html("<h2>"+response.message+"</h2>"+errors); | 112 | $("#create_institution_errors").switchClass("hide-field", "show-field").html("<h2>"+response.message+"</h2>"+errors); |
@@ -233,23 +234,6 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -233,23 +234,6 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
233 | 234 | ||
234 | toggle_extra_fields_style_status(true); | 235 | toggle_extra_fields_style_status(true); |
235 | $("#create_institution_link").click(open_create_institution_modal); | 236 | $("#create_institution_link").click(open_create_institution_modal); |
236 | - } else { | ||
237 | - $("li.ui-menu-item a.ui-corner-all").click(function() { | ||
238 | - $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); | ||
239 | - $("#create_institution_link").remove(); | ||
240 | - toggle_extra_fields_style_status(false); | ||
241 | - }); | ||
242 | - $("li.ui-menu-item a.ui-corner-all").keypress(function(e) { | ||
243 | - alert(e); | ||
244 | - var key = e.keyCode; | ||
245 | - alert(key); | ||
246 | - if(key == 13) { | ||
247 | - $("li.ui-menu-item a.ui-corner-all").click(); | ||
248 | - } | ||
249 | - }); | ||
250 | - //$('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); | ||
251 | - //$("#create_institution_link").remove(); | ||
252 | - //toggle_extra_fields_style_status(false); | ||
253 | } | 237 | } |
254 | }, | 238 | }, |
255 | error: function(ajax, stat, errorThrown) { | 239 | error: function(ajax, stat, errorThrown) { |
@@ -261,6 +245,9 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -261,6 +245,9 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
261 | minLength: 2, | 245 | minLength: 2, |
262 | 246 | ||
263 | select : function (event, selected) { | 247 | select : function (event, selected) { |
248 | + $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); | ||
249 | + $("#create_institution_link").remove(); | ||
250 | + toggle_extra_fields_style_status(false); | ||
264 | $("#institution_selected").val(selected.item.id).attr("data-name", selected.item.label); | 251 | $("#institution_selected").val(selected.item.id).attr("data-name", selected.item.label); |
265 | } | 252 | } |
266 | }); | 253 | }); |