From 1c9ccc6eb118919f39c01e50447428631cca86e8 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 12 Aug 2014 18:26:53 -0400 Subject: [PATCH] ES6: More controllers converted over --- ...rtable_controller.js => discovery-sortable.js.es6} | 2 +- .../{_discovery_controller.js => discovery.js.es6} | 11 +---------- .../discourse/controllers/discovery/categories.js.es6 | 4 +++- .../discourse/controllers/discovery/top.js.es6 | 10 ++-------- .../discourse/controllers/discovery/topics.js.es6 | 10 ++-------- .../controllers/{topic_controller.js => topic.js.es6} | 2 +- .../initializers/dynamic-route-builders.js.es6 | 5 +++-- 7 files changed, 13 insertions(+), 31 deletions(-) rename app/assets/javascripts/discourse/controllers/{discovery_sortable_controller.js => discovery-sortable.js.es6} (84%) rename app/assets/javascripts/discourse/controllers/{_discovery_controller.js => discovery.js.es6} (77%) rename app/assets/javascripts/discourse/controllers/{topic_controller.js => topic.js.es6} (99%) diff --git a/app/assets/javascripts/discourse/controllers/discovery_sortable_controller.js b/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 similarity index 84% rename from app/assets/javascripts/discourse/controllers/discovery_sortable_controller.js rename to app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 index d6b49389e8e..bed27bb21ba 100644 --- a/app/assets/javascripts/discourse/controllers/discovery_sortable_controller.js +++ b/app/assets/javascripts/discourse/controllers/discovery-sortable.js.es6 @@ -1,4 +1,4 @@ -Discourse.DiscoverySortableController = Discourse.Controller.extend({ +export default Discourse.Controller.extend({ needs: ['discovery/topics'], queryParams: ['order', 'ascending', 'status', 'state', 'search'], order: Em.computed.alias('controllers.discovery/topics.order'), diff --git a/app/assets/javascripts/discourse/controllers/_discovery_controller.js b/app/assets/javascripts/discourse/controllers/discovery.js.es6 similarity index 77% rename from app/assets/javascripts/discourse/controllers/_discovery_controller.js rename to app/assets/javascripts/discourse/controllers/discovery.js.es6 index d9a241f268a..66b49a04a13 100644 --- a/app/assets/javascripts/discourse/controllers/_discovery_controller.js +++ b/app/assets/javascripts/discourse/controllers/discovery.js.es6 @@ -1,12 +1,4 @@ -/** - The base controller for discoverying topics - - @class DiscoveryController - @extends Discourse.Controller - @namespace Discourse - @module Discourse -**/ -Discourse.DiscoveryController = Discourse.ObjectController.extend({ +export default Discourse.ObjectController.extend({ loading: false, loadingSpinner: false, scheduledSpinner: null, @@ -25,4 +17,3 @@ Discourse.DiscoveryController = Discourse.ObjectController.extend({ showMoreMonthlyUrl: function() { return this.showMoreUrl('monthly'); }.property('category', 'noSubcategories'), showMoreYearlyUrl: function() { return this.showMoreUrl('yearly'); }.property('category', 'noSubcategories') }); - diff --git a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 index bd9528495ae..9b475e43097 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 @@ -1,4 +1,6 @@ -export default Discourse.DiscoveryController.extend({ +import DiscoveryController from 'discourse/controllers/discovery'; + +export default DiscoveryController.extend({ needs: ['modal', 'discovery'], withLogo: Em.computed.filterBy('categories', 'logo_url'), diff --git a/app/assets/javascripts/discourse/controllers/discovery/top.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/top.js.es6 index be7f3261672..7bb194ad56f 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/top.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/top.js.es6 @@ -1,12 +1,6 @@ -/** - The controller for discoverying 'Top' topics +import DiscoveryController from 'discourse/controllers/discovery'; - @class DiscoveryTopController - @extends Discourse.Controller - @namespace Discourse - @module Discourse -**/ -export default Discourse.DiscoveryController.extend({ +export default DiscoveryController.extend({ needs: ['discovery'], actions: { diff --git a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 index 55b3039e9f4..ba08050911c 100644 --- a/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery/topics.js.es6 @@ -1,12 +1,6 @@ -/** - The controller for displaying a list of topics. +import DiscoveryController from 'discourse/controllers/discovery'; - @class DiscoveryTopicsController - @extends Discourse.Controller - @namespace Discourse - @module Discourse -**/ -export default Discourse.DiscoveryController.extend({ +export default DiscoveryController.extend({ needs: ['discovery'], bulkSelectEnabled: false, selected: [], diff --git a/app/assets/javascripts/discourse/controllers/topic_controller.js b/app/assets/javascripts/discourse/controllers/topic.js.es6 similarity index 99% rename from app/assets/javascripts/discourse/controllers/topic_controller.js rename to app/assets/javascripts/discourse/controllers/topic.js.es6 index 80345837a76..289463010be 100644 --- a/app/assets/javascripts/discourse/controllers/topic_controller.js +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -1,4 +1,4 @@ -Discourse.TopicController = Discourse.ObjectController.extend(Discourse.SelectedPostsCount, { +export default Discourse.ObjectController.extend(Discourse.SelectedPostsCount, { multiSelect: false, needs: ['header', 'modal', 'composer', 'quote-button', 'search', 'topic-progress'], allPostsSelected: false, diff --git a/app/assets/javascripts/discourse/initializers/dynamic-route-builders.js.es6 b/app/assets/javascripts/discourse/initializers/dynamic-route-builders.js.es6 index 67f7fc6f61c..b7b1f04332c 100644 --- a/app/assets/javascripts/discourse/initializers/dynamic-route-builders.js.es6 +++ b/app/assets/javascripts/discourse/initializers/dynamic-route-builders.js.es6 @@ -1,5 +1,6 @@ import buildCategoryRoute from 'discourse/routes/build-category-route'; import buildTopicRoute from 'discourse/routes/build-topic-route'; +import DiscoverySortableController from 'discourse/controllers/discovery-sortable'; export default { name: 'dynamic-route-builders', @@ -11,14 +12,14 @@ export default { app.DiscoveryCategoryNoneRoute = buildCategoryRoute('latest', {no_subcategories: true}); Discourse.Site.currentProp('filters').forEach(function(filter) { - app["Discovery" + filter.capitalize() + "Controller"] = Discourse.DiscoverySortableController.extend(); + app["Discovery" + filter.capitalize() + "Controller"] = DiscoverySortableController.extend(); app["Discovery" + filter.capitalize() + "Route"] = buildTopicRoute(filter); app["Discovery" + filter.capitalize() + "CategoryRoute"] = buildCategoryRoute(filter); app["Discovery" + filter.capitalize() + "CategoryNoneRoute"] = buildCategoryRoute(filter, {no_subcategories: true}); }); Discourse.Site.currentProp('periods').forEach(function(period) { - app["DiscoveryTop" + period.capitalize() + "Controller"] = Discourse.DiscoverySortableController.extend(); + app["DiscoveryTop" + period.capitalize() + "Controller"] = DiscoverySortableController.extend(); app["DiscoveryTop" + period.capitalize() + "Route"] = buildTopicRoute('top/' + period); app["DiscoveryTop" + period.capitalize() + "CategoryRoute"] = buildCategoryRoute('top/' + period); app["DiscoveryTop" + period.capitalize() + "CategoryNoneRoute"] = buildCategoryRoute('top/' + period, {no_subcategories: true});