mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: Dirty edit can toggle to another edit.
This commit is contained in:
parent
ca6fcfd001
commit
f98eddb675
3 changed files with 23 additions and 3 deletions
|
@ -399,7 +399,7 @@ export default Ember.Controller.extend({
|
||||||
// If we're already open, we don't have to do anything
|
// If we're already open, we don't have to do anything
|
||||||
if (composerModel.get('composeState') === Discourse.Composer.OPEN &&
|
if (composerModel.get('composeState') === Discourse.Composer.OPEN &&
|
||||||
composerModel.get('draftKey') === opts.draftKey &&
|
composerModel.get('draftKey') === opts.draftKey &&
|
||||||
composerModel.get('action') === opts.action ) {
|
self._isComposerReply(composerModel, opts)) {
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ export default Ember.Controller.extend({
|
||||||
if (composerModel.get('composeState') === Discourse.Composer.DRAFT &&
|
if (composerModel.get('composeState') === Discourse.Composer.DRAFT &&
|
||||||
composerModel.get('draftKey') === opts.draftKey) {
|
composerModel.get('draftKey') === opts.draftKey) {
|
||||||
composerModel.set('composeState', Discourse.Composer.OPEN);
|
composerModel.set('composeState', Discourse.Composer.OPEN);
|
||||||
if (composerModel.get('action') === opts.action) return resolve();
|
if (self._isComposerReply(composerModel, opts)) return resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's a different draft, cancel it and try opening again.
|
// If it's a different draft, cancel it and try opening again.
|
||||||
|
@ -430,6 +430,11 @@ export default Ember.Controller.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_isComposerReply(composerModel, opts) {
|
||||||
|
return (composerModel.get('action') === Discourse.Composer.REPLY &&
|
||||||
|
composerModel.get('action') === opts.action);
|
||||||
|
},
|
||||||
|
|
||||||
// Given a potential instance and options, set the model for this composer.
|
// Given a potential instance and options, set the model for this composer.
|
||||||
_setModel(composerModel, opts) {
|
_setModel(composerModel, opts) {
|
||||||
if (opts.draft) {
|
if (opts.draft) {
|
||||||
|
|
|
@ -371,7 +371,7 @@ const Composer = RestModel.extend({
|
||||||
|
|
||||||
const composer = this;
|
const composer = this;
|
||||||
if (!replyBlank &&
|
if (!replyBlank &&
|
||||||
((opts.reply || opts.action === this.EDIT) && this.get('replyDirty'))) {
|
((opts.reply || opts.action === EDIT) && this.get('replyDirty'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,21 @@ test("Composer can switch between edits", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Composer with dirty edit can toggle to another edit", () => {
|
||||||
|
visit("/t/this-is-a-test-topic/9");
|
||||||
|
|
||||||
|
click('.topic-post:eq(0) button[data-action=edit]');
|
||||||
|
fillIn('.wmd-input', 'This is a dirty reply');
|
||||||
|
click('.topic-post:eq(1) button[data-action=edit]');
|
||||||
|
andThen(() => {
|
||||||
|
ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog');
|
||||||
|
});
|
||||||
|
click('.modal-footer a:eq(0)');
|
||||||
|
andThen(() => {
|
||||||
|
equal(find('.wmd-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("Composer can toggle between edit and reply", () => {
|
test("Composer can toggle between edit and reply", () => {
|
||||||
visit("/t/this-is-a-test-topic/9");
|
visit("/t/this-is-a-test-topic/9");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue