mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 16:33:59 +08:00
FIX: Support topic templates when changing category too
This commit is contained in:
parent
5e63420064
commit
724781f426
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user