Skip to content

Commit

Permalink
Merge pull request #151 from ymaheshwari1/#146
Browse files Browse the repository at this point in the history
Fixed: issue in filter option persistence and field overridden issue in filter and sort options(#146)
  • Loading branch information
ymaheshwari1 authored Apr 3, 2024
2 parents c13ca23 + 6ed4723 commit 5379187
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/store/modules/orderRouting/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ const actions: ActionTree<OrderRoutingState, RootState> = {

async clearRouting({ commit }) {
commit(types.ORDER_ROUTING_CLEARED)
},

async clearRules({ commit }) {
commit(types.ORDER_ROUTING_RULES_UPDATED, {})
}
}

Expand Down
28 changes: 26 additions & 2 deletions src/views/BrokeringQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
},
},
Expand Down Expand Up @@ -831,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) => {
Expand All @@ -858,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) => {
Expand Down Expand Up @@ -891,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 };
}
Expand Down

0 comments on commit 5379187

Please sign in to comment.