Commit 6f434dd372e84c78c801bca5ac40317d84745fd2
Committed by
Fabio Teixeira
1 parent
0573a077
Exists in
master
and in
3 other branches
Fix some institution problems:
-Add the create institution option on admin panel -Fix some accentuation issues. Still needs to make the seed.rb file to populate the DB with the initial options -Add cancel button on the create institution form
Showing
6 changed files
with
33 additions
and
11 deletions
Show diff stats
lib/gov_user_plugin.rb
... | ... | @@ -137,6 +137,18 @@ class GovUserPlugin < Noosfero::Plugin |
137 | 137 | ) |
138 | 138 | end |
139 | 139 | |
140 | + def admin_panel_links | |
141 | + [ | |
142 | + { | |
143 | + :title => _('Create Institution'), | |
144 | + :url => { | |
145 | + :controller => 'gov_user_plugin', | |
146 | + :action => 'create_institution_admin' | |
147 | + } | |
148 | + } | |
149 | + ] | |
150 | + end | |
151 | + | |
140 | 152 | protected |
141 | 153 | |
142 | 154 | def profile_required_list | ... | ... |
public/static/governmental_powers.txt
public/static/governmental_sphere.txt
public/static/juridical_nature.txt
public/views/create-institution.js
... | ... | @@ -125,6 +125,11 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] |
125 | 125 | }); |
126 | 126 | } |
127 | 127 | |
128 | + function cancel_institution(evt){ | |
129 | + evt.preventDefault(); | |
130 | + $('#institution_dialog').dialog('close'); | |
131 | + } | |
132 | + | |
128 | 133 | |
129 | 134 | function institution_already_exists(){ |
130 | 135 | if( this.value.length >= 3 ) { |
... | ... | @@ -187,8 +192,6 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] |
187 | 192 | |
188 | 193 | |
189 | 194 | function add_new_institution(evt) { |
190 | - (" JAJAjAjAJAJaJ ADD NEW INST") | |
191 | - | |
192 | 195 | evt.preventDefault(); |
193 | 196 | var selected = $("#institution_selected"); |
194 | 197 | var institution_already_added = $(".institutions_added li[data-institution='"+selected.val()+"']").length; |
... | ... | @@ -227,6 +230,8 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] |
227 | 230 | var cnpj = $("#institutions_cnpj").parent().parent(); |
228 | 231 | var city = $("#community_city").parent().parent(); |
229 | 232 | var state = $("#community_state").parent().parent(); |
233 | + var inst_type = $("input[name='institutions[type]']:checked").val(); | |
234 | + institution_type_actions(inst_type) | |
230 | 235 | |
231 | 236 | if( country === "-1" ) $("#community_country").val("BR"); |
232 | 237 | |
... | ... | @@ -243,7 +248,8 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] |
243 | 248 | |
244 | 249 | |
245 | 250 | function institution_type_actions(type) { |
246 | - if( type === "PublicInstitution" ) { | |
251 | + var country = $("#community_country").val(); | |
252 | + if( type === "PublicInstitution" && country == "BR") { | |
247 | 253 | show_public_institutions_fields(); |
248 | 254 | } else { |
249 | 255 | show_private_institutions_fields(); |
... | ... | @@ -255,6 +261,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] |
255 | 261 | var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); |
256 | 262 | var default_option = SelectElement.generateOption("BR", "Brazil"); |
257 | 263 | |
264 | + | |
258 | 265 | var inst_type = $("input[name='institutions[type]']:checked").val(); |
259 | 266 | var country = $("#community_country").val(); |
260 | 267 | |
... | ... | @@ -282,6 +289,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] |
282 | 289 | }); |
283 | 290 | |
284 | 291 | $('#save_institution_button').click(save_institution); |
292 | + $('#cancel_institution_button').click(cancel_institution); | |
285 | 293 | |
286 | 294 | $("#community_name").keyup(institution_already_exists); |
287 | 295 | ... | ... |
views/gov_user_plugin/_institution.html.erb
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | <span class='required-field'> |
65 | 65 | <div class="formfield"> |
66 | 66 | <label for="community_state" class="formlabel"><%= _("State") %></label> |
67 | - <%= f.select(:state, @state_list.collect {|state| [state.name, state.name]}) %> | |
67 | + <%= f.select(:state, [[_('Select a state'), '-1']] | @state_list.collect {|state| [state.name, state.name]}) %> | |
68 | 68 | </div> |
69 | 69 | </span> |
70 | 70 | |
... | ... | @@ -115,9 +115,11 @@ |
115 | 115 | |
116 | 116 | <% if @url_token == "create_institution_admin" %> |
117 | 117 | <%= submit_button :save, _('Save') %> |
118 | + <%= button(:cancel, _("Cancel"), {:controller => "admin_panel", :action => 'index'}) %> | |
118 | 119 | <%else%> |
119 | 120 | <div> |
120 | 121 | <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> |
122 | + <%= link_to(_('Cancel'), '#', :id=>"cancel_institution_button", :class=>'button with-text icon-cancel') %> | |
121 | 123 | </div> |
122 | 124 | <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> |
123 | 125 | <%end%> | ... | ... |