mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Fixed brand settings not resetting when cancelling
no issue - trigger modal close once save task has finished - reset unsaved changes when closing the modal (eg, cancel button clicked) - removed unused code that had been copied over from an old controller
This commit is contained in:
parent
cda3bdda62
commit
16324fd2a4
1 changed files with 5 additions and 42 deletions
|
@ -76,6 +76,8 @@ export default ModalComponent.extend({
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
window.removeEventListener('message', this._previewListener);
|
window.removeEventListener('message', this._previewListener);
|
||||||
|
// reset any unsaved changes when closing
|
||||||
|
this.settings.rollbackAttributes();
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -83,47 +85,6 @@ export default ModalComponent.extend({
|
||||||
this.save.perform();
|
this.save.perform();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleLeaveSettingsModal(transition) {
|
|
||||||
let leaveTransition = this.leaveSettingsTransition;
|
|
||||||
|
|
||||||
if (!transition && this.showLeaveSettingsModal) {
|
|
||||||
this.set('leaveSettingsTransition', null);
|
|
||||||
this.set('showLeaveSettingsModal', false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!leaveTransition || transition.targetName === leaveTransition.targetName) {
|
|
||||||
this.set('leaveSettingsTransition', transition);
|
|
||||||
|
|
||||||
// if a save is running, wait for it to finish then transition
|
|
||||||
if (this.save.isRunning) {
|
|
||||||
return this.save.last.then(() => {
|
|
||||||
transition.retry();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// we genuinely have unsaved data, show the modal
|
|
||||||
this.set('showLeaveSettingsModal', true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
leaveSettings() {
|
|
||||||
let transition = this.leaveSettingsTransition;
|
|
||||||
let settings = this.settings;
|
|
||||||
|
|
||||||
if (!transition) {
|
|
||||||
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// roll back changes on settings props
|
|
||||||
settings.rollbackAttributes();
|
|
||||||
|
|
||||||
return transition.retry();
|
|
||||||
},
|
|
||||||
|
|
||||||
reset() {},
|
|
||||||
|
|
||||||
async removeImage(image) {
|
async removeImage(image) {
|
||||||
// setting `null` here will error as the server treats it as "null"
|
// setting `null` here will error as the server treats it as "null"
|
||||||
this.settings.set(image, '');
|
this.settings.set(image, '');
|
||||||
|
@ -213,7 +174,9 @@ export default ModalComponent.extend({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield RSVP.all(validationPromises);
|
yield RSVP.all(validationPromises);
|
||||||
return yield this.settings.save();
|
yield this.settings.save();
|
||||||
|
this.closeModal();
|
||||||
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
notifications.showAPIError(error);
|
notifications.showAPIError(error);
|
||||||
|
|
Loading…
Add table
Reference in a new issue