diff --git a/app/assets/javascripts/discourse/views/topic-list-item.js.es6 b/app/assets/javascripts/discourse/components/topic-list-item.js.es6 similarity index 79% rename from app/assets/javascripts/discourse/views/topic-list-item.js.es6 rename to app/assets/javascripts/discourse/components/topic-list-item.js.es6 index a7a158bc3f..21d7b3afee 100644 --- a/app/assets/javascripts/discourse/views/topic-list-item.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-list-item.js.es6 @@ -1,22 +1,14 @@ import StringBuffer from 'discourse/mixins/string-buffer'; -export default Ember.View.extend(StringBuffer, { - topic: Em.computed.alias("content"), - rerenderTriggers: ['controller.bulkSelectEnabled', 'topic.pinned'], +export default Ember.Component.extend(StringBuffer, { + rerenderTriggers: ['bulkSelectEnabled', 'topic.pinned'], tagName: 'tr', rawTemplate: 'list/topic-list-item.raw', - classNameBindings: ['controller.checked', - ':topic-list-item', - 'unboundClassNames', - 'selected'], + classNameBindings: [':topic-list-item', 'unboundClassNames'], attributeBindings: ['data-topic-id'], 'data-topic-id': Em.computed.alias('topic.id'), actions: { - select() { - this.set('controller.selectedRow', this); - }, - toggleBookmark() { const self = this; this.get('topic').toggleBookmark().finally(function() { @@ -25,10 +17,6 @@ export default Ember.View.extend(StringBuffer, { } }, - selected: function() { - return this.get('controller.selectedRow')===this; - }.property('controller.selectedRow'), - unboundClassNames: function() { let classes = []; const topic = this.get('topic'); @@ -51,7 +39,7 @@ export default Ember.View.extend(StringBuffer, { }.property(), titleColSpan: function() { - return (!this.get('controller.hideCategory') && + return (!this.get('hideCategory') && this.get('topic.isPinnedUncategorized') ? 2 : 1); }.property("topic.isPinnedUncategorized"), @@ -70,11 +58,11 @@ export default Ember.View.extend(StringBuffer, { return false; } - if (this.get('controller.expandGloballyPinned') && this.get('topic.pinned_globally')) { + if (this.get('expandGloballyPinned') && this.get('topic.pinned_globally')) { return true; } - if (this.get('controller.expandAllPinned')) { + if (this.get('expandAllPinned')) { return true; } @@ -96,7 +84,7 @@ export default Ember.View.extend(StringBuffer, { } if (target.hasClass('bulk-select')) { - const selected = this.get('controller.selected'); + const selected = this.get('selected'); const topic = this.get('topic'); if (target.is(':checked')) { diff --git a/app/assets/javascripts/discourse/templates/components/topic-list.hbs b/app/assets/javascripts/discourse/templates/components/topic-list.hbs index 6f9aa64370..ebc2e1bf5a 100644 --- a/app/assets/javascripts/discourse/templates/components/topic-list.hbs +++ b/app/assets/javascripts/discourse/templates/components/topic-list.hbs @@ -15,5 +15,17 @@ {{/unless}}
- {{each topic in topics itemView="topic-list-item"}} + {{#each topics as |topic|}} + {{topic-list-item topic=topic + bulkSelectEnabled=bulkSelectEnabled + showTopicPostBadges=showTopicPostBadges + hideCategory=hideCategory + showPosters=showPosters + showParticipants=showParticipants + showLikes=showLikes + showOpLikes=showOpLikes + expandGloballyPinned=expandGloballyPinned + expandAllPinned=expandAllPinned + selected=selected}} + {{/each}} 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 4aa7c0607a..bc21dfd6a7 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 @@ -1,4 +1,4 @@ -{{#if controller.bulkSelectEnabled}} +{{#if bulkSelectEnabled}}