Merge pull request #3439 from techAPJ/patch-2

convert open-composer mixin to es6
This commit is contained in:
Robin Ward 2015-05-08 15:38:12 -04:00
commit 9e7182474a
4 changed files with 14 additions and 17 deletions

View file

@ -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 export default Ember.Mixin.create({
@extends Ember.Mixin
@namespace Discourse
@module Discourse
**/
Discourse.OpenComposer = Em.Mixin.create({
openComposer: function(controller) { openComposer(controller) {
this.controllerFor('composer').open({ this.controllerFor('composer').open({
categoryId: controller.get('category.id'), categoryId: controller.get('category.id'),
action: Discourse.Composer.CREATE_TOPIC, 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({ this.controllerFor('composer').open({
action: Discourse.Composer.CREATE_TOPIC, action: Discourse.Composer.CREATE_TOPIC,
topicTitle: title, topicTitle,
topicBody: body, topicBody,
topicCategoryId: category_id, topicCategoryId,
topicCategory: category, topicCategory,
draftKey: controller.get('draft_key'), draftKey: controller.get('draft_key'),
draftSequence: controller.get('draft_sequence') draftSequence: controller.get('draft_sequence')
}); });

View file

@ -1,4 +1,5 @@
import showModal from 'discourse/lib/show-modal'; import showModal from 'discourse/lib/show-modal';
import OpenComposer from "discourse/mixins/open-composer";
function unlessReadOnly(method) { function unlessReadOnly(method) {
return function() { 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'), siteTitle: Discourse.computed.setting('title'),

View file

@ -1,7 +1,8 @@
import ShowFooter from 'discourse/mixins/show-footer'; import ShowFooter from 'discourse/mixins/show-footer';
import showModal from 'discourse/lib/show-modal'; 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() { renderTemplate() {
this.render('navigation/categories', { outlet: 'navigation-bar' }); this.render('navigation/categories', { outlet: 'navigation-bar' });
this.render('discovery/categories', { outlet: 'list-container' }); this.render('discovery/categories', { outlet: 'list-container' });

View file

@ -4,8 +4,9 @@
**/ **/
import ShowFooter from "discourse/mixins/show-footer"; 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(); }, redirect: function() { return this.redirectIfLoginRequired(); },
beforeModel: function(transition) { beforeModel: function(transition) {