import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ notification : service(), notificationData : service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, init() { this._super(...arguments); }, actions: { async saveNotification() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('notification.model.isApprovalData', false); this.notificationData.save(this.notification.model).then(response => { if (response != undefined) { this.transitionToRoute('notification.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, }, });