FIX: Editing a title would not clear it out on your next edit.
This commit is contained in:
parent
11bb9aafc7
commit
d1a0b5dd44
|
@ -68,7 +68,6 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
post = this.get('post');
|
post = this.get('post');
|
||||||
|
|
||||||
if (post) {
|
if (post) {
|
||||||
|
|
||||||
postDescription = Em.String.i18n('post.' + this.get('action'), {
|
postDescription = Em.String.i18n('post.' + this.get('action'), {
|
||||||
link: postLink,
|
link: postLink,
|
||||||
replyAvatar: Discourse.Utilities.tinyAvatar(post.get('username')),
|
replyAvatar: Discourse.Utilities.tinyAvatar(post.get('username')),
|
||||||
|
@ -80,7 +79,6 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
postDescription += " " + Em.String.i18n("post.in_reply_to") + " " +
|
postDescription += " " + Em.String.i18n("post.in_reply_to") + " " +
|
||||||
Discourse.Utilities.tinyAvatar(replyUsername) + " " + replyUsername;
|
Discourse.Utilities.tinyAvatar(replyUsername) + " " + replyUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this.get('action')) {
|
switch (this.get('action')) {
|
||||||
|
@ -355,7 +353,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
Discourse.Post.load(opts.post.get('id')).then(function(result) {
|
Discourse.Post.load(opts.post.get('id')).then(function(result) {
|
||||||
composer.setProperties({
|
composer.setProperties({
|
||||||
reply: result.get('raw'),
|
reply: result.get('raw'),
|
||||||
originalText: composer.get('reply'),
|
originalText: result.get('raw'),
|
||||||
loading: false
|
loading: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -372,6 +370,20 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Clear any state we have in preparation for a new composition.
|
||||||
|
|
||||||
|
@method clearState
|
||||||
|
**/
|
||||||
|
clearState: function() {
|
||||||
|
this.setProperties({
|
||||||
|
originalText: null,
|
||||||
|
reply: null,
|
||||||
|
post: null,
|
||||||
|
title: null
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// When you edit a post
|
// When you edit a post
|
||||||
editPost: function(opts) {
|
editPost: function(opts) {
|
||||||
var post = this.get('post'),
|
var post = this.get('post'),
|
||||||
|
@ -398,9 +410,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
|
|
||||||
return Ember.Deferred.promise(function(promise) {
|
return Ember.Deferred.promise(function(promise) {
|
||||||
post.save(function(savedPost) {
|
post.save(function(savedPost) {
|
||||||
composer.set('originalText', '');
|
composer.clearState();
|
||||||
composer.set('reply', '');
|
|
||||||
composer.set('post', null);
|
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
var response = $.parseJSON(error.responseText);
|
var response = $.parseJSON(error.responseText);
|
||||||
if (response && response.errors) {
|
if (response && response.errors) {
|
||||||
|
@ -463,6 +473,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
saving = true;
|
saving = true;
|
||||||
|
|
||||||
createdPost.updateFromJson(result);
|
createdPost.updateFromJson(result);
|
||||||
|
|
||||||
if (topic) {
|
if (topic) {
|
||||||
// It's no longer a new post
|
// It's no longer a new post
|
||||||
createdPost.set('newPost', false);
|
createdPost.set('newPost', false);
|
||||||
|
@ -475,11 +486,8 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
saving = false;
|
saving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
composer.setProperties({
|
composer.clearState();
|
||||||
reply: '',
|
composer.set('createdPost', createdPost);
|
||||||
createdPost: createdPost,
|
|
||||||
title: ''
|
|
||||||
});
|
|
||||||
|
|
||||||
if (addedToStream) {
|
if (addedToStream) {
|
||||||
composer.set('composeState', CLOSED);
|
composer.set('composeState', CLOSED);
|
||||||
|
@ -487,7 +495,6 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
composer.set('composeState', SAVING);
|
composer.set('composeState', SAVING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return promise.resolve({ post: result });
|
return promise.resolve({ post: result });
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
// If an error occurs
|
// If an error occurs
|
||||||
|
|
|
@ -159,3 +159,20 @@ asyncTest('importQuote with no post', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('clearState', function() {
|
||||||
|
var composer = Discourse.Composer.create({
|
||||||
|
originalText: 'asdf',
|
||||||
|
reply: 'asdf2',
|
||||||
|
post: Discourse.Post.create({id: 1}),
|
||||||
|
title: 'wat'
|
||||||
|
});
|
||||||
|
|
||||||
|
composer.clearState();
|
||||||
|
|
||||||
|
blank(composer.get('originalText'));
|
||||||
|
blank(composer.get('reply'));
|
||||||
|
blank(composer.get('post'));
|
||||||
|
blank(composer.get('title'));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue