Commit 03abebcab3ed42ebc34685d84feeba8af9012cba
1 parent
cad39298
Exists in
master
and in
29 other branches
[suggestions] Add suggestions on communities block
(ActionItem3234)
Showing
9 changed files
with
63 additions
and
18 deletions
Show diff stats
app/models/communities_block.rb
@@ -14,19 +14,16 @@ class CommunitiesBlock < ProfileListBlock | @@ -14,19 +14,16 @@ class CommunitiesBlock < ProfileListBlock | ||
14 | _('This block displays the communities in which the user is a member.') | 14 | _('This block displays the communities in which the user is a member.') |
15 | end | 15 | end |
16 | 16 | ||
17 | + def suggestions | ||
18 | + return nil unless owner.kind_of?(Profile) | ||
19 | + owner.profile_suggestions.of_community.enabled.limit(limit).includes(:suggestion) | ||
20 | + end | ||
21 | + | ||
17 | def footer | 22 | def footer |
18 | owner = self.owner | 23 | owner = self.owner |
19 | - case owner | ||
20 | - when Profile | ||
21 | - lambda do |context| | ||
22 | - link_to s_('communities|View all'), :profile => owner.identifier, :controller => 'profile', :action => 'communities' | ||
23 | - end | ||
24 | - when Environment | ||
25 | - lambda do |context| | ||
26 | - link_to s_('communities|View all'), :controller => 'search', :action => 'communities' | ||
27 | - end | ||
28 | - else | ||
29 | - '' | 24 | + suggestions = self.suggestions |
25 | + proc do | ||
26 | + render :file => 'blocks/communities', :locals => { :owner => owner, :suggestions => suggestions } | ||
30 | end | 27 | end |
31 | end | 28 | end |
32 | 29 |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<% if owner.kind_of?(Profile) %> | ||
2 | + <%= link_to s_('communities|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %> | ||
3 | +<% elsif owner.kind_of?(Environment) %> | ||
4 | + <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %> | ||
5 | +<% else %> | ||
6 | + '' | ||
7 | +<% end %> | ||
8 | + | ||
9 | +<% if user == profile && suggestions && !suggestions.empty? %> | ||
10 | + <div class='suggestions-block common-profile-list-block'> | ||
11 | + <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> | ||
12 | + <div class='profiles-suggestions'> | ||
13 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions } %> | ||
14 | + </div> | ||
15 | + <%= link_to _('See more suggestions'), profile.communities_suggestions_url, :class => 'more-suggestions' %> | ||
16 | + </div> | ||
17 | +<% end %> |
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 => :friends_suggestions } %> | 8 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => @suggestions, :collection => :communities_suggestions } %> |
9 | </div> | 9 | </div> |
app/views/shared/_profile_suggestions_list.html.erb
@@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
34 | :class => 'join-community accept-suggestion', | 34 | :class => 'join-community accept-suggestion', |
35 | :title => _("Join %s") % s.suggestion.name %> | 35 | :title => _("Join %s") % s.suggestion.name %> |
36 | <%= button_without_text :remove, content_tag('span',_('remove')), | 36 | <%= button_without_text :remove, content_tag('span',_('remove')), |
37 | - { :action => 'remove_suggestion', :id => s.suggestion.identifier }, | 37 | + { :controller => 'memberships', :action => 'remove_suggestion', :id => s.suggestion.identifier }, |
38 | :class => 'remove-suggestion', | 38 | :class => 'remove-suggestion', |
39 | :title => _('Remove suggestion'), | 39 | :title => _('Remove suggestion'), |
40 | :confirm => _('Are you sure you want to remove this suggestion?') %> | 40 | :confirm => _('Are you sure you want to remove this suggestion?') %> |
app/views/user_mailer/profiles_suggestions_email.html.erb
1 | <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %> | 1 | <%= _('Hi, %{recipient}!') % { :recipient => @recipient } %> |
2 | 2 | ||
3 | -<p><%= _('We want to give you some suggestions to grow up your network.') %> | 3 | +<p><%= _('We want to give you some suggestions to grow up your network.') %></p> |
4 | <p><%= _('Check it out!') %></p> | 4 | <p><%= _('Check it out!') %></p> |
5 | 5 | ||
6 | <% unless @people_suggestions.empty? %> | 6 | <% unless @people_suggestions.empty? %> |
plugins/people_block/views/blocks/friends.html.erb
1 | <%= link_to s_('friends|View all'), {:profile => profile.identifier, :controller => 'profile', :action => 'friends'}, :class => 'view-all' %> | 1 | <%= link_to s_('friends|View all'), {:profile => profile.identifier, :controller => 'profile', :action => 'friends'}, :class => 'view-all' %> |
2 | 2 | ||
3 | <% if user == profile && !suggestions.empty? %> | 3 | <% if user == profile && !suggestions.empty? %> |
4 | - <div class='common-profile-list-block'> | 4 | + <div class='suggestions-block common-profile-list-block'> |
5 | <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> | 5 | <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> |
6 | <div class='profiles-suggestions'> | 6 | <div class='profiles-suggestions'> |
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 } %> |
public/designs/themes/base/style.css
@@ -515,7 +515,7 @@ div#notice { | @@ -515,7 +515,7 @@ div#notice { | ||
515 | #content .tags-block .block-footer-content a, | 515 | #content .tags-block .block-footer-content a, |
516 | #content .profile-list-block .block-footer-content a, | 516 | #content .profile-list-block .block-footer-content a, |
517 | #content .enterprises-block .block-footer-content a, | 517 | #content .enterprises-block .block-footer-content a, |
518 | -#content .communities-block .block-footer-content a { | 518 | +#content .communities-block .block-footer-content a.view-all { |
519 | background: url(imgs/arrow-right-p.png) 100% 50% no-repeat; | 519 | background: url(imgs/arrow-right-p.png) 100% 50% no-repeat; |
520 | } | 520 | } |
521 | 521 |
public/javascripts/application.js
@@ -1060,6 +1060,13 @@ jQuery('.profiles-suggestions .explain-suggestion').live('click', function() { | @@ -1060,6 +1060,13 @@ jQuery('.profiles-suggestions .explain-suggestion').live('click', function() { | ||
1060 | return false; | 1060 | return false; |
1061 | }); | 1061 | }); |
1062 | 1062 | ||
1063 | +jQuery('.suggestions-block .block-subtitle').live('click', function() { | ||
1064 | + var clicked = jQuery(this); | ||
1065 | + clicked.next('.profiles-suggestions').toggle(); | ||
1066 | + clicked.nextAll('.more-suggestions').toggle(); | ||
1067 | + return false; | ||
1068 | +}); | ||
1069 | + | ||
1063 | jQuery(document).ready(function(){ | 1070 | jQuery(document).ready(function(){ |
1064 | showHideTermsOfUse(); | 1071 | showHideTermsOfUse(); |
1065 | 1072 |
public/stylesheets/application.css
@@ -1667,6 +1667,30 @@ a.button.disabled, input.disabled { | @@ -1667,6 +1667,30 @@ a.button.disabled, input.disabled { | ||
1667 | text-align: center; | 1667 | text-align: center; |
1668 | padding-bottom: 0px; | 1668 | padding-bottom: 0px; |
1669 | } | 1669 | } |
1670 | + | ||
1671 | +#content .communities-block .block-footer-content .profiles-suggestions a.explain-suggestion { | ||
1672 | + padding: 1px; | ||
1673 | + width: 16px; | ||
1674 | +} | ||
1675 | + | ||
1676 | +#content .communities-block .block-footer-content .profiles-suggestions a.accept-suggestion, | ||
1677 | +#content .communities-block .block-footer-content .profiles-suggestions a.remove-suggestion { | ||
1678 | + position: relative; | ||
1679 | + z-index: 5; | ||
1680 | +} | ||
1681 | + | ||
1682 | +#content .communities-block .profiles-suggestions .profile-list .extra_info { | ||
1683 | + z-index: 10; | ||
1684 | +} | ||
1685 | + | ||
1686 | +#content .communities-block .block-footer-content a.more-suggestions { | ||
1687 | + position: relative; | ||
1688 | +} | ||
1689 | + | ||
1690 | +.suggestions-block .block-subtitle { | ||
1691 | + cursor: pointer; | ||
1692 | +} | ||
1693 | + | ||
1670 | .msie7 .communities-block .common-profile-list-block .vcard .profile_link { | 1694 | .msie7 .communities-block .common-profile-list-block .vcard .profile_link { |
1671 | height: 75px; | 1695 | height: 75px; |
1672 | padding-bottom: 0px; | 1696 | padding-bottom: 0px; |
@@ -4066,8 +4090,8 @@ h1#agenda-title { | @@ -4066,8 +4090,8 @@ h1#agenda-title { | ||
4066 | } | 4090 | } |
4067 | 4091 | ||
4068 | .profiles-suggestions .profile-list li { | 4092 | .profiles-suggestions .profile-list li { |
4069 | - width: 58px; | ||
4070 | - max-width: 58px; | 4093 | + width: 85px; |
4094 | + max-width: 85px; | ||
4071 | } | 4095 | } |
4072 | 4096 | ||
4073 | .box-1 .profiles-suggestions .profile-list li { | 4097 | .box-1 .profiles-suggestions .profile-list li { |