mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 01:58:12 +08:00
Hook that allows custom logic before saving the composer
This commit is contained in:
parent
4d67f2a8ed
commit
ee4369f972
|
@ -744,15 +744,22 @@ const Composer = RestModel.extend({
|
|||
return false;
|
||||
},
|
||||
|
||||
save(opts) {
|
||||
if (!this.cantSubmitPost) {
|
||||
// change category may result in some effect for topic featured link
|
||||
if (!this.canEditTopicFeaturedLink) {
|
||||
this.set("featuredLink", null);
|
||||
}
|
||||
// Overwrite to implement custom logic
|
||||
beforeSave() {
|
||||
return Ember.RSVP.Promise.resolve();
|
||||
},
|
||||
|
||||
return this.editingPost ? this.editPost(opts) : this.createPost(opts);
|
||||
}
|
||||
save(opts) {
|
||||
return this.beforeSave().then(() => {
|
||||
if (!this.cantSubmitPost) {
|
||||
// change category may result in some effect for topic featured link
|
||||
if (!this.canEditTopicFeaturedLink) {
|
||||
this.set("featuredLink", null);
|
||||
}
|
||||
|
||||
return this.editingPost ? this.editPost(opts) : this.createPost(opts);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
clearState() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user