mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: display avatar flair in categories route topic list items (#9197)
This commit is contained in:
parent
4ecf0be93d
commit
dc1836573d
@ -63,9 +63,19 @@ const Topic = RestModel.extend({
|
|||||||
const latest = posters.filter(
|
const latest = posters.filter(
|
||||||
p => p.extras && p.extras.indexOf("latest") >= 0
|
p => p.extras && p.extras.indexOf("latest") >= 0
|
||||||
)[0];
|
)[0];
|
||||||
user = latest && latest.user;
|
user = latest;
|
||||||
}
|
}
|
||||||
return user || this.creator;
|
return user || posters.firstObject;
|
||||||
|
},
|
||||||
|
|
||||||
|
@discourseComputed("lastPoster")
|
||||||
|
lastPosterUser(poster) {
|
||||||
|
return poster.user;
|
||||||
|
},
|
||||||
|
|
||||||
|
@discourseComputed("lastPoster")
|
||||||
|
lastPosterGroup(poster) {
|
||||||
|
return poster.primary_group;
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("posters.[]", "participants.[]", "allowed_user_count")
|
@discourseComputed("posters.[]", "participants.[]", "allowed_user_count")
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
<div class='topic-poster'>
|
<div class='topic-poster'>
|
||||||
{{#user-link user=topic.lastPoster}}
|
{{#user-link user=topic.lastPosterUser}}
|
||||||
{{avatar topic.lastPoster imageSize="large"}}
|
{{avatar topic.lastPosterUser imageSize="large"}}
|
||||||
{{/user-link}}
|
{{/user-link}}
|
||||||
|
{{#if topic.lastPosterGroup}}
|
||||||
|
{{avatar-flair
|
||||||
|
flairURL=topic.lastPosterGroup.flair_url
|
||||||
|
flairBgColor=topic.lastPosterGroup.flair_bg_color
|
||||||
|
flairColor=topic.lastPosterGroup.flair_color
|
||||||
|
groupName=topic.lastPosterGroup.name}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class='main-link'>
|
<div class='main-link'>
|
||||||
<div class='top-row'>
|
<div class='top-row'>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<td>
|
<td>
|
||||||
{{~#unless expandPinned}}
|
{{~#unless expandPinned}}
|
||||||
<div class='pull-left'>
|
<div class='pull-left'>
|
||||||
<a href="{{topic.lastPostUrl}}" data-user-card="{{topic.last_poster_username}}">{{avatar topic.lastPoster imageSize="large"}}</a>
|
<a href="{{topic.lastPostUrl}}" data-user-card="{{topic.last_poster_username}}">{{avatar topic.lastPosterUser imageSize="large"}}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class='right'>
|
<div class='right'>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -21,7 +21,13 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
.topic-poster {
|
.topic-poster {
|
||||||
|
position: relative;
|
||||||
width: 60px;
|
width: 60px;
|
||||||
|
.avatar-flair {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.main-link {
|
.main-link {
|
||||||
@extend .topic-list-main-link;
|
@extend .topic-list-main-link;
|
||||||
|
@ -4,6 +4,7 @@ class CategoryAndTopicListsSerializer < ApplicationSerializer
|
|||||||
has_one :category_list, serializer: CategoryListSerializer, embed: :objects
|
has_one :category_list, serializer: CategoryListSerializer, embed: :objects
|
||||||
has_one :topic_list, serializer: TopicListSerializer, embed: :objects
|
has_one :topic_list, serializer: TopicListSerializer, embed: :objects
|
||||||
has_many :users, serializer: BasicUserSerializer, embed: :objects
|
has_many :users, serializer: BasicUserSerializer, embed: :objects
|
||||||
|
has_many :primary_groups, serializer: PrimaryGroupSerializer, embed: :objects
|
||||||
|
|
||||||
def users
|
def users
|
||||||
users = object.topic_list.topics.map do |t|
|
users = object.topic_list.topics.map do |t|
|
||||||
@ -15,4 +16,14 @@ class CategoryAndTopicListsSerializer < ApplicationSerializer
|
|||||||
users
|
users
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def primary_groups
|
||||||
|
groups = object.topic_list.topics.map do |t|
|
||||||
|
t.posters.map { |poster| poster.try(:primary_group) }
|
||||||
|
end
|
||||||
|
groups.flatten!
|
||||||
|
groups.compact!
|
||||||
|
groups.uniq!(&:id)
|
||||||
|
groups
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user