mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 18:45:35 +08:00
FIX: save drafts of new topics with titles but no body
This commit is contained in:
parent
dfd309c64f
commit
bca90381cf
@ -740,7 +740,7 @@ export default Ember.Controller.extend({
|
||||
},
|
||||
|
||||
shrink() {
|
||||
if (this.get('model.replyDirty')) {
|
||||
if (this.get('model.replyDirty') || (this.get('model.canEditTitle') && this.get('model.titleDirty'))) {
|
||||
this.collapse();
|
||||
} else {
|
||||
this.close();
|
||||
|
@ -275,6 +275,16 @@ const Composer = RestModel.extend({
|
||||
return this.get('reply') !== this.get('originalText');
|
||||
}.property('reply', 'originalText'),
|
||||
|
||||
/**
|
||||
Did the user make changes to the topic title?
|
||||
|
||||
@property titleDirty
|
||||
**/
|
||||
@computed('title', 'originalTitle')
|
||||
titleDirty(title, originalTitle) {
|
||||
return title !== originalTitle;
|
||||
},
|
||||
|
||||
/**
|
||||
Number of missing characters in the title until valid.
|
||||
|
||||
@ -519,6 +529,9 @@ const Composer = RestModel.extend({
|
||||
}
|
||||
if (opts.title) { this.set('title', opts.title); }
|
||||
this.set('originalText', opts.draft ? '' : this.get('reply'));
|
||||
if (this.get('editingFirstPost')) {
|
||||
this.set('originalTitle', this.get('title'));
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
@ -741,10 +754,18 @@ const Composer = RestModel.extend({
|
||||
saveDraft() {
|
||||
// Do not save when drafts are disabled
|
||||
if (this.get('disableDrafts')) return;
|
||||
// Do not save when there is no reply
|
||||
if (!this.get('reply')) return;
|
||||
// Do not save when the reply's length is too small
|
||||
if (this.get('replyLength') < this.siteSettings.min_post_length) return;
|
||||
|
||||
if (this.get('canEditTitle')) {
|
||||
// Save title and/or post body
|
||||
if (!this.get('title') && !this.get('reply')) return;
|
||||
if (this.get('title') && this.get('titleLengthValid') &&
|
||||
this.get('reply') && this.get('replyLength') < this.siteSettings.min_post_length) return;
|
||||
} else {
|
||||
// Do not save when there is no reply
|
||||
if (!this.get('reply')) return;
|
||||
// Do not save when the reply's length is too small
|
||||
if (this.get('replyLength') < this.siteSettings.min_post_length) return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
reply: this.get('reply'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user