import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ pdiOperationCode : service(), pdiOperationCodeData : service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, formConfig : { modelCode : { isEditable : true }, operationCode : { isEditable : true }, createdBy : { isEditable : true }, updatedBy : { isEditable : true }, }, init() { this._super(...arguments); }, actions: { async savePdiOperationCode() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('pdiOperationCode.model.isApprovalData', false); this.pdiOperationCodeData.save(this.pdiOperationCode.model).then(response => { if (response != undefined) { this.transitionToRoute('pdi-operation-code.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, }, });