From 4e5831c43fa4fa266ede5602f379ecb9635cdb31 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 3 May 2016 16:13:31 -0400 Subject: [PATCH] Deprecation: Remove `{{each itemView=}}` --- .../topic-list-item.js.es6 | 26 +++++-------------- .../templates/components/topic-list.hbs | 14 +++++++++- .../templates/list/topic-list-item.raw.hbs | 14 +++++----- 3 files changed, 27 insertions(+), 27 deletions(-) rename app/assets/javascripts/discourse/{views => components}/topic-list-item.js.es6 (79%) 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 a7a158bc3f9..21d7b3afee4 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 6f9aa643708..ebc2e1bf5a6 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 4aa7c0607ab..bc21dfd6a7d 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}} @@ -8,7 +8,7 @@ {{raw "topic-status" topic=topic}} {{topic-link topic}} {{plugin-outlet "topic-list-after-title"}} - {{#if controller.showTopicPostBadges}} + {{#if showTopicPostBadges}} {{raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl}} {{/if}} {{#if topic.tags}} @@ -25,23 +25,23 @@ {{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}} -{{#unless controller.hideCategory}} +{{#unless hideCategory}} {{#unless topic.isPinnedUncategorized}} {{raw "list/category-column" category=topic.category}} {{/unless}} {{/unless}} -{{#if controller.showPosters}} +{{#if showPosters}} {{raw "list/posters-column" posters=topic.posters}} {{/if}} {{raw "list/posts-count-column" topic=topic}} -{{#if controller.showParticipants}} +{{#if showParticipants}} {{raw "list/posters-column" posters=topic.participants}} {{/if}} -{{#if controller.showLikes}} +{{#if showLikes}} {{#if hasLikes}} @@ -50,7 +50,7 @@ {{/if}} {{/if}} -{{#if controller.showOpLikes}} +{{#if showOpLikes}} {{#if hasOpLikes}}