Skip to content

Commit

Permalink
Improved: code to handle the showKitComponents logic on item level, p…
Browse files Browse the repository at this point in the history
…assed job run time in the cancel confirm modal, changed the UI for the cancel items button, and passed productStoreId filter when fetching job(#472)
  • Loading branch information
ymaheshwari1 committed Jan 8, 2025
1 parent e1535e9 commit f3f8cf5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
33 changes: 24 additions & 9 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ const actions: ActionTree<OrderState , RootState> ={
productId: item.productId,
facilityId: item.facilityId,
quantity: item.itemQuantity,
inventoryItemId: item.inventoryItemId
inventoryItemId: item.inventoryItemId,
showKitComponents: false
}]
})
} else {
Expand All @@ -170,7 +171,8 @@ const actions: ActionTree<OrderState , RootState> ={
productId: item.productId,
facilityId: item.facilityId,
quantity: item.itemQuantity,
inventoryItemId: item.inventoryItemId
inventoryItemId: item.inventoryItemId,
showKitComponents: false
})
}

Expand Down Expand Up @@ -203,7 +205,7 @@ const actions: ActionTree<OrderState , RootState> ={
return resp;
},

async fetchAdditionalOrderInformation({ commit, dispatch, state }, orderDetails) {
async fetchAdditionalOrderInformation({ dispatch }, orderDetails) {
let order = orderDetails;
const orderId = order.orderId

Expand Down Expand Up @@ -493,15 +495,17 @@ const actions: ActionTree<OrderState , RootState> ={
orderItemSeqId: item.orderItemSeqId,
productId: item.productId,
facilityId: item.facilityId,
quantity: item.itemQuantity
quantity: item.itemQuantity,
showKitComponents: false
}]
})
} else {
currentOrderPart.items.push({
orderItemSeqId: item.orderItemSeqId,
productId: item.productId,
facilityId: item.facilityId,
quantity: item.itemQuantity
quantity: item.itemQuantity,
showKitComponents: false
})
}

Expand Down Expand Up @@ -543,6 +547,13 @@ const actions: ActionTree<OrderState , RootState> ={
await dispatch('fetchShipGroupForOrder');
},

// This action is added mainly to toggle the showKitComponent property for item from the order detail page
// TODO: check whether we can use this action instead of calling updateCurrent on order info update
// as calling update current again fetches the shipGroup info which is not required in all the cases.
async updateCurrentOrderInfo ({ commit }, order) {
commit(types.ORDER_CURRENT_UPDATED, { order })
},

async updateOrderItemFetchingStatus ({ commit, state }, payload) {
const order = state.current ? JSON.parse(JSON.stringify(state.current)) : {};

Expand Down Expand Up @@ -602,14 +613,16 @@ const actions: ActionTree<OrderState , RootState> ={
items: [{
orderItemSeqId: item.orderItemSeqId,
productId: item.productId,
facilityId: item.facilityId
facilityId: item.facilityId,
showKitComponents: false
}]
})
} else {
currentOrderPart.items.push({
orderItemSeqId: item.orderItemSeqId,
productId: item.productId,
facilityId: item.facilityId
facilityId: item.facilityId,
showKitComponents: false
})
}

Expand Down Expand Up @@ -687,14 +700,16 @@ const actions: ActionTree<OrderState , RootState> ={
items: [{
orderItemSeqId: item.orderItemSeqId,
productId: item.productId,
facilityId: item.facilityId
facilityId: item.facilityId,
showKitComponents: false
}]
})
} else {
currentOrderPart.items.push({
orderItemSeqId: item.orderItemSeqId,
productId: item.productId,
facilityId: item.facilityId
facilityId: item.facilityId,
showKitComponents: false
})
}

Expand Down
28 changes: 15 additions & 13 deletions src/views/OrderDetailUpdated.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,23 @@
<ion-icon color="medium" slot="icon-only" :icon="cubeOutline" />
</ion-button>

<ion-button v-if="isKit(item)" fill="clear" size="small" @click.stop="fetchKitComponents(item)">
<ion-icon v-if="showKitComponents" color="medium" slot="icon-only" :icon="chevronUpOutline"/>
<ion-button v-if="isKit(item)" fill="clear" size="small" @click.stop="fetchKitComponents(item, order)">
<ion-icon v-if="item.showKitComponents" color="medium" slot="icon-only" :icon="chevronUpOutline"/>
<ion-icon v-else color="medium" slot="icon-only" :icon="listOutline"/>
</ion-button>
</div>
</div>
</div>

