2016-04-15 17:45:50 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
import ModalComponent from 'ghost/components/modals/base';
|
|
|
|
|
|
|
|
export default ModalComponent.extend({
|
|
|
|
actions: {
|
|
|
|
updateEmail(newEmail) {
|
|
|
|
this.set('model.email', newEmail);
|
|
|
|
this.set('model.hasValidated', Ember.A());
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|