Skip to content

Commit

Permalink
Improved: code and conditions for displaying only users with warehous…
Browse files Browse the repository at this point in the history
…e role (#64)
  • Loading branch information
amansinghbais committed Dec 27, 2023
1 parent 6ef30d1 commit db4af91
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/views/UserDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
<ion-toggle slot="end" :disabled="!hasPermission(Actions.APP_UPDT_PICKER_CONFG)" @click="updatePickerRoleStatus($event)" :checked="selectedUser.isWarehousePicker === true" />
</ion-item>
<ion-item lines="none" button detail :disabled="!hasPermission(Actions.APP_UPDT_FULFILLMENT_FACILITY)" @click="selectFacility()">
<ion-label>{{ getUserFacilities(selectedUser.facilities).length === 1 ? translate('Added to 1 facility') : translate('Added to facilities', { count: getUserFacilities(selectedUser.facilities).length }) }}</ion-label>
<ion-label>{{ getUserFacilities().length === 1 ? translate('Added to 1 facility') : translate('Added to facilities', { count: getUserFacilities().length }) }}</ion-label>
</ion-item>
</ion-list>
</ion-card>
Expand Down Expand Up @@ -551,7 +551,7 @@ export default defineComponent({
},
async selectFacility() {
let componentProps = {
selectedFacilities: this.getUserFacilities(this.selectedUser.facilities)
selectedFacilities: this.getUserFacilities()
} as any
if(this.selectedUser.partyTypeId === 'PARTY_GROUP') {
Expand Down Expand Up @@ -903,8 +903,10 @@ export default defineComponent({
return securityGroups.filter((group: any) => !excludedSecurityGroups.includes(group.groupId))
},
getUserFacilities(facilities: any) {
return facilities.filter((facility: any) => facility.roleTypeId === 'WAREHOUSE_MANAGER')
// Currently a user is getting associated with two roles at a time i.e., 'WAREHOUSE_MANAGER' and 'FAC_LOGIN'
// And here we only want to show records of 'WAREHOUSE_MANAGER'
getUserFacilities() {
return this.selectedUser.facilities.filter((facility: any) => facility.roleTypeId === 'WAREHOUSE_MANAGER')
}
},
setup() {
Expand Down

0 comments on commit db4af91

Please sign in to comment.