From 1dfd7ba1abb69427216ced0cc7bf452c5f1ee6b4 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Thu, 18 Apr 2024 15:03:35 +0530 Subject: [PATCH 1/2] Fixed: case related to updating archived routing and its UI(#181) As we need to save the unarchived routings on clicking backdrop, thus added support to directly update the routing status state on clicking unarchive button instead of waiting for the user to close the modal, becuase after unarchiving multiple routings if user clicks backdrop the data is not passed to parent component and the routings are not updated. Improved the case to display archived routing card when we have all the routings as archived --- src/components/ArchivedRoutingModal.vue | 25 ++++-- src/views/BrokeringRoute.vue | 100 ++++++++++++------------ 2 files changed, 70 insertions(+), 55 deletions(-) diff --git a/src/components/ArchivedRoutingModal.vue b/src/components/ArchivedRoutingModal.vue index f51ae0e..35ae17a 100644 --- a/src/components/ArchivedRoutingModal.vue +++ b/src/components/ArchivedRoutingModal.vue @@ -45,22 +45,33 @@ import { defineProps, ref } from "vue"; const props = defineProps({ archivedRoutings: { required: true - } + }, + saveRoutings: { + required: true + } as any }) let routings = ref(props.archivedRoutings) as any -let routingsToUpdate = ref([]) as any +// Not passing any data on modal close as we are updating the routings on every button click. function closeModal() { - modalController.dismiss({ dismissed: true, routings: routingsToUpdate.value.length ? routingsToUpdate.value.concat(routings.value) : [] }); + modalController.dismiss(); } async function updateOrderRouting(routing: Route, fieldToUpdate: string, value: string) { - routingsToUpdate.value.push({ - ...routing, - [fieldToUpdate]: value - }) // remove the updated routing from the archivedRoutings routings.value = routings.value.filter((route: Route) => route.orderRoutingId !== routing.orderRoutingId) + + /* + Instead of updating the same on closeModal we are updating it on every routing unarchive action, as if a user + unarchives multiple routings and then click backdrop then the updated data can't be sent back to the parent component. + Thus used this approach to update the parent data on every routing unarchive click + + As we need the feature to save the routing status even when backdrop is clicked thus added above approach + */ + props.saveRoutings([{ + ...routing, + [fieldToUpdate]: value + }]) } diff --git a/src/views/BrokeringRoute.vue b/src/views/BrokeringRoute.vue index 3193fcd..12902f1 100644 --- a/src/views/BrokeringRoute.vue +++ b/src/views/BrokeringRoute.vue @@ -126,47 +126,49 @@