2016-04-15 17:45:50 +03:00
|
|
|
import Ember from 'ember';
|
2016-05-24 15:06:59 +03:00
|
|
|
import ModalComponent from 'ghost-admin/components/modals/base';
|
2016-04-15 17:45:50 +03:00
|
|
|
|
2016-06-11 19:52:36 +03:00
|
|
|
const {A: emberA} = Ember;
|
|
|
|
|
2016-04-15 17:45:50 +03:00
|
|
|
export default ModalComponent.extend({
|
|
|
|
actions: {
|
|
|
|
updateEmail(newEmail) {
|
|
|
|
this.set('model.email', newEmail);
|
2016-06-11 19:52:36 +03:00
|
|
|
this.set('model.hasValidated', emberA());
|
2016-04-15 17:45:50 +03:00
|
|
|
this.get('model.errors').clear();
|
|
|
|
},
|
|
|
|
|
|
|
|
confirm() {
|
|
|
|
let confirmAction = this.get('confirm');
|
|
|
|
|
|
|
|
this.set('submitting', true);
|
|
|
|
|
|
|
|
confirmAction().then(() => {
|
|
|
|
this.send('closeModal');
|
2016-05-08 16:15:04 +03:00
|
|
|
}).catch((errors) => {
|
|
|
|
let [error] = errors;
|
2016-05-11 20:56:58 +03:00
|
|
|
if (error && error.match(/email/i)) {
|
2016-05-08 16:15:04 +03:00
|
|
|
this.get('model.errors').add('email', error);
|
|
|
|
this.get('model.hasValidated').pushObject('email');
|
|
|
|
}
|
2016-04-15 17:45:50 +03:00
|
|
|
}).finally(() => {
|
|
|
|
if (!this.get('isDestroying') && !this.get('isDestroyed')) {
|
|
|
|
this.set('submitting', false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|