FEATURE: show added date when looking at group members
This commit is contained in:
parent
aa044623bd
commit
ceafcbc898
|
@ -25,6 +25,7 @@
|
|||
<thead>
|
||||
{{group-index-toggle order=order desc=desc field='username_lower' i18nKey='username'}}
|
||||
<th class='group-owner'>{{i18n "groups.members.owner"}}</th>
|
||||
{{group-index-toggle order=order desc=desc field='added_at' i18nKey='groups.member_added'}}
|
||||
{{group-index-toggle order=order desc=desc field='last_posted_at' i18nKey='last_post'}}
|
||||
{{group-index-toggle order=order desc=desc field='last_seen_at' i18nKey='last_seen'}}
|
||||
<th></th>
|
||||
|
@ -44,7 +45,9 @@
|
|||
</strong>
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<span class="text">{{bound-date m.added_at}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="text">{{bound-date m.last_posted_at}}</span>
|
||||
</td>
|
||||
|
|
|
@ -216,6 +216,8 @@ class GroupsController < ApplicationController
|
|||
|
||||
if params[:order] && %w{last_posted_at last_seen_at}.include?(params[:order])
|
||||
order = "#{params[:order]} #{dir} NULLS LAST"
|
||||
elsif params[:order] == 'added_at'
|
||||
order = "group_users.created_at #{dir}"
|
||||
end
|
||||
|
||||
users = group.users.human_users
|
||||
|
@ -231,6 +233,8 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
users = users.select('users.*, group_users.created_at as added_at')
|
||||
|
||||
members = users
|
||||
.order('NOT group_users.owner')
|
||||
.order(order)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
class GroupUserSerializer < BasicUserSerializer
|
||||
attributes :name, :title, :last_posted_at, :last_seen_at
|
||||
attributes :name, :title, :last_posted_at, :last_seen_at, :added_at
|
||||
|
||||
def include_added_at
|
||||
object.respond_to? :added_at
|
||||
end
|
||||
end
|
||||
|
|
|
@ -413,6 +413,7 @@ en:
|
|||
remove_user_as_group_owner: "Revoke owner"
|
||||
|
||||
groups:
|
||||
member_added: "Added"
|
||||
add_members:
|
||||
title: "Add Members"
|
||||
description: "Manage the membership of this group"
|
||||
|
|
|
@ -360,7 +360,15 @@ describe GroupsController do
|
|||
end
|
||||
|
||||
it "ensures that membership can be paginated" do
|
||||
5.times { group.add(Fabricate(:user)) }
|
||||
|
||||
freeze_time
|
||||
|
||||
first_user = Fabricate(:user)
|
||||
group.add(first_user)
|
||||
|
||||
freeze_time 1.day.from_now
|
||||
|
||||
4.times { group.add(Fabricate(:user)) }
|
||||
usernames = group.users.map { |m| m.username }.sort
|
||||
|
||||
get "/groups/#{group.name}/members.json", params: { limit: 3 }
|
||||
|
@ -378,6 +386,11 @@ describe GroupsController do
|
|||
members = JSON.parse(response.body)["members"]
|
||||
|
||||
expect(members.map { |m| m['username'] }).to eq(usernames[3..5])
|
||||
|
||||
get "/groups/#{group.name}/members.json", params: { order: 'added_at', desc: true }
|
||||
members = JSON.parse(response.body)["members"]
|
||||
|
||||
expect(members.last['added_at']).to eq(first_user.created_at.as_json)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue