Skip to content

Commit

Permalink
Improved: support to unarchive route from modal
Browse files Browse the repository at this point in the history
When moving route from unarchive status we move that route to draft status
Defined emitter to update all the routes after unarchiving a route
  • Loading branch information
ymaheshwari1 committed Jan 19, 2024
1 parent e35e12f commit 1a8250d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
22 changes: 18 additions & 4 deletions src/components/ArchivedRoutingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@

<ion-content>
<ion-list>
<ion-item v-for="routing in props.archivedRoutings" :key="routing.orderRoutingId">
<ion-item v-for="routing in routings" :key="routing.orderRoutingId">
<ion-label>{{ routing.routingName }}</ion-label>
<ion-button slot="end" fill="outline" color="medium">{{ "Unarchive" }}</ion-button>
<ion-button slot="end" fill="outline" color="medium" @click="updateOrderRouting(routing, 'statusId', 'ROUTING_DRAFT')">{{ "Unarchive" }}</ion-button>
</ion-item>
</ion-list>
<p class="empty-state" v-if="!(props as any).archivedRoutings.length">
<p class="empty-state" v-if="!routings.length">
{{ "No archived routings" }}
</p>
</ion-content>
</template>

<script setup lang="ts">
import emitter from "@/event-bus";
import { Route } from "@/types";
import {
IonButton,
IonButtons,
Expand All @@ -38,15 +40,27 @@ import {
modalController,
} from "@ionic/vue";
import { closeOutline } from "ionicons/icons";
import { defineProps } from "vue";
import { defineProps, ref } from "vue";
import { useStore } from "vuex";
const store = useStore()
const props = defineProps({
archivedRoutings: {
required: true
}
})
let routings = ref(props.archivedRoutings)
function closeModal() {
modalController.dismiss({ dismissed: true });
}
async function updateOrderRouting(routing: Route, fieldToUpdate: string, value: string) {
const orderRoutingId = await store.dispatch("orderRouting/updateOrderRouting", { orderRoutingId: routing.orderRoutingId, fieldToUpdate, value })
if(orderRoutingId) {
routings.value = (routings.value as any).filter((routing: Route) => routing.orderRoutingId !== orderRoutingId)
emitter.emit("initializeOrderRoutings")
}
}
</script>
9 changes: 8 additions & 1 deletion src/views/BrokeringRoute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@
</template>

<script setup lang="ts">
import { IonBackButton, IonBadge, IonButtons, IonButton, IonCard, IonCardHeader, IonCardTitle, IonChip, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonList, IonListHeader, IonPage, IonReorder, IonReorderGroup, IonTitle, IonToolbar, alertController, modalController, onIonViewWillEnter } from "@ionic/vue";
import { IonBackButton, IonBadge, IonButtons, IonButton, IonCard, IonCardHeader, IonCardTitle, IonChip, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonList, IonListHeader, IonPage, IonReorder, IonReorderGroup, IonTitle, IonToolbar, alertController, modalController, onIonViewWillEnter, onIonViewWillLeave } from "@ionic/vue";
import { addCircleOutline, archiveOutline, timeOutline, timerOutline } from "ionicons/icons"
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import { computed, defineProps, ref } from "vue";
import { Group, Route } from "@/types";
import ArchivedRoutingModal from "@/components/ArchivedRoutingModal.vue"
import emitter from "@/event-bus";
const router = useRouter();
const store = useStore();
Expand Down Expand Up @@ -128,6 +129,12 @@ onIonViewWillEnter(async () => {
if(!currentRoutingGroup.value.routingGroupId) {
await store.dispatch("orderRouting/fetchOrderRoutingGroups")
}
emitter.on("initializeOrderRoutings", initializeOrderRoutings)
})
onIonViewWillLeave(() => {
emitter.off("initializeOrderRoutings", initializeOrderRoutings)
})
function initializeOrderRoutings() {
Expand Down

0 comments on commit 1a8250d

Please sign in to comment.