Commit 69ce8338006173a49110a1ac0f494a7a57d41c5b
1 parent
688b3512
Exists in
master
and in
29 other branches
Limit number of items in "my communities" menu
This limit the listing to the 5 most popular communities to avoid making it unbearable to users that create a lot of communities.
Showing
1 changed file
with
9 additions
and
1 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -1118,9 +1118,17 @@ module ApplicationHelper |
1118 | 1118 | |
1119 | 1119 | def manage_link(list, kind) |
1120 | 1120 | if list.present? |
1121 | + link_to_all = nil | |
1122 | + if list.count > 5 | |
1123 | + list = list.first(5) | |
1124 | + link_to_all = link_to(content_tag('strong', _('See all')), :controller => 'memberships', :profile => current_user.login) | |
1125 | + end | |
1121 | 1126 | link = list.map do |element| |
1122 | 1127 | link_to(content_tag('strong', [_('<span>Manage</span> %s') % element.short_name(25)]), @environment.top_url + "/myprofile/#{element.identifier}", :class => "icon-menu-"+element.class.identification.underscore, :title => [_('Manage %s') % element.short_name]) |
1123 | 1128 | end |
1129 | + if link_to_all | |
1130 | + link << link_to_all | |
1131 | + end | |
1124 | 1132 | render :partial => "shared/manage_link", :locals => {:link => link, :kind => kind.to_s} |
1125 | 1133 | end |
1126 | 1134 | end |
... | ... | @@ -1132,7 +1140,7 @@ module ApplicationHelper |
1132 | 1140 | |
1133 | 1141 | def manage_communities |
1134 | 1142 | return if not user |
1135 | - administered_communities = user.communities.select {|c| c.admins.include? user} | |
1143 | + administered_communities = user.communities.more_popular.select {|c| c.admins.include? user} | |
1136 | 1144 | manage_link(administered_communities, :communities) |
1137 | 1145 | end |
1138 | 1146 | ... | ... |