From 4d5c54610462cb573f05b70b90e52eea815f4103 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 15 Oct 2024 14:23:45 +0530 Subject: [PATCH] Fixed: case when saving exclude options on server --- src/components/GroupActionsPopover.vue | 9 +-------- src/views/BrokeringQuery.vue | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/GroupActionsPopover.vue b/src/components/GroupActionsPopover.vue index 31dd116..88131b2 100644 --- a/src/components/GroupActionsPopover.vue +++ b/src/components/GroupActionsPopover.vue @@ -42,7 +42,6 @@ const props = defineProps(["group"]) const isOmsConnectionExist = computed(() => store.getters["util/isOmsConnectionExist"]) async function updateGroupStatus(paused: string) { - console.log(props.group) let routingGroups = []; const payload = { routingGroupId: props.group.routingGroupId, @@ -52,13 +51,7 @@ async function updateGroupStatus(paused: string) { try { const resp = await OrderRoutingService.scheduleBrokering(payload) - console.log('resp', resp, hasError(resp)) - if(!hasError(resp)){ - props.group.schedule = { - ...props.group.schedule, - cronExpression: payload.cronExpression, - cronDescription: - } + if(!hasError(resp)) { showToast(translate("Group status updated")) routingGroups = await store.dispatch("orderRouting/updateGroupStatus", { routingGroupId: props.group.routingGroupId, value: paused }) } else { diff --git a/src/views/BrokeringQuery.vue b/src/views/BrokeringQuery.vue index 51e7e03..2720023 100644 --- a/src/views/BrokeringQuery.vue +++ b/src/views/BrokeringQuery.vue @@ -933,7 +933,7 @@ function getSelectedValue(options: any, enumerations: any, parameter: string) { if(value?.length > 1) { return `${value.length} ${translate("selected")}` } else { - return parameter === "SHIPPING_METHOD" ? shippingMethods.value[value[0]]?.description || value[0] : parameter === "SALES_CHANNEL" ? enums.value["ORDER_SALES_CHANNEL"] ? enums.value["ORDER_SALES_CHANNEL"][value[0]]?.description : value[0] : parameter === "ORIGIN_FACILITY_GROUP" ? facilityGroups.value[value[0]]?.facilityGroupName || value[0] : facilities.value[value[0]]?.facilityName || value[0] + return parameter === "SHIPPING_METHOD" || parameter === "SHIPPING_METHOD_EXCLUDED" ? shippingMethods.value[value[0]]?.description || value[0] : parameter === "SALES_CHANNEL" || parameter === "SALES_CHANNEL_EXCLUDED" ? enums.value["ORDER_SALES_CHANNEL"] ? enums.value["ORDER_SALES_CHANNEL"][value[0]]?.description : value[0] : parameter === "ORIGIN_FACILITY_GROUP" || parameter === "ORIGIN_FACILITY_GROUP_EXCLUDED" ? facilityGroups.value[value[0]]?.facilityGroupName || value[0] : facilities.value[value[0]]?.facilityName || value[0] } } @@ -1010,7 +1010,6 @@ function updateOperator(event: CustomEvent) { } function updateOrderFilterValue(event: CustomEvent, id: string, multi = false) { - console.log('id', id) let value = event.detail.value let operator = id.includes("_EXCLUDED") ? "not-equals" : "equals" // When the filter has multiple selection support then we will receive an array in the event value and thus creating a string before updating the same as the fieldValue supports a string as value @@ -1341,6 +1340,19 @@ async function save() { const routeSortOptionsDiff = findSortDiff(initialOrderFilters["ENTCT_SORT_BY"] ? initialOrderFilters["ENTCT_SORT_BY"] : {}, orderRoutingSortOptions.value) const routeFilterOptionsDiff = findFilterDiff(initialOrderFilters["ENTCT_FILTER"] ? initialOrderFilters["ENTCT_FILTER"] : {}, orderRoutingFilterOptions.value) + // As we have explicitely added the options for exclude filter for inventory rules, we will remove the _excluded from the fieldName parameter before updating the same + Object.entries(routeFilterOptionsDiff.seqToRemove).map(([key, value]: any) => { + if(key.includes("_excluded")) { + value["fieldName"] = value["fieldName"].split("_")[0] + } + }) + + Object.entries(routeFilterOptionsDiff.seqToUpdate).map(([key, value]: any) => { + if(key.includes("_excluded")) { + value["fieldName"] = value["fieldName"].split("_")[0] + } + }) + const filtersToRemove = Object.values({ ...routeFilterOptionsDiff.seqToRemove, ...routeSortOptionsDiff.seqToRemove }) const filtersToUpdate = Object.values({ ...routeFilterOptionsDiff.seqToUpdate, ...routeSortOptionsDiff.seqToUpdate }) // Diff found for removing and updating filters