Commit 152c4ed698096355e61803ed6d320d841ab11d15

Authored by Braulio Bhavamitra
Committed by Rafael Martins
1 parent 540b2236

Always shows fields for localization even if not enabled

app/controllers/my_profile/maps_controller.rb
... ... @@ -6,18 +6,13 @@ class MapsController < MyProfileController
6 6 @profile_data = profile
7 7 if request.post?
8 8 begin
9   - national_code = nil
10   - country = params[:profile_data][:country]
11   - city = params[:profile_data][:city]
12   - state = params[:profile_data][:state]
13   -
  9 + country = params[:profile_data][:country]
  10 + city = params[:profile_data][:city]
  11 + state = params[:profile_data][:state]
14 12 nregion = NationalRegion.validate!(city, state, country)
15   -
16   - if nregion != nil
17   - national_code = nregion.national_region_code
  13 + unless nregion.blank?
  14 + params[:profile_data][:national_region_code] = nregion.national_region_code
18 15 end
19   -
20   - params[:profile_data]["national_region_code"] = national_code
21 16  
22 17 Profile.transaction do
23 18 if profile.update_attributes!(params[:profile_data])
... ... @@ -26,9 +21,7 @@ class MapsController < MyProfileController
26 21 end
27 22 end
28 23 rescue Exception => exc
29   -
30 24 flash[:error] = exc.message
31   -
32 25 end
33 26 end
34 27 end
... ...
app/views/maps/edit_location.rhtml
... ... @@ -5,11 +5,11 @@
5 5 <% form_for :profile_data, :url => {:action => 'edit_location'} do |f| %>
6 6  
7 7 <div id='location-fields'>
8   - <%= optional_field(profile, 'country', select_country(_('Country'), 'profile_data', 'country', {:class => 'type-select'})) %>
9   - <%= optional_field(profile, 'state', labelled_form_field(_('State'), f.text_field(:state))) %>
10   - <%= optional_field(profile, 'city', labelled_form_field(_('City'), f.text_field(:city))) %>
11   - <%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(:profile_data, :zip_code))) %>
12   - <%= optional_field(profile, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address))) %>
  8 + <%= select_country _('Country'), 'profile_data', 'country', {:class => 'type-select'} %>
  9 + <%= labelled_form_field _('State'), f.text_field(:state) %>
  10 + <%= labelled_form_field _('City'), f.text_field(:city) %>
  11 + <%= labelled_form_field _('ZIP code'), text_field(:profile_data, :zip_code) %>
  12 + <%= labelled_form_field _('Address (street and number)'), text_field(:profile_data, :address) %>
13 13 <% button_bar do %>
14 14 <%= button_to_function :search, _('Locate in the map'), "codeAddress()", :title => _("Locate the address informed above in the map below (note that you'll probably need to adjust the marker to get a precise position)") %>
15 15 <%= submit_button 'save', _('Save') %>
... ... @@ -23,14 +23,12 @@
23 23  
24 24 <%= f.hidden_field(:lat) %>
25 25 <%= f.hidden_field(:lng) %>
26   -
27 26  
28 27 <% button_bar do %>
29 28 <%= submit_button 'save', _('Save') %>
30 29 <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %>
31 30 <% end %>
32 31  
33   -
34 32 <% end %>
35 33  
36 34 <%= render :partial => 'google_map'%>
... ...