Commit 6ccbcfa668d993c2a63ee668c5f41b1182f4f0bb
1 parent
d8e061ef
Exists in
master
and in
21 other branches
profile-suggestions: final adjustements
Showing
13 changed files
with
29 additions
and
17 deletions
Show diff stats
app/controllers/my_profile/friends_controller.rb
| @@ -27,7 +27,7 @@ class FriendsController < MyProfileController | @@ -27,7 +27,7 @@ class FriendsController < MyProfileController | ||
| 27 | if @person && request.post? | 27 | if @person && request.post? |
| 28 | profile.remove_suggestion(@person) | 28 | profile.remove_suggestion(@person) |
| 29 | @suggestions = profile.profile_suggestions.of_person.enabled.includes(:suggestion).limit(per_page) | 29 | @suggestions = profile.profile_suggestions.of_person.enabled.includes(:suggestion).limit(per_page) |
| 30 | - render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } | 30 | + render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions, :per_page => params[:per_page] || per_page } |
| 31 | end | 31 | end |
| 32 | end | 32 | end |
| 33 | 33 | ||
| @@ -45,7 +45,7 @@ class FriendsController < MyProfileController | @@ -45,7 +45,7 @@ class FriendsController < MyProfileController | ||
| 45 | 45 | ||
| 46 | class << self | 46 | class << self |
| 47 | def per_page | 47 | def per_page |
| 48 | - 10 | 48 | + 12 |
| 49 | end | 49 | end |
| 50 | end | 50 | end |
| 51 | def per_page | 51 | def per_page |
app/controllers/my_profile/memberships_controller.rb
| @@ -45,11 +45,12 @@ class MembershipsController < MyProfileController | @@ -45,11 +45,12 @@ class MembershipsController < MyProfileController | ||
| 45 | 45 | ||
| 46 | def remove_suggestion | 46 | def remove_suggestion |
| 47 | @community = profile.suggested_communities.find_by_identifier(params[:id]) | 47 | @community = profile.suggested_communities.find_by_identifier(params[:id]) |
| 48 | + custom_per_page = params[:per_page] || per_page | ||
| 48 | redirect_to :action => 'suggest' unless @community | 49 | redirect_to :action => 'suggest' unless @community |
| 49 | if @community && request.post? | 50 | if @community && request.post? |
| 50 | profile.remove_suggestion(@community) | 51 | profile.remove_suggestion(@community) |
| 51 | - @suggestions = profile.profile_suggestions.of_community.enabled.includes(:suggestion).limit(per_page) | ||
| 52 | - render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } | 52 | + @suggestions = profile.profile_suggestions.of_community.enabled.includes(:suggestion).limit(custom_per_page) |
| 53 | + render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions, :per_page => custom_per_page} | ||
| 53 | end | 54 | end |
| 54 | end | 55 | end |
| 55 | 56 | ||
| @@ -66,7 +67,7 @@ class MembershipsController < MyProfileController | @@ -66,7 +67,7 @@ class MembershipsController < MyProfileController | ||
| 66 | protected | 67 | protected |
| 67 | 68 | ||
| 68 | def per_page | 69 | def per_page |
| 69 | - 10 | 70 | + 12 |
| 70 | end | 71 | end |
| 71 | 72 | ||
| 72 | end | 73 | end |
app/models/communities_block.rb
| @@ -16,7 +16,7 @@ class CommunitiesBlock < ProfileListBlock | @@ -16,7 +16,7 @@ class CommunitiesBlock < ProfileListBlock | ||
| 16 | 16 | ||
| 17 | def suggestions | 17 | def suggestions |
| 18 | return nil unless owner.kind_of?(Profile) | 18 | return nil unless owner.kind_of?(Profile) |
| 19 | - owner.profile_suggestions.of_community.enabled.limit(limit).includes(:suggestion) | 19 | + owner.profile_suggestions.of_community.enabled.limit(3).includes(:suggestion) |
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | def footer | 22 | def footer |
app/models/person.rb
| @@ -66,7 +66,7 @@ class Person < Profile | @@ -66,7 +66,7 @@ class Person < Profile | ||
| 66 | has_and_belongs_to_many :acepted_forums, :class_name => 'Forum', :join_table => 'terms_forum_people' | 66 | has_and_belongs_to_many :acepted_forums, :class_name => 'Forum', :join_table => 'terms_forum_people' |
| 67 | has_and_belongs_to_many :articles_with_access, :class_name => 'Article', :join_table => 'article_privacy_exceptions' | 67 | has_and_belongs_to_many :articles_with_access, :class_name => 'Article', :join_table => 'article_privacy_exceptions' |
| 68 | 68 | ||
| 69 | - has_many :profile_suggestions, :foreign_key => :person_id, :order => 'id ASC', :dependent => :destroy | 69 | + has_many :profile_suggestions, :foreign_key => :person_id, :order => 'score DESC', :dependent => :destroy |
| 70 | has_many :suggested_people, :through => :profile_suggestions, :source => :suggestion, :conditions => ['profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Person', true] | 70 | has_many :suggested_people, :through => :profile_suggestions, :source => :suggestion, :conditions => ['profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Person', true] |
| 71 | has_many :suggested_communities, :through => :profile_suggestions, :source => :suggestion, :conditions => ['profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Community', true] | 71 | has_many :suggested_communities, :through => :profile_suggestions, :source => :suggestion, :conditions => ['profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Community', true] |
| 72 | 72 |
app/views/blocks/communities.html.erb
| @@ -10,10 +10,10 @@ | @@ -10,10 +10,10 @@ | ||
| 10 | <div class='suggestions-block common-profile-list-block'> | 10 | <div class='suggestions-block common-profile-list-block'> |
| 11 | <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> | 11 | <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> |
| 12 | <div class='profiles-suggestions'> | 12 | <div class='profiles-suggestions'> |
| 13 | - <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions } %> | 13 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions, :per_page => 3 } %> |
| 14 | </div> | 14 | </div> |
| 15 | <div class='more-suggestions'> | 15 | <div class='more-suggestions'> |
| 16 | - <%= link_to _('See more suggestions'), profile.communities_suggestions_url %> | 16 | + <%= link_to _('See all suggestions'), profile.communities_suggestions_url %> |
| 17 | </div> | 17 | </div> |
| 18 | </div> | 18 | </div> |
| 19 | <% end %> | 19 | <% end %> |
app/views/friends/index.html.erb
| @@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
| 30 | <br style="clear:both" /> | 30 | <br style="clear:both" /> |
| 31 | <h2><%= _("Friends suggestions") %></h2> | 31 | <h2><%= _("Friends suggestions") %></h2> |
| 32 | <div class="profiles-suggestions"> | 32 | <div class="profiles-suggestions"> |
| 33 | - <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %> | 33 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions, :per_page => 12 } %> |
| 34 | </div> | 34 | </div> |
| 35 | <% end %> | 35 | <% end %> |
| 36 | 36 |
app/views/friends/suggest.html.erb
| @@ -5,5 +5,5 @@ | @@ -5,5 +5,5 @@ | ||
| 5 | <% end %> | 5 | <% end %> |
| 6 | 6 | ||
| 7 | <div class="profiles-suggestions"> | 7 | <div class="profiles-suggestions"> |
| 8 | - <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %> | 8 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions, :per_page => 12 } %> |
| 9 | </div> | 9 | </div> |
app/views/memberships/suggest.html.erb
| @@ -5,5 +5,5 @@ | @@ -5,5 +5,5 @@ | ||
| 5 | <% end %> | 5 | <% end %> |
| 6 | 6 | ||
| 7 | <div class="profiles-suggestions"> | 7 | <div class="profiles-suggestions"> |
| 8 | - <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } %> | 8 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions, :per_page => 12 } %> |
| 9 | </div> | 9 | </div> |
app/views/shared/_profile_suggestions_list.html.erb
| 1 | +<% per_page = defined?(:per_page) ? per_page : nil %> | ||
| 2 | + | ||
| 1 | <% if suggestions.empty? %> | 3 | <% if suggestions.empty? %> |
| 2 | <p> | 4 | <p> |
| 3 | <em> | 5 | <em> |
| @@ -24,13 +26,13 @@ | @@ -24,13 +26,13 @@ | ||
| 24 | <div class="controll"> | 26 | <div class="controll"> |
| 25 | <% if collection == :friends_suggestions %> | 27 | <% if collection == :friends_suggestions %> |
| 26 | <%= link_to 'x', | 28 | <%= link_to 'x', |
| 27 | - { :controller => 'friends', :action => 'remove_suggestion', :id => s.suggestion.identifier }, | 29 | + { :controller => 'friends', :action => 'remove_suggestion', :id => s.suggestion.identifier, :per_page => per_page }, |
| 28 | :class => 'remove-suggestion', | 30 | :class => 'remove-suggestion', |
| 29 | :title => _('Remove suggestion'), | 31 | :title => _('Remove suggestion'), |
| 30 | :confirm => _('Are you sure you want to remove this suggestion?') %> | 32 | :confirm => _('Are you sure you want to remove this suggestion?') %> |
| 31 | <% elsif collection == :communities_suggestions %> | 33 | <% elsif collection == :communities_suggestions %> |
| 32 | <%= link_to 'x', | 34 | <%= link_to 'x', |
| 33 | - { :controller => 'memberships', :action => 'remove_suggestion', :id => s.suggestion.identifier }, | 35 | + { :controller => 'memberships', :action => 'remove_suggestion', :id => s.suggestion.identifier, :per_page => per_page }, |
| 34 | :class => 'remove-suggestion', | 36 | :class => 'remove-suggestion', |
| 35 | :title => _('Remove suggestion'), | 37 | :title => _('Remove suggestion'), |
| 36 | :confirm => _('Are you sure you want to remove this suggestion?') %> | 38 | :confirm => _('Are you sure you want to remove this suggestion?') %> |
plugins/people_block/lib/friends_block.rb
| @@ -17,7 +17,7 @@ class FriendsBlock < PeopleBlockBase | @@ -17,7 +17,7 @@ class FriendsBlock < PeopleBlockBase | ||
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | def suggestions | 19 | def suggestions |
| 20 | - owner.profile_suggestions.of_person.enabled.limit(limit).includes(:suggestion) | 20 | + owner.profile_suggestions.of_person.enabled.limit(3).includes(:suggestion) |
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | def footer | 23 | def footer |
plugins/people_block/views/blocks/friends.html.erb
| @@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
| 7 | <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :friends_suggestions } %> | 7 | <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :friends_suggestions } %> |
| 8 | </div> | 8 | </div> |
| 9 | <div class='more-suggestions'> | 9 | <div class='more-suggestions'> |
| 10 | - <%= link_to _('See more suggestions'), profile.people_suggestions_url %> | 10 | + <%= link_to _('See all suggestions'), profile.people_suggestions_url %> |
| 11 | </div> | 11 | </div> |
| 12 | </div> | 12 | </div> |
| 13 | <% end %> | 13 | <% end %> |
public/javascripts/add-and-join.js
| @@ -135,7 +135,15 @@ jQuery(function($) { | @@ -135,7 +135,15 @@ jQuery(function($) { | ||
| 135 | $(".accept-suggestion").live('click', function(){ | 135 | $(".accept-suggestion").live('click', function(){ |
| 136 | clicked = $(this) | 136 | clicked = $(this) |
| 137 | loading_for_button(this); | 137 | loading_for_button(this); |
| 138 | - clicked.parents('li').fadeOut(); | 138 | + url = clicked.attr("href"); |
| 139 | + remove_suggestion = clicked.parents('li').find('.remove-suggestion'); | ||
| 140 | + remove_url = remove_suggestion.attr('href') | ||
| 141 | + $.post(remove_url, function(suggestions_data){ | ||
| 142 | + remove_suggestion.parents('.profiles-suggestions').html(suggestions_data); | ||
| 143 | + $.post(url, function(add_data){ | ||
| 144 | + clicked.parents('li').fadeOut(); | ||
| 145 | + }); | ||
| 146 | + }); | ||
| 139 | return false; | 147 | return false; |
| 140 | }) | 148 | }) |
| 141 | 149 |
public/stylesheets/application.css
| @@ -1723,6 +1723,7 @@ a.button.disabled, input.disabled { | @@ -1723,6 +1723,7 @@ a.button.disabled, input.disabled { | ||
| 1723 | .profiles-suggestions .profile-list .extra_info { | 1723 | .profiles-suggestions .profile-list .extra_info { |
| 1724 | z-index: 10; | 1724 | z-index: 10; |
| 1725 | display: inline-block; | 1725 | display: inline-block; |
| 1726 | + width: 100px; | ||
| 1726 | } | 1727 | } |
| 1727 | 1728 | ||
| 1728 | .suggestions-block .block-subtitle { | 1729 | .suggestions-block .block-subtitle { |