import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ subBusinessSegment : service(), subBusinessSegmentData : service(), businessSegmentData : service(), errors : service(), didValidate: false, businessSegments: Array(), formConfig : { subBusinessSegmentCode : { isEditable : true }, subBusinessSegment : { isEditable : true }, businessSegment : { isEditable : true }, }, init() { this._super(...arguments); var businessSegments = this.businessSegmentData.getList(); this.set("businessSegments", businessSegments); }, actions: { onChangeCombo(propertyName, item) { this.set(propertyName, item); }, saveSubBusinessSegment() { this.get('model') .validate() .then(({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('subBusinessSegment.model.isApprovalData', false); this.subBusinessSegmentData.save(this.subBusinessSegment.model).then(response => { if (response != undefined) { this.transitionToRoute('sub-business-segment.detail', response.id); } }) .catch((e) => { this.set('errorMessages', this.errors.getErrorMessages(e)); }); } }); }, }, });