Skip to content

Commit

Permalink
Improved: Updated the logic of display 'Others' as group type for nul…
Browse files Browse the repository at this point in the history
…l facilityGroupTypeId(#258)
  • Loading branch information
R-Sourabh committed Nov 7, 2024
1 parent f45d25e commit af1bd6d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/AddFacilityGroupModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<form @keyup.enter="updateGroups">
<ion-list>
<ion-item-group v-for="(groups, typeId) in filteredFacilityGroupsByType" :key="typeId">
<ion-item-divider color="medium">{{ typeId === "null" ? translate('Others') : getFacilityGroupTypeDesc(typeId) }}</ion-item-divider>
<ion-item-divider color="medium">{{ getFacilityGroupTypeDesc(typeId) }}</ion-item-divider>
<ion-item v-for="group in groups" :key="group.facilityGroupId">
<ion-checkbox :checked="isFacilityGroupLinked(group.facilityGroupId)" @ion-change="updateGroupsForFacility(group.facilityGroupId)">{{ group.facilityGroupName }}</ion-checkbox>
</ion-item>
Expand Down Expand Up @@ -210,12 +210,13 @@ export default defineComponent({
if(!hasError(resp) && resp.data?.docs?.length > 0) {
this.filteredFacilityGroupsByType = this.facilityGroupsByType = resp.data.docs.reduce((groupsByType: any, group: any) => {
if(groupsByType[group.facilityGroupTypeId]) {
groupsByType[group.facilityGroupTypeId].push(group)
const groupTypeId = !group.facilityGroupTypeId ? "Others" : group.facilityGroupTypeId;
if(groupsByType[groupTypeId]) {
groupsByType[groupTypeId].push(group)
} else {
groupsByType[group.facilityGroupTypeId] = [group]
groupsByType[groupTypeId] = [group]
}
return groupsByType
}, {})
} else {
Expand Down

0 comments on commit af1bd6d

Please sign in to comment.