clean up support for filter=liked and filter=bookmarked

This commit is contained in:
Sam 2015-01-07 18:50:28 +11:00
parent 984f8f0c27
commit 6785675150
4 changed files with 43 additions and 12 deletions

View File

@ -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}}

View File

@ -9,19 +9,11 @@
{{#if controller.showTopicPostBadges}}
{{raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl}}
{{/if}}
{{#if expandPinned}}
{{raw "list/topic-excerpt" topic=topic}}
{{/if}}
{{#if topic.bookmarked_post_numbers}}
<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}}
{{raw "list/action-list" topic=topic postNumbers=topic.bookmarked_post_numbers className="bookmarks" icon="bookmark"}}
{{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
</td>
{{#unless controller.hideCategory}}

View File

@ -143,6 +143,24 @@
.posts {
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 {
width: 60px;
&:lang(zh_CN) {

View File

@ -8,7 +8,8 @@ class TopicListItemSerializer < ListableTopicSerializer
:category_id,
:op_like_count,
:pinned_globally,
:bookmarked_post_numbers
:bookmarked_post_numbers,
:liked_post_numbers
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
has_many :participants, serializer: TopicPosterSerializer, embed: :objects
@ -30,9 +31,21 @@ class TopicListItemSerializer < ListableTopicSerializer
end
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.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
def bookmarked_post_numbers