Skip to content

Commit

Permalink
Merge pull request #209 from ymaheshwari1/fix/empty-state-on-missing-…
Browse files Browse the repository at this point in the history
…data

Fixed: case to handle the case when enum data is missing for specific type
  • Loading branch information
ymaheshwari1 authored Apr 29, 2024
2 parents 8b0de43 + 4993d4b commit 22f2511
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/components/AddInventoryFilterOptionsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<div v-if="!enumerations.length" class="empty-state">
<p>{{ translate(`Failed to fetch ${props.label?.toLowerCase()} options`) }}</p>
</div>
<ion-list v-else>
<ion-item v-for="condition in enumerations" :key="condition.enumId">
<ion-checkbox :checked="isConditionOptionSelected(condition.enumCode)" @ionChange="addConditionOption(condition)">{{ condition.description || condition.enumCode }}</ion-checkbox>
</ion-item>
Expand Down Expand Up @@ -66,7 +69,7 @@ const associatedOptions = { IIP_PROXIMITY: { enum: "IIP_MSMNT_SYSTEM", defaultVa
onMounted(() => {
inventoryRuleConditions.value = props.ruleConditions ? JSON.parse(JSON.stringify(props.ruleConditions)) : {}
enumerations.value = Object.values(enums.value[props.parentEnumId]).filter((enumeration: any) => !hiddenOptions.includes(enumeration.enumId))
enumerations.value = enums.value[props.parentEnumId] ? Object.values(enums.value[props.parentEnumId]).filter((enumeration: any) => !hiddenOptions.includes(enumeration.enumId)) : []
})
function checkFilters() {
Expand Down
7 changes: 5 additions & 2 deletions src/components/AddOrderRouteFilterOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item v-for="sort in Object.values(enums[props.parentEnumId] ? enums[props.parentEnumId] : {})" :key="sort.enumId">
<div v-if="!enums[props.parentEnumId]" class="empty-state">
<p>{{ translate(`Failed to fetch ${$props.label?.toLowerCase()} options`) }}</p>
</div>
<ion-list v-else>
<ion-item v-for="sort in Object.values(enums[props.parentEnumId])" :key="sort.enumId">
<ion-checkbox :checked="isSortOptionSelected(sort.enumCode)" @ionChange="addSortOption(sort)">{{ sort.description || sort.enumCode }}</ion-checkbox>
</ion-item>
</ion-list>
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"Failed to create brokering run": "Failed to create brokering run",
"Failed to create inventory rule": "Failed to create inventory rule",
"Failed to create order routing": "Failed to create order routing",
"Failed to fetch filter options": "Failed to fetch filter options",
"Failed to fetch sort options": "Failed to fetch sort options",
"Failed to update group information": "Failed to update group information",
"Failed to update group status": "Failed to update group status",
"Failed to schedule service": "Failed to schedule service",
Expand Down
4 changes: 2 additions & 2 deletions src/views/BrokeringQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ function getPromiseDateValue() {
}
function getFilterValue(options: any, enums: any, parameter: string) {
return options?.[enums[parameter].code]
return enums[parameter] ? options?.[enums[parameter].code] : undefined
}
function getSelectedValue(options: any, enumerations: any, parameter: string) {
Expand All @@ -793,7 +793,7 @@ function getSelectedValue(options: any, enumerations: any, parameter: string) {
function getLabel(parentType: string, code: string) {
const enumerations = enums.value[parentType]
const enumInfo: any = Object.values(enumerations).find((enumeration: any) => enumeration.enumCode === code)
const enumInfo: any = enumerations ? Object.values(enumerations).find((enumeration: any) => enumeration.enumCode === code) : null
return enumInfo?.description
}
Expand Down

0 comments on commit 22f2511

Please sign in to comment.