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: issue in filter option persistence and field overridden issue in filter and sort options(#146) #151

Merged
merged 4 commits into from
Apr 3, 2024
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
4 changes: 4 additions & 0 deletions src/store/modules/orderRouting/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
commit(types.ORDER_ROUTING_HISTORY_UPDATED, routingHistory)
},

async deleteRoutingFilters({ dispatch }, payload) {

Check warning on line 226 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 226 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
let hasAllFiltersDeletedSuccessfully = true;
try {
// As discussed, we can't make parallel api calls, hence using for loop to make api calls
Expand All @@ -243,7 +243,7 @@
return hasAllFiltersDeletedSuccessfully
},

async updateRouting({ dispatch }, payload) {

Check warning on line 246 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 246 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
let orderRoutingId = ''
try {
const resp = await OrderRoutingService.updateRouting(payload)
Expand Down Expand Up @@ -294,7 +294,7 @@
return routingRuleId;
},

async deleteRuleConditions({ dispatch }, payload) {

Check warning on line 297 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 297 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
// TODO: check if we can call request in parallel for delete operation
let hasAllConditionsDeletedSuccessfully = true;
try {
Expand All @@ -314,7 +314,7 @@
return hasAllConditionsDeletedSuccessfully
},

async deleteRuleActions({ dispatch }, payload) {

Check warning on line 317 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 317 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
// TODO: check if we can call request in parallel for delete operation
let hasAllActionsDeletedSuccessfully = true;
try {
Expand Down Expand Up @@ -377,7 +377,7 @@
return rulesInformation[routingRuleId] ? JSON.parse(JSON.stringify(rulesInformation[routingRuleId])) : {}
},

async updateRule({ dispatch }, payload) {

Check warning on line 380 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'dispatch' is defined but never used

Check warning on line 380 in src/store/modules/orderRouting/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'dispatch' is defined but never used
let routingRuleId = ''
try {
const resp = await OrderRoutingService.updateRule(payload)
Expand All @@ -394,6 +394,10 @@

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
Loading