🐛 Fixed "Are you sure" modal being shown incorrectly after toggling private mode (#964)

closes TryGhost/Ghost#9472
- add `changedAttributes()` passthrough to `settings` service
- use `changedAttributes()` in general settings `toggleIsPrivate` method to reset the password to the last known value when disabling private mode
This commit is contained in:
Hey24sheep 2018-03-09 20:12:27 +05:30 committed by Kevin Ansfield
parent a947c03594
commit 09fe424eb1
2 changed files with 16 additions and 4 deletions

View File

@ -103,12 +103,20 @@ export default Controller.extend({
},
toggleIsPrivate(isPrivate) {
this.set('settings.isPrivate', isPrivate);
this.get('settings.errors').remove('password');
let settings = this.get('settings');
settings.set('isPrivate', isPrivate);
settings.get('errors').remove('password');
let changedAttrs = settings.changedAttributes();
// set a new random password when isPrivate is enabled
if (isPrivate && this.get('settings.hasDirtyAttributes')) {
this.get('settings').set('password', randomPassword());
if (isPrivate && changedAttrs.isPrivate) {
settings.set('password', randomPassword());
// reset the password when isPrivate is disabled
} else if (changedAttrs.password) {
settings.set('password', changedAttrs.password[0]);
}
},

View File

@ -68,5 +68,9 @@ export default Service.extend(_ProxyMixin, ValidationEngine, {
rollbackAttributes() {
return this.get('content').rollbackAttributes();
},
changedAttributes() {
return this.get('content').changedAttributes();
}
});