Commit 6f434dd372e84c78c801bca5ac40317d84745fd2

Authored by Gabriela Navarro
Committed by Fabio Teixeira
1 parent 0573a077

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
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
1 1 Executivo
2 2 Legislativo
3   -Judiciario
4   -Nao se aplica
  3 +Judiciário
  4 +Não se aplica
... ...
public/static/governmental_sphere.txt
1 1 Federal
2 2 Estadual
3 3 Distrital
4   -Municipal
5 4 \ No newline at end of file
  5 +Municipal
... ...
public/static/juridical_nature.txt
1   -Administracao Direta
  1 +Administração Direta
2 2 Autarquia
3   -Empresa Publica
4   -Fundacao
5   -Orgao Autonomo
  3 +Empresa Pública
  4 +Fundação
  5 +Orgão Autônomo
6 6 Sociedade
7 7 Sociedade Civil
8 8 Sociedade de Economia Mista
... ...
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%>
... ...