<template v-if="isKit(item) && showKitComponents && !getProduct(item.productId)?.productComponents">
<template v-if="isKit(item) && item.showKitComponents && !getProduct(item.productId)?.productComponents">
<ion-item lines="none">
<ion-skeleton-text animated style="height: 80%;"/>
</ion-item>
<ion-item lines="none">
<ion-skeleton-text animated style="height: 80%;"/>
</ion-item>
</template>
<template v-else-if="isKit(item) && showKitComponents && getProduct(item.productId)?.productComponents">
<template v-else-if="isKit(item) && item.showKitComponents && getProduct(item.productId)?.productComponents">
<ion-card v-for="(productComponent, index) in getProduct(item.productId).productComponents" :key="index">
<ion-item lines="none">
<ion-thumbnail slot="start">
Expand Down Expand Up @@ -217,7 +217,7 @@
<ion-icon slot="start" :icon="checkmarkDoneOutline"/>
{{ order.part?.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP' ? translate("Handover") : translate("Ship") }}
</ion-button>
<ion-button size="default" :disabled="!hasPermission(Actions.APP_ORDER_UPDATE) || order.handovered || order.shipped || order.cancelled || !order.hasCancelledItems" expand="block" fill="outline" @click="cancelOrder(order)">
<ion-button color="danger" size="default" :disabled="!hasPermission(Actions.APP_ORDER_UPDATE) || order.handovered || order.shipped || order.cancelled || !order.hasCancelledItems" expand="block" fill="outline" @click="cancelOrder(order)">
{{ translate("Cancel Items") }}
</ion-button>
</ion-item>
Expand Down Expand Up @@ -371,8 +371,7 @@ import {
IonFab,
IonFabButton,
modalController,
popoverController,
IonItemOption
popoverController
} from "@ionic/vue";
import { computed, defineComponent } from "vue";
import { mapGetters, useStore } from "vuex";
Expand Down Expand Up @@ -469,7 +468,6 @@ export default defineComponent({
'PAYMENT_REFUNDED': 'warning',
'PAYMENT_SETTLED': ''
} as any,
showKitComponents: false,
rejectEntireOrderReasonId: "REJ_AVOID_ORD_SPLIT",
isCancelationSyncJobEnabled: false,
isProcessRefundEnabled: false,
Expand Down Expand Up @@ -619,7 +617,8 @@ export default defineComponent({
componentProps: {
order,
isCancelationSyncJobEnabled: this.isCancelationSyncJobEnabled,
isProcessRefundEnabled: this.isProcessRefundEnabled
isProcessRefundEnabled: this.isProcessRefundEnabled,
cancelJobNextRunTime: this.cancelJobNextRunTime
}
});
Expand Down Expand Up @@ -767,11 +766,12 @@ export default defineComponent({
if(timeDiff.minutes) diffString += `${Math.round(timeDiff.minutes)} minutes`
return diffString
},
async fetchKitComponents(orderItem: any, toggleKitComponents = true) {
async fetchKitComponents(orderItem: any, order: any, toggleKitComponents = true) {
await this.store.dispatch('product/fetchProductComponents', { productId: orderItem.productId })
if(toggleKitComponents) {
this.showKitComponents = !this.showKitComponents
orderItem.showKitComponents = !orderItem.showKitComponents
this.store.dispatch("order/updateCurrentOrderInfo", order)
}
},
updateColor(stock: number) {
Expand Down Expand Up @@ -822,7 +822,7 @@ export default defineComponent({
// If the current item is kit, and if its components are not available then fetch the components for the kit and mark those components as rejected components
if(isKit(item)) {
if(!this.getProduct(item.productId).productComponents) await this.fetchKitComponents(item, false)
if(!this.getProduct(item.productId).productComponents) await this.fetchKitComponents(item, order, false)
item.rejectedComponents = this.getProduct(item.productId).productComponents?.map((product: any) => product.productIdTo)
}
Expand Down Expand Up @@ -945,7 +945,8 @@ export default defineComponent({
statusId: ["SERVICE_DRAFT", "SERVICE_PENDING"],
statusId_op: "in",
systemJobEnumId: "JOB_UL_CNCLD_ORD",
systemJobEnumId_op: "equals"
systemJobEnumId_op: "equals",
productStoreId: this.currentEComStore?.productStoreId,
},
orderBy: "runTime DESC",
noConditionFind: "Y",
Expand All @@ -961,6 +962,7 @@ export default defineComponent({
this.isCancelationSyncJobEnabled = true;
this.cancelJobNextRunTime = job.runTime
this.getProcessRefundStatus();
return true;
}
})
}
Expand Down

0 comments on commit f3f8cf5

Please sign in to comment.