diff --git a/src/components/AddStaffMemberModal.vue b/src/components/AddStaffMemberModal.vue index 86c8de72..6782829f 100644 --- a/src/components/AddStaffMemberModal.vue +++ b/src/components/AddStaffMemberModal.vue @@ -30,14 +30,14 @@ {{ description }} - + - - + + @@ -98,7 +98,7 @@ export default defineComponent({ IonToolbar }, props: ['facilityId', 'selectedParties'], - data () { + data() { return { parties: [], queryString: '', @@ -207,13 +207,12 @@ export default defineComponent({ let party = {} as any const selectedRoleTypeId = event.detail.value - if(this.isPartySelected(selectedPartyId)) { + party = this.getParty(selectedPartyId) + if(party?.partyId) { party = this.selectedPartyValues.find((party: any) => party.partyId === selectedPartyId) + this.selectedPartyValues = this.selectedPartyValues.filter((party: any) => party.partyId !== selectedPartyId) - if(selectedRoleTypeId === '') { - this.selectedPartyValues = this.selectedPartyValues.filter((party: any) => party.partyId !== selectedPartyId) - } else if(selectedPartyId !== party.roleTypeId) { - this.selectedPartyValues = this.selectedPartyValues.filter((party: any) => party.partyId !== selectedPartyId) + if(selectedRoleTypeId) { this.selectedPartyValues.push({...party, roleTypeId: selectedRoleTypeId}) } } else { @@ -221,11 +220,11 @@ export default defineComponent({ this.selectedPartyValues.push({...party, roleTypeId: selectedRoleTypeId}) } }, - isPartySelected(partyId: string) { + getParty(partyId: string) { return this.selectedPartyValues.find((party: any) => party.partyId === partyId) }, getPartyRoleTypeId(partyId: string) { - return this.selectedPartyValues.find((party: any) => party.partyId === partyId) ? this.selectedPartyValues.find((party: any) => party.partyId === partyId).roleTypeId : '' + return this.getParty(partyId) ? this.getParty(partyId).roleTypeId : '' } }, async mounted() { diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 78a071d1..87ee4878 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -103,7 +103,7 @@ const actions: ActionTree = { return } - const roles = {} as any + const partyRoles = {} as any const params = { inputFields: { roleTypeGroupId: 'FACILITY_PARTY_ROLE' @@ -118,19 +118,19 @@ const actions: ActionTree = { try { const resp = await UtilService.fetchPartyRoles(params) if (!hasError(resp)) { - resp.data.docs.map((doc:any) => { - roles[doc.roleTypeId] = doc.description + resp.data.docs.map((role: any) => { + partyRoles[role.roleTypeId] = role.description }) // pushing none explicitly to show on UI - roles[''] = 'none' + partyRoles[''] = 'none' } else { throw resp.data } } catch (error) { logger.error(error) } - commit(types.UTIL_PARTY_ROLES_UPDATED, roles) + commit(types.UTIL_PARTY_ROLES_UPDATED, partyRoles) }, clearUtilState({ commit }) {