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 with reordering of rules not being saved by updating the sequence of rules just after reordering instead of updating them before saving(#283) #284

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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
22 changes: 14 additions & 8 deletions src/views/BrokeringQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@

<script setup lang="ts">
import { IonBackButton, IonBadge, IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonCardTitle, IonChip, IonContent, IonFab, IonFabButton, IonHeader, IonIcon, IonInput, IonItem, IonItemDivider, IonItemGroup, IonLabel, IonList, IonNote, IonPage, IonReorder, IonReorderGroup, IonSelect, IonSelectOption, IonTitle, IonToggle, IonToolbar, alertController, modalController, onIonViewWillEnter, popoverController } from "@ionic/vue";
import { addCircleOutline, closeCircleOutline, copyOutline, filterOutline, golfOutline, optionsOutline, pencilOutline, playForwardOutline, pulseOutline, saveOutline, swapVerticalOutline, timeOutline } from "ionicons/icons"

Check warning on line 403 in src/views/BrokeringQuery.vue

View workflow job for this annotation

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

'copyOutline' is defined but never used

Check warning on line 403 in src/views/BrokeringQuery.vue

View workflow job for this annotation

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

'copyOutline' is defined but never used
import { onBeforeRouteLeave, useRouter } from "vue-router";
import { computed, defineProps, nextTick, ref } from "vue";
import store from "@/store";
Expand Down Expand Up @@ -1106,7 +1106,7 @@
isRuleNameUpdating.value = false
}

async function cloneRule() {

Check warning on line 1109 in src/views/BrokeringQuery.vue

View workflow job for this annotation

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

'cloneRule' is defined but never used

Check warning on line 1109 in src/views/BrokeringQuery.vue

View workflow job for this annotation

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

'cloneRule' is defined but never used
emitter.emit("presentLoader", { message: `Cloning ${selectedRoutingRule.value.ruleName}`, backdropDismiss: false })

try {
Expand Down Expand Up @@ -1170,7 +1170,7 @@

function findRulesDiff(previousSeq: any, updatedSeq: any) {
const diffSeq: any = Object.keys(previousSeq).reduce((diff, key) => {
if (updatedSeq[key].routingRuleId === previousSeq[key].routingRuleId && updatedSeq[key].statusId === previousSeq[key].statusId && updatedSeq[key].assignmentEnumId === previousSeq[key].assignmentEnumId && updatedSeq[key].ruleName === previousSeq[key].ruleName) return diff
if (updatedSeq[key].routingRuleId === previousSeq[key].routingRuleId && updatedSeq[key].statusId === previousSeq[key].statusId && updatedSeq[key].assignmentEnumId === previousSeq[key].assignmentEnumId && updatedSeq[key].ruleName === previousSeq[key].ruleName && updatedSeq[key].sequenceNum === previousSeq[key].sequenceNum) return diff
return {
...diff,
[key]: updatedSeq[key]
Expand Down Expand Up @@ -1313,6 +1313,16 @@
diffSeq = Object.keys(diffSeq).map((key) => diffSeq[key])

rulesForReorder.value = updatedSeq

// Once the reordering is completed then update the original rules array with the updated sequenceNum
// This is required as we will find a final diff of rules before saving changes
inventoryRules.value.map((rule: Rule) => {
const updatedRule = updatedSeq.find((seq: any) => seq.routingRuleId === rule.routingRuleId)
if(updatedRule) {
rule.sequenceNum = updatedRule.sequenceNum
}
})

hasUnsavedChanges.value = true
}

Expand All @@ -1331,12 +1341,6 @@
// Find diff for inventory rules
if(currentRouting.value["rules"]) {
let diffSeq = findRulesDiff(currentRouting.value["rules"], inventoryRules.value)

const updatedSeqenceNum = currentRouting.value["rules"].map((rule: Rule) => rule.sequenceNum)
Object.keys(diffSeq).map((key: any) => {
diffSeq[key].sequenceNum = updatedSeqenceNum[key]
})

diffSeq = Object.keys(diffSeq).map((key) => diffSeq[key])

if(diffSeq.length) {
Expand Down Expand Up @@ -1493,7 +1497,9 @@
}

function initializeInventoryRules() {
rulesForReorder.value = JSON.parse(JSON.stringify(getActiveAndDraftOrderRules()))
// Sorting the sequence once again here, as after making some changes in the rules like status, enumId etc
// the original reordered sequence is lost thus before updating the variable sorting it first and then saving changes
rulesForReorder.value = sortSequence(JSON.parse(JSON.stringify(getActiveAndDraftOrderRules())))
}

function getActiveAndDraftOrderRules() {
Expand Down
Loading