Commit fd65e2c1473333575a743558654dc2061d5165d2
Committed by
André Guedes
1 parent
a08b3fc4
Exists in
split_by_role
and in
1 other branch
Split members page in admins and non-admins
- Order members by name - Removed white spaces - Changed strings to be translated - Renamed div id and test - Adjust ul tag members - Fixed plugin dependency Signed-off-by: Omar Junior <omarroinuj@gmail.com> Signed-off-by: DylanGuedes <djmgguedes@gmail.com> Signed-off-by: Vitor Barbosa <vitormga15@gmail.com> Signed-off-by: Brenddon Gontijo <brenddongontijo@msn.com>
Showing
8 changed files
with
179 additions
and
10 deletions
Show diff stats
app/controllers/public/profile_controller.rb
... | ... | @@ -65,8 +65,19 @@ class ProfileController < PublicController |
65 | 65 | |
66 | 66 | def members |
67 | 67 | if is_cache_expired?(profile.members_cache_key(params)) |
68 | - @members = profile.members_by_name.includes(relations_to_include).paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => profile.members.count) | |
68 | + all_members = if params[:sort] and params[:sort] == "desc" | |
69 | + profile.members.order("name desc") | |
70 | + else | |
71 | + profile.members.order("name asc") | |
72 | + end | |
73 | + | |
74 | + @profile_admins = profile.admins | |
75 | + @total_members = all_members.count | |
76 | + @members_except_admins = all_members - @profile_admins | |
77 | + @members_count = @members_except_admins.count | |
78 | + @members_except_admins = @members_except_admins.paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => @members_count) | |
69 | 79 | end |
80 | + | |
70 | 81 | end |
71 | 82 | |
72 | 83 | def fans | ... | ... |
app/views/profile/members.html.erb
1 | 1 | <div class="common-profile-list-block"> |
2 | 2 | |
3 | -<h1><%= _("%s's members") % profile.name %></h1> | |
3 | +<h1><%= _("Members") + " (#{@total_members})" %></h1> | |
4 | +<h3 class="community-name-members"><%= _("%s") % profile.name %></h3> | |
4 | 5 | |
5 | 6 | <% cache_timeout(profile.members_cache_key(params), 4.hours) do %> |
6 | - <ul class='profile-list'> | |
7 | - <% @members.each do |member| %> | |
8 | - <%= profile_image_link(member) %> | |
9 | - <% end %> | |
10 | - </ul> | |
7 | + | |
8 | + <div class='profile-admins'> | |
9 | + <h2><%= "#{@profile_admins.count} "+_("admins") %></h2> | |
10 | + <ul class='profile-list'> | |
11 | + <% @profile_admins.each do |admin| %> | |
12 | + <%= profile_image_link(admin) %> | |
13 | + <% end %> | |
14 | + </ul> | |
15 | + </div> | |
16 | + | |
17 | + <div class="profile-members-title-sort"> | |
18 | + <h2><%= "#{@members_count} "+ _("members") %></h2> | |
19 | + | |
20 | + <div id="members-display-options-sort"> | |
21 | + <%= label_tag("sort", _("Sort by:")) %> | |
22 | + <%= select_tag("sort", | |
23 | + options_for_select( | |
24 | + [ | |
25 | + [_("Name A-Z"), 'asc'], | |
26 | + [_("Name Z-A"), 'desc'], | |
27 | + ], :selected=>params[:sort]) | |
28 | + ) %> | |
29 | + </div> | |
30 | + </div> | |
31 | + | |
32 | + <div class='profile-members'> | |
33 | + <ul class='profile-list'> | |
34 | + <% @members_except_admins.each do |member| %> | |
35 | + <%= profile_image_link(member) %> | |
36 | + <% end %> | |
37 | + </ul> | |
38 | + </div> | |
11 | 39 | |
12 | 40 | <div id='pagination-profiles'> |
13 | - <%= pagination_links @members, :param_name => 'npage' %> | |
41 | + <%= pagination_links @members_except_admins, :param_name => 'npage' %> | |
14 | 42 | </div> |
15 | 43 | <% end %> |
16 | 44 | |
... | ... | @@ -26,4 +54,7 @@ |
26 | 54 | <% end %> |
27 | 55 | <% end %> |
28 | 56 | |
57 | +<%= hidden_field_tag "current_profile", profile.identifier %> | |
29 | 58 | </div><!-- fim class="common-profile-list-block" --> |
59 | + | |
60 | +<%= javascript_include_tag "members_page.js" %> | ... | ... |
plugins/people_block/controllers/people_block_plugin_profile_controller.rb
... | ... | @@ -14,7 +14,7 @@ class PeopleBlockPluginProfileController < ProfileController |
14 | 14 | end |
15 | 15 | @members = @members.includes(relations_to_include).paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => @members.count) |
16 | 16 | end |
17 | - render "profile/members" | |
17 | + render "people_block_profile/members" | |
18 | 18 | end |
19 | 19 | |
20 | 20 | end | ... | ... |
plugins/people_block/views/people_block_profile/members.html.erb
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +<div class="common-profile-list-block"> | |
2 | + | |
3 | +<h1><%= _("%s's members") % profile.name %></h1> | |
4 | + | |
5 | +<% cache_timeout(profile.members_cache_key(params), 4.hours) do %> | |
6 | + <ul class='profile-list'> | |
7 | + <% @members.each do |member| %> | |
8 | + <%= profile_image_link(member) %> | |
9 | + <% end %> | |
10 | + </ul> | |
11 | + | |
12 | + <div id='pagination-profiles'> | |
13 | + <%= pagination_links @members, :param_name => 'npage' %> | |
14 | + </div> | |
15 | +<% end %> | |
16 | + | |
17 | +<% button_bar do %> | |
18 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | |
19 | + <% if profile.community? and user %> | |
20 | + <% if user.has_permission?(:invite_members, profile) %> | |
21 | + <%= button :person, _('Invite people to join'), :controller => 'invite', :action => 'invite_friends' %> | |
22 | + <% end %> | |
23 | + <% if user.has_permission?(:send_mail_to_members, profile) %> | |
24 | + <%= button :send, _('Send e-mail to members'), :controller => 'profile', :action => 'send_mail' %> | |
25 | + <% end %> | |
26 | + <% end %> | |
27 | +<% end %> | |
28 | + | |
29 | +</div><!-- fim class="common-profile-list-block" --> | |
0 | 30 | \ No newline at end of file | ... | ... |
public/designs/themes/base/style.css
... | ... | @@ -231,6 +231,10 @@ body, th, td, input { |
231 | 231 | border-left: 0px; |
232 | 232 | } |
233 | 233 | |
234 | +.menu-submenu-list>li{ | |
235 | + width: 100%; | |
236 | +} | |
237 | + | |
234 | 238 | #navigation .menu-submenu ul{ |
235 | 239 | border: 1px solid #888a85; |
236 | 240 | border-top: 0px; |
... | ... | @@ -1530,3 +1534,7 @@ table#recaptcha_table tr:hover td { |
1530 | 1534 | width: 494px; |
1531 | 1535 | padding-left: 2px; |
1532 | 1536 | } |
1537 | + | |
1538 | +.profile-members-title-sort { | |
1539 | + clear: both; | |
1540 | +} | |
1533 | 1541 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +(function($) { | |
2 | + "use strict"; | |
3 | + | |
4 | + function set_members_sort() { | |
5 | + var page_profile = $("#current_profile").val(); | |
6 | + var members_url = noosfero_root() + "/profile/" + page_profile + "/members"; | |
7 | + | |
8 | + $("#sort").on("change", function() { | |
9 | + var sort_value = this.value; | |
10 | + var actual_page_content = $(".common-profile-list-block"); | |
11 | + | |
12 | + $.get(members_url, {sort: sort_value}, function(response) { | |
13 | + var html_response = $(response); | |
14 | + | |
15 | + actual_page_content.html(html_response.html()); | |
16 | + set_members_sort(); | |
17 | + }); | |
18 | + }); | |
19 | + } | |
20 | + | |
21 | + $(document).ready(function() { | |
22 | + set_members_sort(); | |
23 | + }); | |
24 | +}) (jQuery); | ... | ... |
public/stylesheets/application.css
test/functional/profile_controller_test.rb
... | ... | @@ -55,7 +55,8 @@ class ProfileControllerTest < ActionController::TestCase |
55 | 55 | |
56 | 56 | assert_response :success |
57 | 57 | assert_template 'members' |
58 | - assert assigns(:members) | |
58 | + assert assigns(:members_except_admins) | |
59 | + assert assigns(:profile_admins) | |
59 | 60 | end |
60 | 61 | |
61 | 62 | should 'list favorite enterprises' do |
... | ... | @@ -1748,4 +1749,68 @@ class ProfileControllerTest < ActionController::TestCase |
1748 | 1749 | assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} |
1749 | 1750 | end |
1750 | 1751 | |
1752 | + should 'only admins from a community be present in admin users div' do | |
1753 | + community = fast_create(Community) | |
1754 | + another_user = create_user('another_user').person | |
1755 | + | |
1756 | + login_as(@profile.identifier) | |
1757 | + | |
1758 | + community.add_admin(@profile) | |
1759 | + community.add_member(another_user) | |
1760 | + | |
1761 | + get :members, :profile => community.identifier | |
1762 | + | |
1763 | + assert_tag :tag => 'div', :attributes => { :class => /profile-admins/}, | |
1764 | + :descendant => { :tag => 'a', :attributes => { :title => "testuser" } } | |
1765 | + | |
1766 | + assert_no_tag :tag => 'div', :attributes => { :class => /profile-admins/}, | |
1767 | + :descendant => { :tag => 'a', :attributes => { :title => "another_user" } } | |
1768 | + end | |
1769 | + | |
1770 | + should 'only normal users from a community be present in normal users div' do | |
1771 | + community = fast_create(Community) | |
1772 | + another_user = create_user('another_user').person | |
1773 | + | |
1774 | + login_as(@profile.identifier) | |
1775 | + | |
1776 | + community.add_admin(@profile) | |
1777 | + community.add_member(another_user) | |
1778 | + | |
1779 | + get :members, :profile => community.identifier | |
1780 | + | |
1781 | + assert_no_tag :tag => 'div', :attributes => { :class => /profile-members/}, | |
1782 | + :descendant => { :tag => 'a', :attributes => { :title => "testuser" } } | |
1783 | + | |
1784 | + assert_tag :tag => 'div', :attributes => { :class => /profile-members/}, | |
1785 | + :descendant => { :tag => 'a', :attributes => { :title => "another_user" } } | |
1786 | + end | |
1787 | + | |
1788 | + should 'members be sorted by name in ascendant order' do | |
1789 | + community = fast_create(Community) | |
1790 | + another_user = create_user('another_user').person | |
1791 | + different_user = create_user('different_user').person | |
1792 | + | |
1793 | + community.add_member(@profile) | |
1794 | + community.add_member(another_user) | |
1795 | + community.add_member(different_user) | |
1796 | + | |
1797 | + get :members, :profile => community.identifier, :sort => "asc" | |
1798 | + | |
1799 | + assert @response.body.index("another_user") < @response.body.index("different_user") | |
1800 | + end | |
1801 | + | |
1802 | + should 'members be sorted by name in descendant order' do | |
1803 | + community = fast_create(Community) | |
1804 | + another_user = create_user('another_user').person | |
1805 | + different_user = create_user('different_user').person | |
1806 | + | |
1807 | + community.add_member(@profile) | |
1808 | + community.add_member(another_user) | |
1809 | + community.add_member(different_user) | |
1810 | + | |
1811 | + get :members, :profile => community.identifier, :sort => "desc" | |
1812 | + | |
1813 | + assert @response.body.index("another_user") > @response.body.index("different_user") | |
1814 | + end | |
1815 | + | |
1751 | 1816 | end | ... | ... |