Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: case to handle the case when enum data is missing for specific type #209

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading