Skip to content

Commit

Permalink
Updated: resolved the comments regarding the scheduled restock functi…
Browse files Browse the repository at this point in the history
…onality(#285)
  • Loading branch information
R-Sourabh committed Jun 6, 2024
1 parent 5b756bb commit 1be633b
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 76 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VUE_APP_PERMISSION_ID="IMPORT_APP_VIEW"
VUE_APP_ALIAS={}
VUE_APP_MAPPING_TYPES={"PO": "PO_MAPPING_PREF","RSTINV": "INV_MAPPING_PREF","RSTSTK": "STK_MAPPING_PREF"}
VUE_APP_MAPPING_PO={"orderId": { "label": "Order ID", "required": true }, "productSku": { "label": "Shopify product SKU", "required": true },"orderDate": { "label": "Arrival date", "required": true }, "quantity": { "label": "Ordered quantity", "required": true }, "facility": { "label": "Facility ID", "required": true }}
VUE_APP_MAPPING_RSTINV={"productIdentification": { "label": "Product Identification", "required": true }, "quantity": { "label": "Quantity", "required": true }}
VUE_APP_MAPPING_RSTSTK={"productIdentification": { "label": "Product Identification", "required": true }, "facility": { "label": "Facility", "required": true }, "restockQuantity": { "label": "Restock quantity", "required": true }}
VUE_APP_MAPPING_RSTINV={"productIdentification": { "label": "Product Identification", "required": true }, "quantity": { "label": "Quantity", "required": true }, "facility": { "label": "Facility ID", "required": true }}
VUE_APP_MAPPING_RSTSTK={"productIdentification": { "label": "Product Identification", "required": true }, "restockQuantity": { "label": "Restock quantity", "required": true }}
VUE_APP_DEFAULT_LOG_LEVEL="error"
VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login"
11 changes: 0 additions & 11 deletions src/components/CreateMappingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,6 @@ export default defineComponent({
methods: {
getFields() {
const fields = process.env["VUE_APP_MAPPING_" + this.mappingType];
if (this.mappingType == 'RSTSTK') {
const parsedFields = fields ? JSON.parse(fields) : {};
const requiredFields: any = {};
for (const [key, value] of Object.entries(parsedFields)) {
if ((value as any).required == true) {
requiredFields[key] = value;
}
}
return requiredFields;
}
return fields ? JSON.parse(fields) : {};
},
closeModal() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ScheduledRestockPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
id="schedule-datetime"
show-default-buttons
hour-cycle="h23"
presentation="date-time"
:value="job.runTime ? getDateTime(job.runTime) : getDateTime(DateTime.now().toMillis())"
@ionChange="changeJobRunTime($event)"
/>
Expand Down Expand Up @@ -140,7 +139,8 @@ export default defineComponent({
setup() {
const store = useStore();
return {
store
store,
translate
}
},
});
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"New version available, please update the app.": "New version available, please update the app.",
"There are no saved CSV mappings to show. Create a new mapping from a file upload screen": "There are no saved CSV mappings to show. Create a new mapping from a file upload screen",
"No new file upload. Please try again": "No new file upload. Please try again",
"No product found": "No product found",
"No products found": "No products found",
"No results found": "No results found",
"No time zone found": "No time zone found",
"of": "of",
Expand All @@ -114,6 +114,7 @@
"Pending": "Pending",
"Please ensure that the uploaded file contains accurate product information. If a product does not exist, the corresponding records will not be processed.": "Please ensure that the uploaded file contains accurate product information. If a product does not exist, the corresponding records will not be processed.",
"Please provide a future date and time": "Please provide a future date and time",
"Please select a facility": "Please select a facility",
"Please select a schedule time": "Please select a schedule time",
"Please select a product store": "Please select a product store",
"Please select a shopify shop": "Please select a shopify shop",
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const routes: Array<RouteRecordRaw> = [
},
{
path: '/scheduled-restock-review',
name: 'ScheduledRestockDetail',
name: 'ScheduledRestockReview',
component: ScheduledRestockReview,
beforeEnter: authGuard
},
Expand Down
3 changes: 1 addition & 2 deletions src/store/modules/stock/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,14 @@ const actions: ActionTree<StockState, RootState> = {
}

const payload = {
'JOB_NAME': restockName || state.schedule.restockName || `Created ${DateTime.fromMillis(+state.schedule.scheduledTime).toLocaleString(DateTime.DATETIME_MED)}`,
'JOB_NAME': restockName || state.schedule.restockName || `Created ${DateTime.now().toLocaleString(DateTime.DATETIME_MED)}`,
'SERVICE_NAME': job.serviceName,
'SERVICE_COUNT': '0',
'SERVICE_TEMP_EXPR': job.jobStatus,
'SERVICE_RUN_AS_SYSTEM':'Y',
'jobFields': {
'systemJobEnumId': job.systemJobEnumId,
'tempExprId': job.jobStatus, // Need to remove this as we are passing frequency in SERVICE_TEMP_EXPR, currently kept it for backward compatibility
'maxRecurrenceCount': '-1',
'parentJobId': job.parentJobId,
'runAsUser': 'system', //default system, but empty in run now. TODO Need to remove this as we are using SERVICE_RUN_AS_SYSTEM, currently kept it for backward compatibility
'recurrenceTimeZone': this.state.user.current.usershipPackedOrdersTimeZone,
Expand Down
8 changes: 7 additions & 1 deletion src/store/modules/util/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ const actions: ActionTree<UtilState, RootState> = {
}
return state.facilities;
},
async fetchProductStores({ state, commit }) {
async fetchProductStores({ commit }) {
let productStores = [];

const payload = {
"viewSize": 50,
"entityName": "ProductStore",
"fieldList": ["storeName", "productStoreId"],
"noConditionFind": "Y"
}
try {
Expand All @@ -126,6 +127,11 @@ const actions: ActionTree<UtilState, RootState> = {

commit(types.UTIL_PRODUCT_STORES_UPDATED, productStores);
},

async clearProductStores({ commit }) {
commit(types.UTIL_PRODUCT_STORES_UPDATED, []);
},

async updateFileProcessingStatus({ commit }, status){
commit(types.UTIL_FILE_PROCESSING_STATUS_UPDATED, { status });
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/Inventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ main {
margin: var(--spacer-sm) auto 0;
}
.review{
ion-button{
margin: var(--spacer-base) var(--spacer-sm);
}
Expand Down
31 changes: 13 additions & 18 deletions src/views/ScheduledRestock.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<ion-page>
<ion-header :translucent="true">
<ion-header>
<ion-toolbar>
<ion-menu-button slot="start" />
<ion-title>{{ translate("Scheduled Restock") }}</ion-title>
Expand All @@ -12,7 +12,7 @@
<ion-item>
<ion-label>{{ translate("Restock") }}</ion-label>
<ion-label class="ion-text-right ion-padding-end">{{ file.name }} </ion-label>
<input @change="parse" ref="file" class="ion-hide" type="file" id="restockInputFile" placeholder=/>
<input @change="parse" ref="file" class="ion-hide" type="file" id="restockInputFile"/>
<label for="restockInputFile" fill="outline">{{ translate("Upload") }}</label>
</ion-item>

Expand Down Expand Up @@ -62,7 +62,6 @@
id="schedule-datetime"
show-default-buttons
hour-cycle="h23"
presentation="date-time"
:value="schedule ? getDateTime(schedule) : getDateTime(DateTime.now().toMillis())"
@ionChange="updateCustomTime($event)"
/>
Expand All @@ -77,7 +76,7 @@
</ion-select>
</ion-item>
<ion-item>
<ion-select :label="translate('Product store')" interface="popover" :value="selectedProductStoreId" @ionChange="updateProductStore($event)">
<ion-select :label="translate('Product store')" interface="popover" :placeholder = "translate('Select')" :value="selectedProductStoreId" @ionChange="updateProductStore($event.detail.value)">
<ion-select-option v-for="productStore in productStores" :key="productStore.productStoreId" :value="productStore.productStoreId">
{{ productStore.storeName || productStore.productStoreId }}
</ion-select-option>
Expand Down Expand Up @@ -119,7 +118,6 @@
id="schedule-datetime"
show-default-buttons
hour-cycle="h23"
presentation="date-time"
:value="currentJob.runTime ? getDateTime(currentJob.runTime) : getDateTime(DateTime.now().toMillis())"
@ionChange="changeJobRunTime($event)"
/>
Expand All @@ -145,6 +143,7 @@ import CreateMappingModal from "@/components/CreateMappingModal.vue";
import { DateTime } from 'luxon';
import { UtilService } from '@/services/UtilService'
import logger from "@/logger";
import emitter from "@/event-bus";
import { StockService } from "@/services/StockService";
export default defineComponent({
Expand Down Expand Up @@ -214,10 +213,7 @@ export default defineComponent({
this.selectedProductStoreId = ""
this.selectedShopifyShopId = ""
this.selectedFacility = ""
await this.store.dispatch('util/fetchFacilities');
await this.store.dispatch('stock/fetchJobs')
await this.store.dispatch('util/fetchProductStores')
await this.store.dispatch('util/fetchGoodIdentificationTypes');
await Promise.allSettled([this.store.dispatch('util/fetchFacilities'), this.store.dispatch('stock/fetchJobs'), this.store.dispatch('util/fetchProductStores'), this.store.dispatch('util/fetchGoodIdentificationTypes')])
},
methods: {
Expand All @@ -229,6 +225,7 @@ export default defineComponent({
try {
const resp = await UtilService.fetchShopifyShop({
entityName: "ShopifyShop",
fieldList: ['name', 'shopId'],
inputFields: {
productStoreId
},
Expand All @@ -244,7 +241,7 @@ export default defineComponent({
logger.error('Failed to fetch shopify shops', error)
}
this.shopifyShops = shopifyShops
this.selectedShopifyShopId = this.shopifyShops[0].shopId ? this.shopifyShops[0].shopId : '';
this.selectedShopifyShopId = this.shopifyShops.length && this.shopifyShops[0]?.shopId ? this.shopifyShops[0].shopId : '';
},
updateTime() {
this.isDateTimeModalOpen = true
Expand Down Expand Up @@ -335,7 +332,7 @@ export default defineComponent({
this.content = await this.parseCsv(this.file);
this.fileColumns = Object.keys(this.content[0]);
showToast(translate("File uploaded successfully"));
this.selectedProductStoreId = this.productStores[0].productStoreId ? this.productStores[5].productStoreId : ''
this.selectedProductStoreId = this.productStores.length ? this.productStores[0].productStoreId : ''
this.updateProductStore(this.selectedProductStoreId)
} else {
showToast(translate("No new file upload. Please try again"));
Expand All @@ -356,6 +353,7 @@ export default defineComponent({
return popover.present();
},
async review() {
emitter.emit("presentLoader")
const areAllFieldsSelected = Object.values(this.fieldMapping).every(field => field !== "");
if (!areAllFieldsSelected) {
showToast(translate("Select all the fields to continue"));
Expand All @@ -377,9 +375,10 @@ export default defineComponent({
restockName: this.restockName,
scheduledTime: this.schedule,
facilityId: this.selectedFacility
})
})
emitter.emit("dismissLoader")
this.router.push({
name:'ScheduledRestockDetail'
name:'ScheduledRestockReview'
})
},
async addFieldMapping() {
Expand All @@ -389,12 +388,8 @@ export default defineComponent({
});
return createMappingModal.present();
},
async updateProductStore(event) {
async updateProductStore(productStoreId) {
this.selectedShopifyShopId = ''
let productStoreId = event
if (event?.detail?.value) {
productStoreId = event.detail.value;
}
this.fetchShopifyShops(productStoreId);
},
getDateTime(time) {
Expand Down
74 changes: 37 additions & 37 deletions src/views/ScheduledRestockReview.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<ion-page>
<ion-header :translucent="true">
<ion-header>
<ion-toolbar>
<ion-back-button slot="start" default-href="/scheduled-restock" />
<ion-title>{{ translate("Restock details")}}</ion-title>
Expand Down Expand Up @@ -32,7 +32,6 @@
id="schedule-datetime"
show-default-buttons
hour-cycle="h23"
presentation="date-time"
:value="schedule.scheduledTime ? getDateTime(schedule.scheduledTime) : getDateTime(DateTime.now().toMillis())"
@ionChange="updateCustomTime($event)"
/>
Expand All @@ -49,13 +48,13 @@
</ion-item>
<ion-item>
<ion-icon slot="start" :icon="globeOutline"/>
<ion-select :label="translate('Product store')" interface="popover" :value="schedule.productStoreId" @ionChange="updateProductStore($event)">
<ion-select :label="translate('Product store')" interface="popover" :placeholder = "translate('Select')" :value="schedule.productStoreId" @ionChange="updateProductStore($event)">
<ion-select-option v-for="productStore in productStores" :key="productStore.productStoreId" :value="productStore.productStoreId">
{{ productStore.storeName || productStore.productStoreId }}
</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-item>
<ion-select :disabled="!schedule.productStoreId" :label="translate('Shopify store')" interface="popover" :placeholder = "translate('Select')" v-model="schedule.shopId">
<ion-select-option v-for="shop in shopifyShops" :key="shop.shopId" :value="shop.shopId">
{{ shop.name ? shop.name : shop.shopId }}
Expand All @@ -69,7 +68,7 @@
</div>
</div>
<div v-if="!parsedItems.length">
<p>{{ translate("No product found") }}</p>
<p>{{ translate("No products found") }}</p>
</div>
<div v-else>
<div class="list-item" v-for="(item , index) in parsedItems" :key="index">
Expand Down Expand Up @@ -114,7 +113,7 @@ import { useRouter } from "vue-router";
export default defineComponent({
name: 'ScheduledRestockDetail',
name: 'ScheduledRestockReview',
components: {
DxpShopifyImg,
IonBackButton,
Expand Down Expand Up @@ -162,41 +161,40 @@ export default defineComponent({
},
async ionViewDidEnter() {
await this.store.dispatch('util/fetchFacilities');
this.getRestockItems();
if(this.schedule.productStoreId) {
this.fetchShopifyShops(this.schedule.productStoreId);
}
},
// async beforeRouteLeave(to) {
// if(to.path === "/login" ) return;
// let canLeave = false;
// const alert = await alertController.create({
// header: translate("Leave page"),
// message: translate("Any edits made on this page will be lost."),
// buttons: [
// {
// text: translate("STAY"),
// handler: () => {
// canLeave = false;
// },
// },
// {
// text: translate("LEAVE"),
// handler: () => {
// canLeave = true;
// },
// },
// ],
// });
// if(!this.isCsvUploadedSuccessfully){
// alert.present();
// await alert.onDidDismiss();
// return canLeave;
// } else {
// this.isCsvUploadedSuccessfully = false;
// }
// },
async beforeRouteLeave(to) {
if(to.path === "/login" ) return;
let canLeave = false;
const alert = await alertController.create({
header: translate("Leave page"),
message: translate("Any edits made on this page will be lost."),
buttons: [
{
text: translate("STAY"),
handler: () => {
canLeave = false;
},
},
{
text: translate("LEAVE"),
handler: () => {
canLeave = true;
},
},
],
});
if(!this.isCsvUploadedSuccessfully){
alert.present();
await alert.onDidDismiss();
return canLeave;
} else {
this.isCsvUploadedSuccessfully = false;
}
},
methods: {
getPlaceholder() {
return `Created ${this.getTime(this.schedule.scheduledTime ? this.schedule.scheduledTime : DateTime.now().toMillis())}`
Expand Down Expand Up @@ -266,6 +264,7 @@ export default defineComponent({
try {
const resp = await UploadService.createIncomingShipment(uploadData)
if(!hasError(resp) && resp.data.shipmentId) {
this.isCsvUploadedSuccessfully = true;
await this.store.dispatch("stock/scheduleService", {
params: {
shipmentId: resp.data.shipmentId,
Expand Down Expand Up @@ -328,6 +327,7 @@ export default defineComponent({
try {
const resp = await UtilService.fetchShopifyShop({
entityName: "ShopifyShop",
fieldList: ['name', 'shopId'],
inputFields: {
productStoreId
},
Expand All @@ -343,7 +343,7 @@ export default defineComponent({
logger.error('Failed to fetch shopify shops.', error)
}
this.shopifyShops = shopifyShops
this.schedule.shopId = this.shopifyShops[0].shopId ? this.shopifyShops[0].shopId : '';
this.schedule.shopId = this.shopifyShops.length && this.shopifyShops[0]?.shopId ? this.shopifyShops[0].shopId : '';
},
getDateTime(time) {
return DateTime.fromMillis(time).toISO()
Expand Down

0 comments on commit 1be633b

Please sign in to comment.