From 4efc7a2db52fab8a592456ce32c3baf01e79b8a2 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 3 Apr 2024 12:26:45 +0530 Subject: [PATCH 1/4] Fixed: inventory filters not displayed after moving back and forth to the rules page(#146) When creating multiple rules and saving their filters at once, and if moving to the route page and again coming to the rules page, it displays the data from the state instead of fetching the latest information, thus added an action to clear the rules once the page is left so that always the latest information for the rules is fetched --- src/store/modules/orderRouting/actions.ts | 4 ++++ src/views/BrokeringQuery.vue | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/store/modules/orderRouting/actions.ts b/src/store/modules/orderRouting/actions.ts index 2561b66..67f6f17 100644 --- a/src/store/modules/orderRouting/actions.ts +++ b/src/store/modules/orderRouting/actions.ts @@ -394,6 +394,10 @@ const actions: ActionTree = { async clearRouting({ commit }) { commit(types.ORDER_ROUTING_CLEARED) + }, + + async clearRules({ commit }) { + commit(types.ORDER_ROUTING_RULES_UPDATED, {}) } } diff --git a/src/views/BrokeringQuery.vue b/src/views/BrokeringQuery.vue index 8cf12e5..26bd7cc 100644 --- a/src/views/BrokeringQuery.vue +++ b/src/views/BrokeringQuery.vue @@ -330,6 +330,7 @@ onBeforeRouteLeave(async (to) => { if(!hasUnsavedChanges.value) { // clearning the selected ruleId whenever user tries to leave the page, we need to clear this id, as if user opens some other routing then the id will not be found which will result in an empty state scenario store.dispatch("orderRouting/updateRoutingRuleId", "") + store.dispatch("orderRouting/clearRules", "") return; } @@ -348,6 +349,7 @@ onBeforeRouteLeave(async (to) => { handler: () => { // clearning the selected ruleId whenever user leaves the page, we need to clear this id, as if user opens some other routing then the id will not be found which will result in an empty state scenario store.dispatch("orderRouting/updateRoutingRuleId", "") + store.dispatch("orderRouting/clearRules", "") canLeave = true; }, }, From 3a8ef272280b9370e4730211314e80a7ddb4bafc Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 3 Apr 2024 15:26:49 +0530 Subject: [PATCH 2/4] Improved: diff logic for filter and sort options(#146) When having same fieldName in sort and filter options and adding/removing that field in both filter and sort, then always the sort option is honored and the filter option is ignored, as the filter field key gets overridden by the sort key inside the object. Updated the keys after finding the diff to include filter and sort string in the respective options, to handle the override property issue. --- src/views/BrokeringQuery.vue | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/views/BrokeringQuery.vue b/src/views/BrokeringQuery.vue index 26bd7cc..161dfdc 100644 --- a/src/views/BrokeringQuery.vue +++ b/src/views/BrokeringQuery.vue @@ -833,7 +833,7 @@ function findRulesDiff(previousSeq: any, updatedSeq: any) { } function findSortDiff(previousSeq: any, updatedSeq: any) { - let seqToUpdate = {} + let seqToUpdate = {} as any let seqToRemove = {} as any seqToUpdate = Object.keys(previousSeq).reduce((diff, key) => { @@ -860,11 +860,22 @@ function findSortDiff(previousSeq: any, updatedSeq: any) { return diff }, seqToUpdate) + // Updated the keys of the object as there are some cases in which the field is same for both filter and sort options thus causing issue when doing same kind operation (addtion or deletion) of fields + seqToUpdate = Object.keys(seqToUpdate).reduce((updatedSeq: any, key) => { + updatedSeq[key + 'sort'] = seqToUpdate[key] + return updatedSeq + }, {}) + + seqToRemove = Object.keys(seqToRemove).reduce((updatedSeq: any, key) => { + updatedSeq[key + 'sort'] = seqToRemove[key] + return updatedSeq + }, {}) + return { seqToUpdate, seqToRemove }; } function findFilterDiff(previousSeq: any, updatedSeq: any) { - let seqToUpdate = {} + let seqToUpdate = {} as any let seqToRemove = {} as any seqToUpdate = Object.keys(previousSeq).reduce((diff, key) => { @@ -893,6 +904,17 @@ function findFilterDiff(previousSeq: any, updatedSeq: any) { return diff }, seqToUpdate) + // Updated the keys of the object as there are some cases in which the field is same for both filter and sort options thus causing issue when doing same kind operation (addtion or deletion) of fields + seqToUpdate = Object.keys(seqToUpdate).reduce((updatedSeq: any, key) => { + updatedSeq[key + 'filter'] = seqToUpdate[key] + return updatedSeq + }, {}) + + seqToRemove = Object.keys(seqToRemove).reduce((updatedSeq: any, key) => { + updatedSeq[key + 'filter'] = seqToRemove[key] + return updatedSeq + }, {}) + return { seqToUpdate, seqToRemove }; } From 68d9abe596b72ae3758c2ba1cc82925a4e435b28 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 3 Apr 2024 15:31:00 +0530 Subject: [PATCH 3/4] Removed: unused parameter passed to the action call(#146) --- src/views/BrokeringQuery.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/BrokeringQuery.vue b/src/views/BrokeringQuery.vue index 161dfdc..a86123e 100644 --- a/src/views/BrokeringQuery.vue +++ b/src/views/BrokeringQuery.vue @@ -330,7 +330,7 @@ onBeforeRouteLeave(async (to) => { if(!hasUnsavedChanges.value) { // clearning the selected ruleId whenever user tries to leave the page, we need to clear this id, as if user opens some other routing then the id will not be found which will result in an empty state scenario store.dispatch("orderRouting/updateRoutingRuleId", "") - store.dispatch("orderRouting/clearRules", "") + store.dispatch("orderRouting/clearRules") return; } @@ -349,7 +349,7 @@ onBeforeRouteLeave(async (to) => { handler: () => { // clearning the selected ruleId whenever user leaves the page, we need to clear this id, as if user opens some other routing then the id will not be found which will result in an empty state scenario store.dispatch("orderRouting/updateRoutingRuleId", "") - store.dispatch("orderRouting/clearRules", "") + store.dispatch("orderRouting/clearRules") canLeave = true; }, }, From 6ed4723385929be386c8351c79499fe8e7fae7da Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 3 Apr 2024 15:32:38 +0530 Subject: [PATCH 4/4] Improved: the key to separate fieldName and type with _(#146) --- src/views/BrokeringQuery.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/BrokeringQuery.vue b/src/views/BrokeringQuery.vue index a86123e..fa30e4e 100644 --- a/src/views/BrokeringQuery.vue +++ b/src/views/BrokeringQuery.vue @@ -862,12 +862,12 @@ function findSortDiff(previousSeq: any, updatedSeq: any) { // Updated the keys of the object as there are some cases in which the field is same for both filter and sort options thus causing issue when doing same kind operation (addtion or deletion) of fields seqToUpdate = Object.keys(seqToUpdate).reduce((updatedSeq: any, key) => { - updatedSeq[key + 'sort'] = seqToUpdate[key] + updatedSeq[key + '_sort'] = seqToUpdate[key] return updatedSeq }, {}) seqToRemove = Object.keys(seqToRemove).reduce((updatedSeq: any, key) => { - updatedSeq[key + 'sort'] = seqToRemove[key] + updatedSeq[key + '_sort'] = seqToRemove[key] return updatedSeq }, {}) @@ -906,12 +906,12 @@ function findFilterDiff(previousSeq: any, updatedSeq: any) { // Updated the keys of the object as there are some cases in which the field is same for both filter and sort options thus causing issue when doing same kind operation (addtion or deletion) of fields seqToUpdate = Object.keys(seqToUpdate).reduce((updatedSeq: any, key) => { - updatedSeq[key + 'filter'] = seqToUpdate[key] + updatedSeq[key + '_filter'] = seqToUpdate[key] return updatedSeq }, {}) seqToRemove = Object.keys(seqToRemove).reduce((updatedSeq: any, key) => { - updatedSeq[key + 'filter'] = seqToRemove[key] + updatedSeq[key + '_filter'] = seqToRemove[key] return updatedSeq }, {})