import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ accountManagement : service(), accountManagementData : service(), categoryUioData:service(), addressTypeData : service(), countryData : service(), villageData : service(), provinceData : service(), municipalityData : service(), subDistrictData : service(), accountAddressData : service(), accountAddress:service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, categoryUios: Array(), init() { this._super(...arguments); this.set("rightActionInProgress", false); var categoryUios = this.categoryUioData.getList(); this.set("categoryUios", categoryUios); }, actions: { onChangeCombo(propertyName, itemCollection) { this.set(propertyName, itemCollection); }, async saveAccountManagement() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); this.set('accountManagement.model.isApprovalData', false); this.set('accountManagement.model.isFromCustomer',"true"); this.accountManagementData.save(this.accountManagement.model).then(response => { if (response != undefined) { this.set("rightActionInProgress", false); this.set('errorMessages', null); this.transitionToRoute('account-management.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); console.log(e); this.set('errorMessages', this.errors.getErrorMessages(e)); window.scrollTo(0,0); }); }); }, }, });