import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ approvalConfiguration: service(), hoyuSalesOrderProductSplit : service(), hoyuSalesOrderProductSplitData : service(), color : service(), colorData : service(), rightActionInProgress: false, errors : service(), store : service(), formConfig: false, colors: Array(), async init() { this._super(...arguments); let colors = await this.colorData.getList(); this.set("colors", colors); let formConfig = await this.approvalConfiguration.getApprovalConfiguration("hoyu-sales-order-product-split"); this.set("formConfig", formConfig); }, actions: { async saveHoyuSalesOrderProductSplit() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('hoyuSalesOrderProductSplit.model.isApprovalData', false); this.hoyuSalesOrderProductSplitData.save(this.hoyuSalesOrderProductSplit.model).then(response => { if (response != undefined) { this.transitionToRoute('hoyu-sales-order-approval.hoyu-sales-order-product-split', response.hoyuSalesOrderApprovalId); this.set("rightActionInProgress", false); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, } });