Commit 6ccbcfa668d993c2a63ee668c5f41b1182f4f0bb
1 parent
d8e061ef
Exists in
master
and in
29 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 | 27 | if @person && request.post? |
28 | 28 | profile.remove_suggestion(@person) |
29 | 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 | 31 | end |
32 | 32 | end |
33 | 33 | |
... | ... | @@ -45,7 +45,7 @@ class FriendsController < MyProfileController |
45 | 45 | |
46 | 46 | class << self |
47 | 47 | def per_page |
48 | - 10 | |
48 | + 12 | |
49 | 49 | end |
50 | 50 | end |
51 | 51 | def per_page | ... | ... |
app/controllers/my_profile/memberships_controller.rb
... | ... | @@ -45,11 +45,12 @@ class MembershipsController < MyProfileController |
45 | 45 | |
46 | 46 | def remove_suggestion |
47 | 47 | @community = profile.suggested_communities.find_by_identifier(params[:id]) |
48 | + custom_per_page = params[:per_page] || per_page | |
48 | 49 | redirect_to :action => 'suggest' unless @community |
49 | 50 | if @community && request.post? |
50 | 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 | 54 | end |
54 | 55 | end |
55 | 56 | |
... | ... | @@ -66,7 +67,7 @@ class MembershipsController < MyProfileController |
66 | 67 | protected |
67 | 68 | |
68 | 69 | def per_page |
69 | - 10 | |
70 | + 12 | |
70 | 71 | end |
71 | 72 | |
72 | 73 | end | ... | ... |
app/models/communities_block.rb
... | ... | @@ -16,7 +16,7 @@ class CommunitiesBlock < ProfileListBlock |
16 | 16 | |
17 | 17 | def suggestions |
18 | 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 | 20 | end |
21 | 21 | |
22 | 22 | def footer | ... | ... |
app/models/person.rb
... | ... | @@ -66,7 +66,7 @@ class Person < Profile |
66 | 66 | has_and_belongs_to_many :acepted_forums, :class_name => 'Forum', :join_table => 'terms_forum_people' |
67 | 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 | 70 | has_many :suggested_people, :through => :profile_suggestions, :source => :suggestion, :conditions => ['profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Person', true] |
71 | 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 | <div class='suggestions-block common-profile-list-block'> |
11 | 11 | <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> |
12 | 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 | 14 | </div> |
15 | 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 | 17 | </div> |
18 | 18 | </div> |
19 | 19 | <% end %> | ... | ... |
app/views/friends/index.html.erb
... | ... | @@ -30,7 +30,7 @@ |
30 | 30 | <br style="clear:both" /> |
31 | 31 | <h2><%= _("Friends suggestions") %></h2> |
32 | 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 | 34 | </div> |
35 | 35 | <% end %> |
36 | 36 | ... | ... |
app/views/friends/suggest.html.erb
... | ... | @@ -5,5 +5,5 @@ |
5 | 5 | <% end %> |
6 | 6 | |
7 | 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 | 9 | </div> | ... | ... |
app/views/memberships/suggest.html.erb
... | ... | @@ -5,5 +5,5 @@ |
5 | 5 | <% end %> |
6 | 6 | |
7 | 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 | 9 | </div> | ... | ... |
app/views/shared/_profile_suggestions_list.html.erb
1 | +<% per_page = defined?(:per_page) ? per_page : nil %> | |
2 | + | |
1 | 3 | <% if suggestions.empty? %> |
2 | 4 | <p> |
3 | 5 | <em> |
... | ... | @@ -24,13 +26,13 @@ |
24 | 26 | <div class="controll"> |
25 | 27 | <% if collection == :friends_suggestions %> |
26 | 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 | 30 | :class => 'remove-suggestion', |
29 | 31 | :title => _('Remove suggestion'), |
30 | 32 | :confirm => _('Are you sure you want to remove this suggestion?') %> |
31 | 33 | <% elsif collection == :communities_suggestions %> |
32 | 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 | 36 | :class => 'remove-suggestion', |
35 | 37 | :title => _('Remove suggestion'), |
36 | 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 | 17 | end |
18 | 18 | |
19 | 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 | 21 | end |
22 | 22 | |
23 | 23 | def footer | ... | ... |
plugins/people_block/views/blocks/friends.html.erb
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :friends_suggestions } %> |
8 | 8 | </div> |
9 | 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 | 11 | </div> |
12 | 12 | </div> |
13 | 13 | <% end %> | ... | ... |
public/javascripts/add-and-join.js
... | ... | @@ -135,7 +135,15 @@ jQuery(function($) { |
135 | 135 | $(".accept-suggestion").live('click', function(){ |
136 | 136 | clicked = $(this) |
137 | 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 | 147 | return false; |
140 | 148 | }) |
141 | 149 | ... | ... |
public/stylesheets/application.css