From 8b876a3c2190609b8dd8f3e3e8e42b86b57c4162 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sat, 9 May 2015 00:37:57 +0530 Subject: [PATCH] convert open-composer mixin to es6 --- ...{open_composer.js => open-composer.js.es6} | 22 +++++++------------ .../discourse/routes/application.js.es6 | 3 ++- .../routes/discovery-categories-route.js.es6 | 3 ++- .../discourse/routes/discovery.js.es6 | 3 ++- 4 files changed, 14 insertions(+), 17 deletions(-) rename app/assets/javascripts/discourse/mixins/{open_composer.js => open-composer.js.es6} (51%) diff --git a/app/assets/javascripts/discourse/mixins/open_composer.js b/app/assets/javascripts/discourse/mixins/open-composer.js.es6 similarity index 51% rename from app/assets/javascripts/discourse/mixins/open_composer.js rename to app/assets/javascripts/discourse/mixins/open-composer.js.es6 index 8e1906ba93..03516b9d8b 100644 --- a/app/assets/javascripts/discourse/mixins/open_composer.js +++ b/app/assets/javascripts/discourse/mixins/open-composer.js.es6 @@ -1,14 +1,8 @@ -/** - This mixin allows a route to open the composer +// This mixin allows a route to open the composer - @class Discourse.OpenComposer - @extends Ember.Mixin - @namespace Discourse - @module Discourse -**/ -Discourse.OpenComposer = Em.Mixin.create({ +export default Ember.Mixin.create({ - openComposer: function(controller) { + openComposer(controller) { this.controllerFor('composer').open({ categoryId: controller.get('category.id'), action: Discourse.Composer.CREATE_TOPIC, @@ -17,13 +11,13 @@ Discourse.OpenComposer = Em.Mixin.create({ }); }, - openComposerWithParams: function(controller, title, body, category_id, category) { + openComposerWithParams(controller, topicTitle, topicBody, topicCategoryId, topicCategory) { this.controllerFor('composer').open({ action: Discourse.Composer.CREATE_TOPIC, - topicTitle: title, - topicBody: body, - topicCategoryId: category_id, - topicCategory: category, + topicTitle, + topicBody, + topicCategoryId, + topicCategory, draftKey: controller.get('draft_key'), draftSequence: controller.get('draft_sequence') }); diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index 22f97dc2c5..17d5d824e9 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -1,4 +1,5 @@ import showModal from 'discourse/lib/show-modal'; +import OpenComposer from "discourse/mixins/open-composer"; function unlessReadOnly(method) { return function() { @@ -10,7 +11,7 @@ function unlessReadOnly(method) { }; } -const ApplicationRoute = Discourse.Route.extend(Discourse.OpenComposer, { +const ApplicationRoute = Discourse.Route.extend(OpenComposer, { siteTitle: Discourse.computed.setting('title'), diff --git a/app/assets/javascripts/discourse/routes/discovery-categories-route.js.es6 b/app/assets/javascripts/discourse/routes/discovery-categories-route.js.es6 index 636a646db2..c46b9b8275 100644 --- a/app/assets/javascripts/discourse/routes/discovery-categories-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/discovery-categories-route.js.es6 @@ -1,7 +1,8 @@ import ShowFooter from 'discourse/mixins/show-footer'; import showModal from 'discourse/lib/show-modal'; +import OpenComposer from "discourse/mixins/open-composer"; -Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(Discourse.OpenComposer, ShowFooter, { +Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(OpenComposer, ShowFooter, { renderTemplate() { this.render('navigation/categories', { outlet: 'navigation-bar' }); this.render('discovery/categories', { outlet: 'list-container' }); diff --git a/app/assets/javascripts/discourse/routes/discovery.js.es6 b/app/assets/javascripts/discourse/routes/discovery.js.es6 index c12cb9a72c..572b9536bd 100644 --- a/app/assets/javascripts/discourse/routes/discovery.js.es6 +++ b/app/assets/javascripts/discourse/routes/discovery.js.es6 @@ -4,8 +4,9 @@ **/ import ShowFooter from "discourse/mixins/show-footer"; +import OpenComposer from "discourse/mixins/open-composer"; -const DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, Discourse.OpenComposer, ShowFooter, { +const DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, OpenComposer, ShowFooter, { redirect: function() { return this.redirectIfLoginRequired(); }, beforeModel: function(transition) {