Merge pull request #806 from ZogStriP/clear-pin-link-in-list-topics-view

Add a clear pin link in the list topics view
This commit is contained in:
Sam 2013-05-02 16:45:46 -07:00
commit 3ca263568e
3 changed files with 17 additions and 5 deletions

View File

@ -53,6 +53,11 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({
topic.toggleStar();
},
// clear a pinned topic
clearPin: function(topic) {
topic.clearPin();
},
toggleRankDetails: function() {
this.toggleProperty('rankDetailsVisible');
},

View File

@ -371,13 +371,17 @@ Discourse.Topic = Discourse.Model.extend({
},
hasExcerpt: function() {
return this.get('excerpt') && this.get('excerpt').length > 0;
}.property('excerpt'),
return this.get('pinned') && this.get('excerpt') && this.get('excerpt').length > 0;
}.property('pinned', 'excerpt'),
excerptTruncated: function() {
var e = this.get('excerpt');
return( e && e.substr(e.length - 8,8) === '…' );
}.property('excerpt')
}.property('excerpt'),
canClearPin: function() {
return this.get('pinned') && (this.get('last_read_post_number') === this.get('highest_post_number'));
}.property('pinned', 'last_read_post_number', 'highest_post_number')
});
Discourse.Topic.reopenClass({

View File

@ -29,11 +29,14 @@
<a href="{{lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
{{/if}}
{{#if excerpt}}
{{#if hasExcerpt}}
<div class="topic-excerpt">
{{excerpt}}
{{#if excerptTruncated}}
<a href="{{lastReadUrl}}">{{i18n read_more}}</a>
{{#unless canClearPin}}<a href="{{lastReadUrl}}">{{i18n read_more}}</a>{{/unless}}
{{/if}}
{{#if canClearPin}}
<a href="#" {{action clearPin this target="controller"}} title="{{unbound i18n topic.clear_pin.help}}">{{i18n topic.clear_pin.title}}</a>
{{/if}}
</div>
{{/if}}