diff --git a/app/assets/javascripts/discourse/routes/build-category-route.js.es6 b/app/assets/javascripts/discourse/routes/build-category-route.js.es6 index 2c3a79dc6ec..2cbef30cf5c 100644 --- a/app/assets/javascripts/discourse/routes/build-category-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-category-route.js.es6 @@ -82,6 +82,7 @@ export default function(filter, params) { noSubcategories: params && !!params.no_subcategories, order: topics.get('params.order'), ascending: topics.get('params.ascending'), + expandAllPinned: true }); this.controllerFor('search').set('searchContext', model.get('searchContext')); diff --git a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 index 9b7c7c37cb5..d8cb0e02c61 100644 --- a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 @@ -53,6 +53,7 @@ export default function(filter, extras) { category: null, period: periods.findBy('id', periodId), selected: [], + expandGloballyPinned: true }; var params = model.get('params'); diff --git a/app/assets/javascripts/discourse/templates/discovery/topics.hbs b/app/assets/javascripts/discourse/templates/discovery/topics.hbs index 8c9c54e8e2c..b5417dfdecf 100644 --- a/app/assets/javascripts/discourse/templates/discovery/topics.hbs +++ b/app/assets/javascripts/discourse/templates/discovery/topics.hbs @@ -47,6 +47,8 @@ ascending=ascending bulkSelectEnabled=bulkSelectEnabled selected=selected + expandGloballyPinned=expandGloballyPinned + expandAllPinned=expandAllPinned topics=topics}} {{/if}} diff --git a/app/assets/javascripts/discourse/templates/list/topic_list_item.raw.hbs b/app/assets/javascripts/discourse/templates/list/topic_list_item.raw.hbs index 83eedde3ac2..1b5f225a713 100644 --- a/app/assets/javascripts/discourse/templates/list/topic_list_item.raw.hbs +++ b/app/assets/javascripts/discourse/templates/list/topic_list_item.raw.hbs @@ -10,7 +10,9 @@ {{raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl}} {{/if}} - {{raw "list/topic-excerpt" topic=topic}} + {{#if expandPinned}} + {{raw "list/topic-excerpt" topic=topic}} + {{/if}} {{#unless controller.hideCategory}} diff --git a/app/assets/javascripts/discourse/views/topic-list-item.js.es6 b/app/assets/javascripts/discourse/views/topic-list-item.js.es6 index 94191326473..6a4391ad46f 100644 --- a/app/assets/javascripts/discourse/views/topic-list-item.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-list-item.js.es6 @@ -22,6 +22,23 @@ export default Discourse.View.extend(StringBuffer, { return this.get('topic.op_like_count') > 0; }, + expandPinned: function(){ + var pinned = this.get('topic.pinned'); + if(!pinned){ + return false; + } + + if(this.get('controller.expandGloballyPinned') && this.get('topic.pinned_globally')){ + return true; + } + + if(this.get('controller.expandAllPinned')){ + return true; + } + + return false; + }.property(), + click: function(e){ var target = $(e.target); diff --git a/app/serializers/topic_list_item_serializer.rb b/app/serializers/topic_list_item_serializer.rb index 91da032a8ab..97adc464fec 100644 --- a/app/serializers/topic_list_item_serializer.rb +++ b/app/serializers/topic_list_item_serializer.rb @@ -7,7 +7,8 @@ class TopicListItemSerializer < ListableTopicSerializer :archetype, :last_poster_username, :category_id, - :op_like_count + :op_like_count, + :pinned_globally has_many :posters, serializer: TopicPosterSerializer, embed: :objects has_many :participants, serializer: TopicPosterSerializer, embed: :objects