Skip to content

Commit

Permalink
Merge pull request #163 from ymaheshwari1/#140
Browse files Browse the repository at this point in the history
Implemented: support to disable the save button if there are no changes in the filter options(#140)
  • Loading branch information
ymaheshwari1 authored Apr 5, 2024
2 parents c8358c4 + ee28e8b commit a97cc8c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/components/AddInventoryFilterOptionsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ion-list>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button @click="saveConditionOptions()">
<ion-fab-button :disabled="!areFiltersUpdated" @click="saveConditionOptions()">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
Expand Down Expand Up @@ -58,6 +58,8 @@ const props = defineProps({
})
let inventoryRuleConditions = ref({}) as any
let enumerations = ref([]) as any
let areFiltersUpdated = ref(false)
const hiddenOptions = ["IIP_MSMNT_SYSTEM"]
// managing this object, as we have some filters for which we need to have its associated filter, like in this case when we have PROXIMITY we also need to add MEASUREMENT_SYSTEM(this is not available on UI for selection and included in hiddenOptions)
const associatedOptions = { IIP_PROXIMITY: { enum: "IIP_MSMNT_SYSTEM", defaultValue: "IMPERIAL" }} as any
Expand All @@ -67,6 +69,17 @@ onMounted(() => {
enumerations.value = Object.values(enums.value[props.parentEnumId]).filter((enumeration: any) => !hiddenOptions.includes(enumeration.enumId))
})
function checkFilters() {
areFiltersUpdated.value = false;
areFiltersUpdated.value = Object.keys(inventoryRuleConditions.value).some((options: string) => {
return !props.ruleConditions[options]
})
areFiltersUpdated.value = areFiltersUpdated.value ? areFiltersUpdated.value : Object.keys(props.ruleConditions).some((options: string) => {
return !inventoryRuleConditions.value[options]
})
}
function addConditionOption(condition: any) {
const isConditionOptionAlreadyApplied = isConditionOptionSelected(condition.enumCode)?.fieldName
const associatedEnum = enums.value[props.parentEnumId][associatedOptions[condition.enumId]?.enum]
Expand Down Expand Up @@ -101,6 +114,8 @@ function addConditionOption(condition: any) {
})
}
}
checkFilters()
}
function saveConditionOptions() {
Expand Down
17 changes: 16 additions & 1 deletion src/components/AddOrderRouteFilterOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ion-list>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button @click="saveSortOptions()">
<ion-fab-button :disabled="!areFiltersUpdated" @click="saveSortOptions()">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
Expand Down Expand Up @@ -57,12 +57,25 @@ const props = defineProps({
}
})
let routingFilters = ref({}) as any
let areFiltersUpdated = ref(false)
onMounted(() => {
routingFilters.value = props.orderRoutingFilters ? JSON.parse(JSON.stringify(props.orderRoutingFilters)) : {}
})
function checkFilters() {
areFiltersUpdated.value = false;
areFiltersUpdated.value = Object.keys(routingFilters.value).some((options: string) => {
return !props.orderRoutingFilters[options]
})
areFiltersUpdated.value = areFiltersUpdated.value ? areFiltersUpdated.value : Object.keys(props.orderRoutingFilters).some((options: string) => {
return !routingFilters.value[options]
})
}
function addSortOption(sort: any) {
const isSortOptionAlreadyApplied = isSortOptionSelected(sort.enumCode)?.fieldName
if(isSortOptionAlreadyApplied) {
Expand All @@ -83,6 +96,8 @@ function addSortOption(sort: any) {
}
}
}
checkFilters()
}
function saveSortOptions() {
Expand Down

0 comments on commit a97cc8c

Please sign in to comment.