clean up support for filter=liked and filter=bookmarked
This commit is contained in:
parent
984f8f0c27
commit
6785675150
|
@ -0,0 +1,8 @@
|
||||||
|
{{#if postNumbers}}
|
||||||
|
<div class='post-actions {{className}}'>
|
||||||
|
<i class='fa fa-{{icon}}'></i>
|
||||||
|
{{#each postNumber in postNumbers}}
|
||||||
|
<a href='{{topic.url}}/{{postNumber}}'>#{{postNumber}}</a>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
|
@ -9,19 +9,11 @@
|
||||||
{{#if controller.showTopicPostBadges}}
|
{{#if controller.showTopicPostBadges}}
|
||||||
{{raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl}}
|
{{raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if expandPinned}}
|
{{#if expandPinned}}
|
||||||
{{raw "list/topic-excerpt" topic=topic}}
|
{{raw "list/topic-excerpt" topic=topic}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{raw "list/action-list" topic=topic postNumbers=topic.bookmarked_post_numbers className="bookmarks" icon="bookmark"}}
|
||||||
{{#if topic.bookmarked_post_numbers}}
|
{{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
|
||||||
<div class='bookmarks'>
|
|
||||||
<i class='fa fa-bookmark'></i>
|
|
||||||
{{#each postNumber in topic.bookmarked_post_numbers}}
|
|
||||||
<a href='{{topic.url}}/{{postNumber}}'>#{{postNumber}}</a>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
{{#unless controller.hideCategory}}
|
{{#unless controller.hideCategory}}
|
||||||
|
|
|
@ -143,6 +143,24 @@
|
||||||
.posts {
|
.posts {
|
||||||
width: 65px;
|
width: 65px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-actions {
|
||||||
|
clear: both;
|
||||||
|
width: auto;
|
||||||
|
color: scale-color($primary, $lightness: 50%);
|
||||||
|
text-align: left;
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 5px;
|
||||||
|
.fa {
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
font-size: 11px;
|
||||||
|
color: scale-color($primary, $lightness: 50%);
|
||||||
|
margin-right: 3px;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
.activity {
|
.activity {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
&:lang(zh_CN) {
|
&:lang(zh_CN) {
|
||||||
|
|
|
@ -8,7 +8,8 @@ class TopicListItemSerializer < ListableTopicSerializer
|
||||||
:category_id,
|
:category_id,
|
||||||
:op_like_count,
|
:op_like_count,
|
||||||
:pinned_globally,
|
:pinned_globally,
|
||||||
:bookmarked_post_numbers
|
:bookmarked_post_numbers,
|
||||||
|
:liked_post_numbers
|
||||||
|
|
||||||
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
|
||||||
|
@ -30,9 +31,21 @@ class TopicListItemSerializer < ListableTopicSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_bookmarked_post_numbers?
|
def include_bookmarked_post_numbers?
|
||||||
|
include_post_action? :bookmark
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_liked_post_numbers?
|
||||||
|
include_post_action? :like
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_post_action?(action)
|
||||||
object.user_data &&
|
object.user_data &&
|
||||||
object.user_data.post_action_data &&
|
object.user_data.post_action_data &&
|
||||||
object.user_data.post_action_data.key?(PostActionType.types[:bookmark])
|
object.user_data.post_action_data.key?(PostActionType.types[action])
|
||||||
|
end
|
||||||
|
|
||||||
|
def liked_post_numbers
|
||||||
|
object.user_data.post_action_data[PostActionType.types[:like]]
|
||||||
end
|
end
|
||||||
|
|
||||||
def bookmarked_post_numbers
|
def bookmarked_post_numbers
|
||||||
|
|
Loading…
Reference in New Issue