FIX: Support topic templates when changing category too

This commit is contained in:
Robin Ward 2015-07-07 14:39:24 -04:00
parent 5e63420064
commit 724781f426

View File

@ -304,6 +304,21 @@ const Composer = RestModel.extend({
Discourse.KeyValueStore.set({ key: 'composer.showPreview', value: this.get('showPreview') });
},
applyTopicTemplate: function() {
if (this.get('action') !== CREATE_TOPIC) { return; }
if (!Ember.isEmpty(this.get('reply'))) { return; }
const categoryId = this.get('categoryId');
const category = this.site.categories.find((c) => c.get('id') === categoryId);
if (category) {
const topicTemplate = category.get('topic_template');
if (!Ember.isEmpty(topicTemplate)) {
this.set('reply', topicTemplate);
}
}
}.observes('categoryId'),
/*
Open a composer
@ -354,16 +369,6 @@ const Composer = RestModel.extend({
reply: opts.reply || this.get("reply") || ""
});
if (opts.action === CREATE_TOPIC && categoryId) {
const category = this.site.categories.find((c) => c.get('id') === categoryId);
if (category) {
const topicTemplate = category.get('topic_template');
if (!Ember.isEmpty(topicTemplate)) {
this.set('reply', topicTemplate);
}
}
}
if (opts.postId) {
this.set('loading', true);
this.store.find('post', opts.postId).then(function(post) {