import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ privilegeInfo : service(), privilegeInfoData : service(), coreUserGroupData : service(), coreFunctionInfoData : service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, groupIds: Array(), functionIds: Array(), formConfig : { groupId : { isEditable : true }, functionId : { isEditable : true }, allowCreate : { isEditable : true }, allowRead : { isEditable : true }, allowUpdate : { isEditable : true }, allowDelete : { isEditable : true }, allowSubmitChangeRequest : { isEditable : true }, allowCancelRequest : { isEditable : true }, isShow : { isEditable : true }, createdBy : { isEditable : true }, updatedBy : { isEditable : true }, }, init() { this._super(...arguments); var groupIds = this.coreUserGroupData.getList(); this.set("groupIds", groupIds); var functionIds = this.coreFunctionInfoData.getList(); this.set("functionIds", functionIds); }, actions: { onChangeCombo(propertyName, item) { this.set(propertyName, item); }, async savePrivilegeInfo() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('privilegeInfo.model.isApprovalData', false); this.privilegeInfoData.save(this.privilegeInfo.model).then(response => { if (response != undefined) { this.set("rightActionInProgress", false); this.transitionToRoute('privilege-info.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, }, });