From 5b559d96319163ad552d096926aa0e8a732e4071 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 6 Feb 2014 14:38:04 -0500 Subject: [PATCH] Pinned uncategorized topics span the title and category column in topic lists --- .../controllers/topic_list_item_controller.js | 11 ++++++++++- app/assets/javascripts/discourse/models/topic.js | 4 ++++ .../templates/list/topic_list_item.js.handlebars | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic_list_item_controller.js b/app/assets/javascripts/discourse/controllers/topic_list_item_controller.js index 80c6010f613..555493d95e5 100644 --- a/app/assets/javascripts/discourse/controllers/topic_list_item_controller.js +++ b/app/assets/javascripts/discourse/controllers/topic_list_item_controller.js @@ -10,7 +10,6 @@ Discourse.TopicListItemController = Ember.ObjectController.extend({ needs: ['discoveryTopics'], canStar: Em.computed.alias('controllers.discoveryTopics.currentUser.id'), - hideCategory: Em.computed.alias('controllers.discoveryTopics.hideCategory'), bulkSelectEnabled: Em.computed.alias('controllers.discoveryTopics.bulkSelectEnabled'), checked: function(key, value) { @@ -27,6 +26,16 @@ Discourse.TopicListItemController = Ember.ObjectController.extend({ return selected.contains(topic); }.property('controllers.discoveryTopics.selected.length'), + titleColSpan: function() { + // Uncategorized pinned topics will span the title and category column in the topic list. + return (!this.get('controllers.discoveryTopics.hideCategory') && + this.get('model.isPinnedUncategorized') ? 2 : 1); + }.property('controllers.discoveryTopics.hideCategory', 'model.isPinnedUncategorized'), + + hideCategory: function() { + return this.get('controllers.discoveryTopics.hideCategory') || this.get('titleColSpan') > 1; + }.property('controllers.discoveryTopics.hideCategory', 'titleColSpan'), + actions: { toggleStar: function() { this.get('model').toggleStar(); diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index 867bd5db1be..dc9145c8241 100644 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -260,6 +260,10 @@ Discourse.Topic = Discourse.Model.extend({ }, + isPinnedUncategorized: function() { + return this.get('pinned') && this.get('category.isUncategorizedCategory'); + }.property('pinned', 'category.isUncategorizedCategory'), + /** Clears the pin from a topic for the currently logged in user diff --git a/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars b/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars index 0f5281f80c1..640b86bf629 100644 --- a/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars +++ b/app/assets/javascripts/discourse/templates/list/topic_list_item.js.handlebars @@ -10,7 +10,7 @@ {{/if}} {{/if}} - + {{topicStatus topic=this}} {{{topicLink this}}} {{#if unread}}