diff --git a/app/controllers/my_profile/friends_controller.rb b/app/controllers/my_profile/friends_controller.rb index f900322..4066443 100644 --- a/app/controllers/my_profile/friends_controller.rb +++ b/app/controllers/my_profile/friends_controller.rb @@ -27,7 +27,7 @@ class FriendsController < MyProfileController if @person && request.post? profile.remove_suggestion(@person) @suggestions = profile.profile_suggestions.of_person.enabled.includes(:suggestion).limit(per_page) - render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } + render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions, :per_page => params[:per_page] || per_page } end end @@ -45,7 +45,7 @@ class FriendsController < MyProfileController class << self def per_page - 10 + 12 end end def per_page diff --git a/app/controllers/my_profile/memberships_controller.rb b/app/controllers/my_profile/memberships_controller.rb index 9b20e86..4a83778 100644 --- a/app/controllers/my_profile/memberships_controller.rb +++ b/app/controllers/my_profile/memberships_controller.rb @@ -45,11 +45,12 @@ class MembershipsController < MyProfileController def remove_suggestion @community = profile.suggested_communities.find_by_identifier(params[:id]) + custom_per_page = params[:per_page] || per_page redirect_to :action => 'suggest' unless @community if @community && request.post? profile.remove_suggestion(@community) - @suggestions = profile.profile_suggestions.of_community.enabled.includes(:suggestion).limit(per_page) - render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } + @suggestions = profile.profile_suggestions.of_community.enabled.includes(:suggestion).limit(custom_per_page) + render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions, :per_page => custom_per_page} end end @@ -66,7 +67,7 @@ class MembershipsController < MyProfileController protected def per_page - 10 + 12 end end diff --git a/app/models/communities_block.rb b/app/models/communities_block.rb index 8cd5b8c..2e8a7b0 100644 --- a/app/models/communities_block.rb +++ b/app/models/communities_block.rb @@ -16,7 +16,7 @@ class CommunitiesBlock < ProfileListBlock def suggestions return nil unless owner.kind_of?(Profile) - owner.profile_suggestions.of_community.enabled.limit(limit).includes(:suggestion) + owner.profile_suggestions.of_community.enabled.limit(3).includes(:suggestion) end def footer diff --git a/app/models/person.rb b/app/models/person.rb index 82cc97d..c44974c 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -66,7 +66,7 @@ class Person < Profile has_and_belongs_to_many :acepted_forums, :class_name => 'Forum', :join_table => 'terms_forum_people' has_and_belongs_to_many :articles_with_access, :class_name => 'Article', :join_table => 'article_privacy_exceptions' - has_many :profile_suggestions, :foreign_key => :person_id, :order => 'id ASC', :dependent => :destroy + has_many :profile_suggestions, :foreign_key => :person_id, :order => 'score DESC', :dependent => :destroy has_many :suggested_people, :through => :profile_suggestions, :source => :suggestion, :conditions => ['profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Person', true] has_many :suggested_communities, :through => :profile_suggestions, :source => :suggestion, :conditions => ['profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Community', true] diff --git a/app/views/blocks/communities.html.erb b/app/views/blocks/communities.html.erb index 0e82e0d..08a74a1 100644 --- a/app/views/blocks/communities.html.erb +++ b/app/views/blocks/communities.html.erb @@ -10,10 +10,10 @@

<%= _('Some suggestions for you') %>

- <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions } %> + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions, :per_page => 3 } %>
- <%= link_to _('See more suggestions'), profile.communities_suggestions_url %> + <%= link_to _('See all suggestions'), profile.communities_suggestions_url %>
<% end %> diff --git a/app/views/friends/index.html.erb b/app/views/friends/index.html.erb index 4798d20..312fb0e 100644 --- a/app/views/friends/index.html.erb +++ b/app/views/friends/index.html.erb @@ -30,7 +30,7 @@

<%= _("Friends suggestions") %>

