FEATURE: accept category_id as new-topic param to better support subcategory

This commit is contained in:
Arpit Jalan 2015-05-01 21:40:28 +05:30
parent 8521ee24b1
commit 480cea7284
4 changed files with 7 additions and 10 deletions

View File

@ -439,11 +439,8 @@ export default DiscourseController.extend({
this.set('model.title', opts.topicTitle);
}
if (opts.topicCategory) {
var category = Discourse.Category.list().findProperty('name', opts.topicCategory);
if (category && category.id) {
this.set('model.categoryId', category.id);
}
if (opts.topicCategoryId) {
this.set('model.categoryId', opts.topicCategoryId);
}
if (opts.topicBody) {

View File

@ -17,12 +17,12 @@ Discourse.OpenComposer = Em.Mixin.create({
});
},
openComposerWithParams: function(controller, title, body, category) {
openComposerWithParams: function(controller, title, body, category_id) {
this.controllerFor('composer').open({
action: Discourse.Composer.CREATE_TOPIC,
topicTitle: title,
topicBody: body,
topicCategory: category,
topicCategoryId: category_id,
draftKey: controller.get('draft_key'),
draftSequence: controller.get('draft_sequence')
});

View File

@ -148,8 +148,8 @@ const ApplicationRoute = Discourse.Route.extend(Discourse.OpenComposer, {
this.render(w, {into: 'modal/topic-bulk-actions', outlet: 'bulkOutlet', controller: factory ? controllerName : 'topic-bulk-actions'});
},
createNewTopicViaParams: function(title, body, category) {
this.openComposerWithParams(this.controllerFor('discovery/topics'), title, body, category);
createNewTopicViaParams: function(title, body, category_id) {
this.openComposerWithParams(this.controllerFor('discovery/topics'), title, body, category_id);
}
},

View File

@ -7,7 +7,7 @@ export default Discourse.Route.extend({
if (self.controllerFor('navigation/default').get('canCreateTopic')) {
// User can create topic
Ember.run.next(function() {
e.send('createNewTopicViaParams', transition.queryParams.title, transition.queryParams.body, transition.queryParams.category);
e.send('createNewTopicViaParams', transition.queryParams.title, transition.queryParams.body, transition.queryParams.category_id);
});
}
});