Commit 878fa51be6769ac2e2c2b7491df3775c6b72b84b
1 parent
343a24b4
Exists in
master
and in
5 other branches
Add page Members header
Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
Showing
3 changed files
with
103 additions
and
0 deletions
Show diff stats
lib/ext/profile_controller.rb
@@ -20,4 +20,21 @@ class ProfileController | @@ -20,4 +20,21 @@ class ProfileController | ||
20 | @communities = type.paginate(:per_page => per_page, :page => params[:npage], :total_entries => type.count) | 20 | @communities = type.paginate(:per_page => per_page, :page => params[:npage], :total_entries => type.count) |
21 | end | 21 | end |
22 | end | 22 | end |
23 | + | ||
24 | + def members | ||
25 | + if is_cache_expired?(profile.members_cache_key(params)) | ||
26 | + all_members = if params[:sort] and params[:sort] == "desc" | ||
27 | + profile.members.order("name desc") | ||
28 | + else | ||
29 | + profile.members.order("name asc") | ||
30 | + end | ||
31 | + @profile_admins = profile.admins | ||
32 | + @profile_members = all_members - @profile_admins | ||
33 | + @profile_members = @profile_members.paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => @profile_members.size) | ||
34 | + @profile_admins = @profile_admins.paginate(:per_page => members_per_page, :page => params[:npage], :total_entries => @profile_admins.size) | ||
35 | + @total_members = all_members.size | ||
36 | + @profile_members_url = url_for(:controller => "profile", :action => "members") | ||
37 | + end | ||
38 | + end | ||
39 | + | ||
23 | end | 40 | end |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | + <div id="profile-members-sort-options"> | ||
2 | + <%= label_tag("sort-#{role}", _("Sort by:")) %> | ||
3 | + <%= select_tag("sort-#{role}", | ||
4 | + options_for_select([ | ||
5 | + [_("Name A-Z"), 'asc'], | ||
6 | + [_("Name Z-A"), 'desc'], | ||
7 | + ], :selected=>params[:sort]) | ||
8 | + ) %> | ||
9 | + </div> | ||
10 | + <ul class="profile-list-<%= role %>" > | ||
11 | + <% users.each do |u| %> | ||
12 | + <%= profile_image_link(u) %> | ||
13 | + <% end %> | ||
14 | +</ul> |
@@ -0,0 +1,72 @@ | @@ -0,0 +1,72 @@ | ||
1 | + | ||
2 | +<div class="page-members-header"> | ||
3 | + <h1><%= _("Members") + " (#{@total_members})" %></h1> | ||
4 | + <h3 class="community-name-members"><%= _("%s") % profile.name %></h3> | ||
5 | + <%= render "blocks/profile_info_actions/community" %> | ||
6 | +</div> | ||
7 | + | ||
8 | +<% cache_timeout(profile.members_cache_key(params), 4.hours) do %> | ||
9 | +<div class="profile-members-tabs-container"> | ||
10 | + <% tabs = [] %> | ||
11 | + | ||
12 | + <% div_members = content_tag :div, :class => "profile-members" do | ||
13 | + render :partial => 'profile_members_list', | ||
14 | + :locals => { | ||
15 | + :users => @profile_members, | ||
16 | + :role => "members" | ||
17 | + } | ||
18 | + | ||
19 | + end %> | ||
20 | + | ||
21 | + <% members_pagination = content_tag :div, :class => "pagination-profile-members" do | ||
22 | + pagination_links @profile_members, :param_name => 'npage' | ||
23 | + end %> | ||
24 | + | ||
25 | + | ||
26 | + <% tabs << {:title => "#{@profile_members.size} "+_("Members"), | ||
27 | + :id => "members-tab", | ||
28 | + :content => (div_members + members_pagination) | ||
29 | + } %> | ||
30 | + | ||
31 | + <% div_admins = content_tag :div, :class => "profile-admins" do | ||
32 | + render :partial => 'profile_members_list', | ||
33 | + :locals => { | ||
34 | + :users => @profile_admins, | ||
35 | + :role => "admins" | ||
36 | + } | ||
37 | + end %> | ||
38 | + | ||
39 | + <% admins_pagination = content_tag :div, :class => "pagination-profile-admins" do | ||
40 | + pagination_links @profile_admins, :param_name => 'npage' | ||
41 | + end %> | ||
42 | + | ||
43 | + <% tabs << {:title => "#{@profile_admins.size} "+_("Administrators"), | ||
44 | + :id => "admins-tab", | ||
45 | + :content => (div_admins+admins_pagination) | ||
46 | + } %> | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | + | ||
51 | + <%= render_tabs(tabs) %> | ||
52 | + <% end %> | ||
53 | +</div> | ||
54 | + | ||
55 | + | ||
56 | +<% button_bar do %> | ||
57 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | ||
58 | + <% if profile.community? and user %> | ||
59 | + <% if user.has_permission?(:invite_members, profile) %> | ||
60 | + <%= button :person, _('Invite people to join'), :controller => 'invite', :action => 'invite_friends' %> | ||
61 | + <% end %> | ||
62 | + <% if user.has_permission?(:send_mail_to_members, profile) %> | ||
63 | + <%= button :send, _('Send e-mail to members'), :controller => 'profile', :action => 'send_mail' %> | ||
64 | + <% end %> | ||
65 | + <% end %> | ||
66 | +<% end %> | ||
67 | + | ||
68 | +<%= hidden_field_tag "profile_url", @profile_members_url %> | ||
69 | +<%= hidden_field_tag "sort", "asc" %> | ||
70 | +</div><!-- fim class="common-profile-list-block" --> | ||
71 | + | ||
72 | +<%= javascript_include_tag "members_page.js" %> |