Commit 21153d137c8b6adb78a88bd3dea86860e8e8e1be

Authored by Victor Costa
1 parent ba1e746f

rails3: fix change image from profile

app/models/person.rb
1 # A person is the profile of an user holding all relationships with the rest of the system 1 # A person is the profile of an user holding all relationships with the rest of the system
2 class Person < Profile 2 class Person < Profile
3 3
4 - attr_accessible :organization, :contact_information, :sex, :birth_date 4 + attr_accessible :organization, :contact_information, :sex, :birth_date, :professional_activity
5 5
6 SEARCH_FILTERS += %w[ 6 SEARCH_FILTERS += %w[
7 more_popular 7 more_popular
app/views/shared/_change_image.html.erb
1 <%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %> 1 <%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %>
2 - <%= link_to_function(_('Cancel'), nil, :id => 'cancel-change-image-link', :class => 'button icon-cancel with-text', :style => 'display: none') do |page|  
3 - page['change-image-link'].show  
4 - page['change-image'].replace_html ''  
5 - end %> 2 + <%= link_to_function(_('Cancel'), "jQuery('#change-image-link').show(); jQuery('#change-image').html('')", :id => 'cancel-change-image-link', :class => 'button icon-cancel with-text', :style => 'display: none') %>
app/views/shared/_show_thumbnail.html.erb
@@ -2,10 +2,15 @@ @@ -2,10 +2,15 @@
2 2
3 <br/> 3 <br/>
4 4
5 - <%= link_to_function(_('Change image'), nil, :id => 'change-image-link', :class => 'button icon-photos with-text') do |page|  
6 - page['change-image'].replace_html :partial => 'shared/change_image', :locals => { :i => i, :image => image }  
7 - page['change-image-link'].hide  
8 - page['cancel-change-image-link'].show  
9 - end %> 5 + <%= link_to_function(_('Change image'), 'display_change_image()', :id => 'change-image-link', :class => 'button icon-photos with-text') %>
  6 +
  7 + <script>
  8 + function display_change_image() {
  9 + var content = "<%= j(render :partial => 'shared/change_image', :locals => { :i => i, :image => image }) %>";
  10 + jQuery('#change-image').html(content);
  11 + jQuery('#change-image-link').hide();
  12 + jQuery('#cancel-change-image-link').show();
  13 + }
  14 + </script>
10 15
11 <div id='change-image'> </div> <br/> 16 <div id='change-image'> </div> <br/>
plugins/require_auth_to_comment/lib/ext/profile.rb
@@ -2,4 +2,5 @@ require_dependency &#39;profile&#39; @@ -2,4 +2,5 @@ require_dependency &#39;profile&#39;
2 2
3 class Profile 3 class Profile
4 settings_items :allow_unauthenticated_comments, :type => :boolean 4 settings_items :allow_unauthenticated_comments, :type => :boolean
  5 + attr_accessible :allow_unauthenticated_comments
5 end 6 end