Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/hotwax/import into #245fb8k
Browse files Browse the repository at this point in the history
  • Loading branch information
meet-aniket committed Mar 31, 2022
2 parents 5dbe5cf + 41f9940 commit ca68c5d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ VUE_APP_I18N_FALLBACK_LOCALE=en
VUE_APP_CACHE_MAX_AGE=3600
VUE_APP_VIEW_SIZE=10
VUE_APP_SECURITY_KEY=VUE_APP_SECURITY_KEY
VUE_APP_DATE_FORMAT=MM/dd/yyyy
6 changes: 6 additions & 0 deletions changelogs/unreleased/-24gtujf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Updated the code to make date format configurable through env file
ticket_id: "#24gtujf"
merge_request: 28
author: Disha Talreja
type: performance
4 changes: 3 additions & 1 deletion src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import RootState from '@/store/RootState'
import OrderState from './OrderState'
import * as types from './mutation-types'
import router from '@/router'
import { DateTime } from 'luxon';


const actions: ActionTree<OrderState, RootState> = {
Expand All @@ -25,6 +26,7 @@ const actions: ActionTree<OrderState, RootState> = {
return item.shopifyProductSKU == product.internalName;
})
if(product){
item.arrivalDate = DateTime.fromFormat(item.arrivalDate, "D").toFormat(process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy');
item.parentProductId = product.groupId;
item.internalName = product.internalName;
item.parentProductName = product.parentProductName;
Expand All @@ -44,4 +46,4 @@ const actions: ActionTree<OrderState, RootState> = {
commit(types.ORDER_LIST_ITEMS_UPDATED, orderListItems)
},
}
export default actions;
export default actions;
48 changes: 22 additions & 26 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,22 @@
</div>

<div v-else v-for="id in getGroupList(ordersList.items)" :key="id" >
<div v-for="item in getGroupItems(id, ordersList.items)" :key="item">
<div class="list-item list-header">
<ion-label>{{ item.parentProductName }}</ion-label>

<div class="tablet" />

<div class="tablet" />

<div />
<div class="list-item list-header">
<ion-label>{{ getParentInformation(id, ordersList.items).parentProductName }}</ion-label>

<ion-checkbox :checked="isParentProductChecked(id)" @ionChange="selectParentProduct(id, $event)" />

<ion-button fill="clear" color="medium" @click="UpdateProduct($event, id, true, item)">
<ion-icon slot="icon-only" :icon="ellipsisVerticalOutline" />
</ion-button>
</div>
<div class="tablet" />

<div class="tablet" />

<div />

<ion-checkbox :checked="isParentProductChecked(id)" @ionChange="selectParentProduct(id, $event)" />

<ion-button fill="clear" color="medium" @click="UpdateProduct($event, id, true, getParentInformation(id, ordersList.items))">
<ion-icon slot="icon-only" :icon="ellipsisVerticalOutline" />
</ion-button>
</div>
<div v-for="(item, index) in getGroupItems(id, ordersList.items)" :key="index">
<div class="list-item">
<ion-item lines="none">
<ion-thumbnail slot="start">
Expand Down Expand Up @@ -276,7 +275,7 @@ export default defineComponent({
window.location.href = `https://${this.instanceUrl}.hotwax.io/commerce/control/ImportData?configId=IMP_PO`
}
}])
this.ordersList = [];
this.store.dispatch('order/updatedOrderListItems', { items: [], original: [] });
this.router.push("/purchase-order");
}).catch(() => {
showToast(translate("Something went wrong, please try again"));
Expand Down Expand Up @@ -320,15 +319,9 @@ export default defineComponent({
})
return popover.present();
},
selectOnlyParentProduct(id: any){
this.ordersList.items.forEach((item: any) => {
item.isSelected = !item.parentProductId === id;
})
},
isParentProductChecked(parentProductId: string) {
return !(this as any).ordersList.items.filter((item: any) => item.parentProductId === parentProductId).some((item: any) => {
return !item.isSelected
})
const items = (this as any).ordersList.items.filter((item: any) => item.parentProductId === parentProductId)
return items.every((item: any) => item.isSelected)
},
selectProduct(item: any, event: any) {
item.isSelected = event.detail.checked;
Expand All @@ -341,7 +334,7 @@ export default defineComponent({
this.ordersList.items.map((item: any) => {
if (item.isSelected) {
item.quantityOrdered -= this.numberOfPieces;
item.arrivalDate = DateTime.fromFormat(item.arrivalDate, "D").plus({ days: this.numberOfDays }).toFormat('MM/dd/yyyy');
item.arrivalDate = DateTime.fromFormat(item.arrivalDate, process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy').plus({ days: this.numberOfDays }).toFormat(process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy');
item.isNewProduct = this.catalog;
if(this.facilityId) {
item.facilityId = this.facilityId;
Expand All @@ -356,6 +349,9 @@ export default defineComponent({
getGroupItems(parentProductId: any, items: any) {
return items.filter((item: any) => item.parentProductId == parentProductId)
},
getParentInformation(id: any, items: any) {
return items.find((item: any) => item.parentProductId == id)
},
selectAllItems() {
this.ordersList.items.forEach((item: any) => {
item.isSelected = true;
Expand All @@ -364,7 +360,7 @@ export default defineComponent({
selectParentProduct(parentProductId: any, event: any) {
this.ordersList.items.forEach((item: any) => {
if (item.parentProductId == parentProductId) {
item.isSelected = event.detail.checked;
item.isSelected = event.detail.checked;
}
})
}
Expand Down

0 comments on commit ca68c5d

Please sign in to comment.