Commit 80db92cc2fef121689f6fa2caaed8a61dc3731de
Committed by
Gabriela Navarro
1 parent
760ea10e
Exists in
master
and in
5 other branches
fix_institution: Change state to select field and correct country bug
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
3 changed files
with
23 additions
and
6 deletions
Show diff stats
controllers/mpog_software_plugin_controller.rb
| ... | ... | @@ -40,6 +40,7 @@ class MpogSoftwarePluginController < ApplicationController |
| 40 | 40 | |
| 41 | 41 | def create_institution |
| 42 | 42 | @show_sisp_field = environment.admins.include?(current_user.person) |
| 43 | + @estate_list = get_state_list() | |
| 43 | 44 | |
| 44 | 45 | if request.xhr? |
| 45 | 46 | render :layout=>false |
| ... | ... | @@ -57,6 +58,7 @@ class MpogSoftwarePluginController < ApplicationController |
| 57 | 58 | |
| 58 | 59 | def create_institution_admin |
| 59 | 60 | @show_sisp_field = environment.admins.include?(current_user.person) |
| 61 | + @estate_list = get_state_list() | |
| 60 | 62 | |
| 61 | 63 | @url_token = split_http_referer request.original_url() |
| 62 | 64 | end |
| ... | ... | @@ -143,7 +145,7 @@ class MpogSoftwarePluginController < ApplicationController |
| 143 | 145 | def get_brazil_states |
| 144 | 146 | redirect_to "/" unless request.xhr? |
| 145 | 147 | |
| 146 | - state_list = NationalRegion.find(:all, :conditions=>["national_region_type_id = ?", 2], :order=>"name") | |
| 148 | + state_list = get_state_list() | |
| 147 | 149 | render :json=>state_list.collect {|state| state.name }.to_json |
| 148 | 150 | end |
| 149 | 151 | |
| ... | ... | @@ -175,6 +177,10 @@ class MpogSoftwarePluginController < ApplicationController |
| 175 | 177 | |
| 176 | 178 | protected |
| 177 | 179 | |
| 180 | + def get_state_list | |
| 181 | + NationalRegion.find(:all, :conditions=>["national_region_type_id = ?", 2], :order=>"name") | |
| 182 | + end | |
| 183 | + | |
| 178 | 184 | def private_create_institution |
| 179 | 185 | community = Community.new(params[:community]) |
| 180 | 186 | community.environment = environment | ... | ... |
public/mpog-institution-validations.js
| ... | ... | @@ -4,6 +4,8 @@ |
| 4 | 4 | |
| 5 | 5 | jQuery.get("/plugin/mpog_software/create_institution", function(response){ |
| 6 | 6 | jQuery("#institution_dialog").html(response); |
| 7 | + | |
| 8 | + set_form_count_custom_data(); | |
| 7 | 9 | set_events(); |
| 8 | 10 | |
| 9 | 11 | jQuery("#institution_dialog").dialog({ |
| ... | ... | @@ -212,10 +214,12 @@ |
| 212 | 214 | var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); |
| 213 | 215 | var default_option = SelectElement.generateOption("BR", "Brazil"); |
| 214 | 216 | |
| 215 | - jQuery('#community_country').find("option[value='']").remove(); | |
| 216 | - jQuery('#community_country').prepend(divisor_option); | |
| 217 | - jQuery('#community_country').prepend(default_option); | |
| 218 | - jQuery('#community_country').val("BR"); | |
| 217 | + if( jQuery('#community_country').find("option[value='']").length == 1 ) { | |
| 218 | + jQuery('#community_country').find("option[value='']").remove(); | |
| 219 | + jQuery('#community_country').prepend(divisor_option); | |
| 220 | + jQuery('#community_country').prepend(default_option); | |
| 221 | + jQuery('#community_country').val("BR"); | |
| 222 | + } | |
| 219 | 223 | } |
| 220 | 224 | |
| 221 | 225 | function set_events() { | ... | ... |
views/mpog_software_plugin/_institution.html.erb
| ... | ... | @@ -51,7 +51,14 @@ |
| 51 | 51 | </span> |
| 52 | 52 | |
| 53 | 53 | <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %> |
| 54 | - <%= required f.text_field(:state) %> | |
| 54 | + | |
| 55 | + <span class='required-field'> | |
| 56 | + <div class="formfield"> | |
| 57 | + <label for="community_state" class="formlabel"><%= _("State") %></label> | |
| 58 | + <%= f.select(:state, @estate_list.collect {|state| [state.name, state.name]}) %> | |
| 59 | + </div> | |
| 60 | + </span> | |
| 61 | + | |
| 55 | 62 | <%= required f.text_field(:city) %> |
| 56 | 63 | |
| 57 | 64 | ... | ... |