- <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %> + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions, :per_page => 12 } %>
<% end %> diff --git a/app/views/friends/suggest.html.erb b/app/views/friends/suggest.html.erb index 73a4b37..b663f68 100644 --- a/app/views/friends/suggest.html.erb +++ b/app/views/friends/suggest.html.erb @@ -5,5 +5,5 @@ <% end %>
- <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions } %> + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :friends_suggestions, :per_page => 12 } %>
diff --git a/app/views/memberships/suggest.html.erb b/app/views/memberships/suggest.html.erb index 6bcc0bd..9b94b8c 100644 --- a/app/views/memberships/suggest.html.erb +++ b/app/views/memberships/suggest.html.erb @@ -5,5 +5,5 @@ <% end %>
- <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } %> + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions, :per_page => 12 } %>
diff --git a/app/views/shared/_profile_suggestions_list.html.erb b/app/views/shared/_profile_suggestions_list.html.erb index f637e21..104976e 100644 --- a/app/views/shared/_profile_suggestions_list.html.erb +++ b/app/views/shared/_profile_suggestions_list.html.erb @@ -1,3 +1,5 @@ +<% per_page = defined?(:per_page) ? per_page : nil %> + <% if suggestions.empty? %>

@@ -24,13 +26,13 @@

<% if collection == :friends_suggestions %> <%= link_to 'x', - { :controller => 'friends', :action => 'remove_suggestion', :id => s.suggestion.identifier }, + { :controller => 'friends', :action => 'remove_suggestion', :id => s.suggestion.identifier, :per_page => per_page }, :class => 'remove-suggestion', :title => _('Remove suggestion'), :confirm => _('Are you sure you want to remove this suggestion?') %> <% elsif collection == :communities_suggestions %> <%= link_to 'x', - { :controller => 'memberships', :action => 'remove_suggestion', :id => s.suggestion.identifier }, + { :controller => 'memberships', :action => 'remove_suggestion', :id => s.suggestion.identifier, :per_page => per_page }, :class => 'remove-suggestion', :title => _('Remove suggestion'), :confirm => _('Are you sure you want to remove this suggestion?') %> diff --git a/plugins/people_block/lib/friends_block.rb b/plugins/people_block/lib/friends_block.rb index f094e6c..73b67b9 100644 --- a/plugins/people_block/lib/friends_block.rb +++ b/plugins/people_block/lib/friends_block.rb @@ -17,7 +17,7 @@ class FriendsBlock < PeopleBlockBase end def suggestions - owner.profile_suggestions.of_person.enabled.limit(limit).includes(:suggestion) + owner.profile_suggestions.of_person.enabled.limit(3).includes(:suggestion) end def footer diff --git a/plugins/people_block/views/blocks/friends.html.erb b/plugins/people_block/views/blocks/friends.html.erb index cb6f00e..7598e8b 100644 --- a/plugins/people_block/views/blocks/friends.html.erb +++ b/plugins/people_block/views/blocks/friends.html.erb @@ -7,7 +7,7 @@ <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :friends_suggestions } %>
- <%= link_to _('See more suggestions'), profile.people_suggestions_url %> + <%= link_to _('See all suggestions'), profile.people_suggestions_url %>
<% end %> diff --git a/public/javascripts/add-and-join.js b/public/javascripts/add-and-join.js index fec4001..142638d 100644 --- a/public/javascripts/add-and-join.js +++ b/public/javascripts/add-and-join.js @@ -135,7 +135,15 @@ jQuery(function($) { $(".accept-suggestion").live('click', function(){ clicked = $(this) loading_for_button(this); - clicked.parents('li').fadeOut(); + url = clicked.attr("href"); + remove_suggestion = clicked.parents('li').find('.remove-suggestion'); + remove_url = remove_suggestion.attr('href') + $.post(remove_url, function(suggestions_data){ + remove_suggestion.parents('.profiles-suggestions').html(suggestions_data); + $.post(url, function(add_data){ + clicked.parents('li').fadeOut(); + }); + }); return false; }) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 346533a..5bfb06d 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1723,6 +1723,7 @@ a.button.disabled, input.disabled { .profiles-suggestions .profile-list .extra_info { z-index: 10; display: inline-block; + width: 100px; } .suggestions-block .block-subtitle { -- libgit2 0.21.2