import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ teamResource : service(), teamResourceData : service(), teamRoleData : service(), teamOrganizationData : service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, teamRoles: Array(), teamOrganizations: Array(), formConfig : { resourceName : { isEditable : true }, firstName : { isEditable : true }, lastName : { isEditable : true }, registryId : { isEditable : true }, teamRole : { isEditable : true }, phone : { isEditable : true }, email : { isEditable : true }, teamOrganization : { isEditable : true }, manager : { isEditable : true }, partyNumber : { isEditable : true }, partyId : { isEditable : true }, }, init() { this._super(...arguments); var teamRoles = this.teamRoleData.getList(); this.set("teamRoles", teamRoles); var teamOrganizations = this.teamOrganizationData.getList(); this.set("teamOrganizations", teamOrganizations); }, actions: { onChangeCombo(propertyName, item) { this.set(propertyName, item); }, async saveTeamResource() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('teamResource.model.isApprovalData', false); this.teamResourceData.save(this.teamResource.model).then(response => { if (response != undefined) { this.transitionToRoute('team-resource.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, }, });