BUGIX: no draft key when creating a topic from the /top page

This commit is contained in:
Régis Hanol 2014-02-11 13:51:21 -08:00
parent cf6f983523
commit 7a85e06119
4 changed files with 44 additions and 11 deletions

View File

@ -0,0 +1,21 @@
/**
This mixin allows a route to open the composer
@class Discourse.OpenComposer
@extends Ember.Mixin
@namespace Discourse
@module Discourse
**/
Discourse.OpenComposer = Em.Mixin.create({
openComposer: function(controller) {
this.controllerFor('composer').open({
categoryId: controller.get('category.id'),
action: Discourse.Composer.CREATE_TOPIC,
draftKey: controller.get('draft_key'),
draftSequence: controller.get('draft_sequence')
});
}
});

View File

@ -15,7 +15,6 @@ Discourse.TopList.reopenClass({
var url = Discourse.getURL("/") + (filter || "top") + ".json";
return Discourse.ajax(url);
}).then(function (result) {
var topList = Discourse.TopList.create({
can_create_topic: result.can_create_topic,
draft: result.draft,

View File

@ -7,7 +7,7 @@
@namespace Discourse
@module Discourse
**/
Discourse.DiscoveryRoute = Discourse.Route.extend({
Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.OpenComposer, {
actions: {
loading: function() {
this.controllerFor('discovery').set('loading', true);
@ -27,13 +27,7 @@ Discourse.DiscoveryRoute = Discourse.Route.extend({
},
createTopic: function() {
var topicsController = this.controllerFor('discoveryTopics');
this.controllerFor('composer').open({
categoryId: topicsController.get('category.id'),
action: Discourse.Composer.CREATE_TOPIC,
draftKey: topicsController.get('draft_key'),
draftSequence: topicsController.get('draft_sequence')
});
this.openComposer(this.controllerFor('discoveryTopics'));
},
changeBulkTemplate: function(w) {
@ -46,5 +40,6 @@ Discourse.DiscoveryRoute = Discourse.Route.extend({
this.send('changeBulkTemplate', 'modal/bulk_actions_buttons');
}
}
});

View File

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
Discourse.DiscoveryTopRoute = Discourse.Route.extend({
Discourse.DiscoveryTopRoute = Discourse.Route.extend(Discourse.OpenComposer, {
beforeModel: function() {
this.controllerFor('navigationDefault').set('filterMode', 'top');
},
@ -35,7 +35,16 @@ Discourse.DiscoveryTopRoute = Discourse.Route.extend({
renderTemplate: function() {
this.render('navigation/default', { outlet: 'navigation-bar' });
this.render('discovery/top', { outlet: 'list-container' });
},
actions: {
createTopic: function() {
this.openComposer(this.controllerFor('discoveryTop'));
}
}
});
/**
@ -46,7 +55,7 @@ Discourse.DiscoveryTopRoute = Discourse.Route.extend({
@namespace Discourse
@module Discourse
**/
Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend({
Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenComposer, {
model: function(params) {
return Discourse.Category.findBySlug(params.slug, params.parentSlug);
},
@ -97,7 +106,16 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend({
deactivate: function() {
this._super();
this.controllerFor('search').set('searchContext', null);
},
actions: {
createTopic: function() {
this.openComposer(this.controllerFor('discoveryTop'));
}
}
});
Discourse.DiscoveryTopCategoryNoneRoute = Discourse.DiscoveryTopCategoryRoute.extend({no_subcategories: true});