import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ approvalLog : service(), approvalLogData : service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, formConfig : { documentTypeCode : { isEditable : true }, documentTypeDescription : { isEditable : true }, approvalCode : { isEditable : true }, approvalName : { isEditable : true }, syncTarget : { isEditable : true }, transactionId : { isEditable : true }, sourceSystemNo : { isEditable : true }, requestNo : { isEditable : true }, approvalInboxStatus : { isEditable : true }, notes : { isEditable : true }, action : { isEditable : true }, validationMessage : { isEditable : true }, }, init() { this._super(...arguments); }, actions: { async saveApprovalLog() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('approvalLog.model.isApprovalData', false); this.approvalLogData.save(this.approvalLog.model).then(response => { if (response != undefined) { this.transitionToRoute('approval-log.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, }, });