Support likes column via site extension

This commit is contained in:
Sam 2015-01-05 17:03:48 +11:00
parent 69771562d7
commit d0d2a15180
5 changed files with 21 additions and 0 deletions

View File

@ -95,6 +95,10 @@ Discourse.Topic = Discourse.Model.extend({
return this.urlForPostNumber(1);
}.property('url'),
summaryUrl: function () {
return this.urlForPostNumber(1) + (this.get('has_summary') ? "?filter=summary" : "");
}.property('url'),
lastPosterUrl: function() {
return Discourse.getURL("/users/") + this.get("last_poster.username");
}.property('last_poster'),

View File

@ -14,5 +14,8 @@
{{#if showParticipants}}
{{raw "components/topic-list-header-column" order='participants' name='users'}}
{{/if}}
{{#if showLikes}}
{{raw "components/topic-list-header-column" sortable=sortable number='true' order='likes' name='likes'}}
{{/if}}
{{raw "components/topic-list-header-column" sortable=sortable number='true' order='views' name='views'}}
{{raw "components/topic-list-header-column" sortable=sortable number='true' order='activity' name='activity'}}

View File

@ -6,6 +6,7 @@
toggleInTitle=toggleInTitle
hideCategory=hideCategory
showPosters=showPosters
showLikes=showLikes
showParticipants=showParticipants
order=order
ascending=ascending

View File

@ -29,6 +29,15 @@
{{raw "list/posters-column" posters=topic.participants}}
{{/if}}
{{#if controller.showLikes}}
<td class="num likes">
{{#if hasLikes}}
<a href='{{topic.summaryUrl}}'>
{{number topic.like_count}} <i class='fa fa-heart'></i></td>
</a>
{{/if}}
{{/if}}
<td class="num views {{topic.viewsHeat}}">{{number topic.views numberKey="views_long"}}</td>
{{raw "list/activity-column" topic=topic class="num" tagName="td"}}

View File

@ -14,6 +14,10 @@ export default Discourse.View.extend(StringBuffer, {
topic: Em.computed.alias("content"),
hasLikes: function(){
return this.get('topic.like_count') > 0;
},
click: function(e){
var target = $(e.target);