Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: functionality to schedule process upload job from initial load page(#2ftaz3n) #192

Merged
merged 2 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VUE_APP_ODR_JOB_ENUMS={"IMP_NEW_ORDERS":"JOB_IMP_ORD","IMP_CANCELLED_ORDERS":"JO
VUE_APP_PRODR_JOB_ENUMS={"PRE_ORDER_CTLG":"JOB_CAT_REL_PREODR","ADD_PRODR_TG_SHPFY":"JOB_ADD_PREORD_VRT","REMV_PRODR_TG_SHPFY":"JOB_RMV_PREORD_VRT","ADD_PRODR_SHPG_DTE_SHPFY":"JOB_ADD_PREORD_SKU","JOB_UPD_PREORD_SKU":"JOB_UPD_PREORD_SKU","REMV_PRODR_SHPG_DTE_SHPFY":"JOB_RMV_PREORD_SKU","BACK_ORDER_CTLG":"JOB_CAT_REL_BACKORD","ADD_BACKODR_TG_SHPFY":"JOB_ADD_BACKORD_VRT","REMV_BACKODR_TG_SHPFY":"JOB_RMV_BACKORD_VRT","ADD_BACKODR_SHPG_DTE_SHPFY":"JOB_ADD_BACKORD_SKU","JOB_UPD_BACKORD_SKU":"JOB_UPD_BACKORD_SKU","REMV_BACKODR_SHPG_DTE_SHPFY":"JOB_RMV_BACKORD_SKU","REALLOC_PRODR":"JOB_REALOC_PO","AUTO_RELSE_DAILY":"JOB_RLS_ORD_DTE"}
VUE_APP_PRD_JOB_ENUMS={"IMP_PRDTS":"JOB_IMP_PROD_NEW","SYNC_PRDTS":"JOB_IMP_PROD_UPD"}
VUE_APP_INV_JOB_ENUMS={"HARD_SYNC":"JOB_UL_INV","BOPIS_CORRECTION":"JOB_BOPIS_RALC"}
VUE_APP_INITIAL_JOB_ENUMS={"IMP_PRDTS_BLK":"JOB_IMP_PROD_NEW_BLK","IMP_ORDERS_BLK":"JOB_IMP_ORD_BLK"}
VUE_APP_INITIAL_JOB_ENUMS={"IMP_PRDTS_BLK":"JOB_IMP_PROD_NEW_BLK","IMP_ORDERS_BLK":"JOB_IMP_ORD_BLK","UL_PRCS":"JOB_UL_PRCS"}
VUE_APP_JOB_TITLES={"JOB_IMP_PROD_NEW":"Import products","JOB_IMP_PROD_UPD":"Sync products","JOB_IMP_ORD_CNCL":"Cancelled orders","JOB_IMP_ORD":"New orders","JOB_IMP_ITM_CNCL":"Cancelled items","JOB_UL_CNCLD_ORD":"Cancelled orders","JOB_UL_CMPLT_ORD":"Completed orders","JOB_IMP_PYMNT_STTS":"Payment status","JOB_IMP_RTN":"Returns","JOB_UL_REFUNDS":"Refunds","JOB_BKR_REJ_ORD":"Rejected orders","JOB_BKR_ORD_UNF":"Unfillable orders","JOB_UL_INV":"Hard sync"}
VUE_APP_INITIAL_JOB_TYPES={"JOB_IMP_PROD_NEW_BLK":"products","JOB_IMP_ORD_BLK":"orders"}
VUE_APP_BASE_URL=
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"Canceling this job will cancel this occurrence and all following occurrences. This job will have to be re-enabled manually to run it again.": "Canceling this job will cancel this occurrence and all following occurrences. This job will have to be re-enabled manually to run it again.",
"Change": "Change",
"Change time zone": "Change time zone",
"Configuration missing": "Configuration missing",
"Confirm": "Confirm",
"Click the backdrop to dismiss.": "Click the backdrop to dismiss.",
"Cancelled orders": "Cancelled orders",
Expand Down Expand Up @@ -99,6 +100,7 @@
"Pin job": "Pin job",
"Pinned jobs": "Pinned jobs",
"Pipeline": "Pipeline",
"Process Uploads": "Process Uploads",
"Product": "Product",
"Products": "Products",
"Promise date changes": "Promise date changes",
Expand Down Expand Up @@ -175,6 +177,7 @@
"Unfillable": "Unfillable",
"Unfillable orders": "Unfillable orders",
"Unfulfilled orders that pass their auto cancelation date will be canceled automatically in HotWax Commerce. They will also be canceled in Shopify if upload for canceled orders is enabled.": "Unfulfilled orders that pass their auto cancelation date will be canceled automatically in HotWax Commerce. They will also be canceled in Shopify if upload for canceled orders is enabled.",
"Upload Pending Process": "Upload Pending Process",
"Update shipping dates in Shopify": "Update shipping dates in Shopify",
"When importing historical completed orders, this should be turned off.": "When importing historical completed orders, this should be turned off.",
"When using HotWax BOPIS, Shopify isn't aware of the actual inventory consumed. HotWax will automatically restore inventory automatically reduced by Shopify and deduct inventory from the correct store to maintain inventory accuracy.": "When using HotWax BOPIS, Shopify isn't aware of the actual inventory consumed. HotWax will automatically restore inventory automatically reduced by Shopify and deduct inventory from the correct store to maintain inventory accuracy."
Expand Down
51 changes: 49 additions & 2 deletions src/views/InitialLoad.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
</ion-label>
</ion-item>
</ion-card>

<ion-card>
<ion-card-header>
<ion-card-title>{{ $t("Process Uploads") }}</ion-card-title>
</ion-card-header>
<ion-item>
<ion-label class="ion-text-wrap">{{ $t("Upload Pending Process") }}</ion-label>
<ion-checkbox slot="end" :checked="processPendingUploadsOnShopify" @ionChange="updateJob($event['detail'].checked, jobEnums['UL_PRCS'])"/>
</ion-item>
</ion-card>
</section>

<aside class="desktop-only" v-if="isDesktop" v-show="currentSelectedJobModal">
Expand All @@ -51,6 +61,7 @@ import {
IonCard,
IonCardHeader,
IonCardTitle,
IonCheckbox,
IonContent,
IonHeader,
IonItem,
Expand All @@ -63,10 +74,11 @@ import {
} from '@ionic/vue';
import { defineComponent } from 'vue';
import { mapGetters, useStore } from 'vuex';
import { isFutureDate } from '@/utils';
import { isFutureDate, showToast } from '@/utils';
import emitter from '@/event-bus';
import InitialJobConfiguration from '@/components/InitialJobConfiguration.vue';
import { useRouter } from 'vue-router';
import { translate } from '@/i18n';

export default defineComponent({
name: 'InitialLoad',
Expand All @@ -76,6 +88,7 @@ export default defineComponent({
IonCard,
IonCardHeader,
IonCardTitle,
IonCheckbox,
IonContent,
IonHeader,
IonItem,
Expand Down Expand Up @@ -109,9 +122,43 @@ export default defineComponent({
getJob: 'job/getJob',
shopifyConfigId: 'user/getShopifyConfigId',
currentEComStore: 'user/getCurrentEComStore'
})
}),
processPendingUploadsOnShopify(): boolean {
const status = this.getJobStatus(this.jobEnums["UL_PRCS"]);
return status && status !== "SERVICE_DRAFT";
},
},
methods: {
async updateJob(checked: boolean, id: string, status = 'EVERY_15_MIN') {
const job = this.getJob(id);

// added check that if the job is not present, then display a toast and then return
if (!job) {
showToast(translate('Configuration missing'))
return;
}

// TODO: added this condition to not call the api when the value of the select automatically changes
// need to handle this properly
if ((checked && job?.status === 'SERVICE_PENDING') || (!checked && job?.status === 'SERVICE_DRAFT')) {
return;
}

job['jobStatus'] = status

// if job runTime is not a valid date then making runTime as empty
if (job?.runTime && !isFutureDate(job?.runTime)) {
job.runTime = ''
}

if (!checked) {
this.store.dispatch('job/cancelJob', job)
} else if (job?.status === 'SERVICE_DRAFT') {
this.store.dispatch('job/scheduleService', job)
} else if (job?.status === 'SERVICE_PENDING') {
this.store.dispatch('job/updateJob', job)
}
},
async viewJobConfiguration(label: string, id: string) {
this.currentSelectedJobModal = label;
this.job = this.getJob(id);
Expand Down