mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Adds +n indicator in PM topic list (#8353)
Shows the number of additional PM recipients in list when there are more than 5.
This commit is contained in:
@@ -70,8 +70,8 @@ const Topic = RestModel.extend({
|
|||||||
return user || this.creator;
|
return user || this.creator;
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("posters.[]", "participants.[]")
|
@discourseComputed("posters.[]", "participants.[]", "allowed_user_count")
|
||||||
featuredUsers(posters, participants) {
|
featuredUsers(posters, participants, allowedUserCount) {
|
||||||
let users = posters;
|
let users = posters;
|
||||||
const maxUserCount = 5;
|
const maxUserCount = 5;
|
||||||
const posterCount = users.length;
|
const posterCount = users.length;
|
||||||
@@ -97,6 +97,13 @@ const Topic = RestModel.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isPrivateMessage && allowedUserCount > maxUserCount) {
|
||||||
|
users.splice(maxUserCount - 2, 1); // remove second-last avatar
|
||||||
|
users.push({
|
||||||
|
moreCount: `+${allowedUserCount - maxUserCount + 1}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<td class='posters'>
|
<td class='posters'>
|
||||||
{{#each posters as |poster|}}
|
{{#each posters as |poster|}}
|
||||||
<a href="{{poster.user.path}}" data-user-card="{{poster.user.username}}" class="{{poster.extraClasses}}">{{avatar poster avatarTemplatePath="user.avatar_template" usernamePath="user.username" namePath="user.name" imageSize="small"}}</a>
|
{{#if poster.moreCount}}
|
||||||
|
<a class="posters-more-count">{{poster.moreCount}}</a>
|
||||||
|
{{else}}
|
||||||
|
<a href="{{poster.user.path}}" data-user-card="{{poster.user.username}}" class="{{poster.extraClasses}}">{{avatar poster avatarTemplatePath="user.avatar_template" usernamePath="user.username" namePath="user.name" imageSize="small"}}</a>
|
||||||
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -88,6 +88,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$td-posters-height: 29px; // min-height of td with avatar glow
|
||||||
|
$td-posters-more-lh: $td-posters-height - 4;
|
||||||
|
|
||||||
.posters {
|
.posters {
|
||||||
// we know there are up to 5 avatars of fixed size
|
// we know there are up to 5 avatars of fixed size
|
||||||
// will be overridden by media width queries on narrow displays to 1 avatar's width
|
// will be overridden by media width queries on narrow displays to 1 avatar's width
|
||||||
@@ -98,10 +101,17 @@
|
|||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.posters-more-count {
|
||||||
|
cursor: default;
|
||||||
|
color: dark-light-choose($primary-medium, $secondary-medium);
|
||||||
|
line-height: $td-posters-more-lh;
|
||||||
|
font-size: $font-down-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
td.posters {
|
td.posters {
|
||||||
height: 29px; // min-height of td with avatar glow
|
height: $td-posters-height;
|
||||||
}
|
}
|
||||||
.posters a:first-child .avatar.latest:not(.single) {
|
.posters a:first-child .avatar.latest:not(.single) {
|
||||||
box-shadow: 0 0 3px 1px desaturate($tertiary-medium, 35%);
|
box-shadow: 0 0 3px 1px desaturate($tertiary-medium, 35%);
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ class TopicListItemSerializer < ListableTopicSerializer
|
|||||||
:bookmarked_post_numbers,
|
:bookmarked_post_numbers,
|
||||||
:liked_post_numbers,
|
:liked_post_numbers,
|
||||||
:featured_link,
|
:featured_link,
|
||||||
:featured_link_root_domain
|
:featured_link_root_domain,
|
||||||
|
:allowed_user_count
|
||||||
|
|
||||||
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
||||||
has_many :participants, serializer: TopicPosterSerializer, embed: :objects
|
has_many :participants, serializer: TopicPosterSerializer, embed: :objects
|
||||||
@@ -86,4 +87,12 @@ class TopicListItemSerializer < ListableTopicSerializer
|
|||||||
SiteSetting.topic_featured_link_enabled && object.featured_link.present?
|
SiteSetting.topic_featured_link_enabled && object.featured_link.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allowed_user_count
|
||||||
|
return object.allowed_users.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_allowed_user_count?
|
||||||
|
object.private_message?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user