Skip to content

Commit

Permalink
Improved: logic to show spinner and close configuration card in case …
Browse files Browse the repository at this point in the history
…of product store change (hotwax#720)
  • Loading branch information
amansinghbais committed Aug 9, 2024
1 parent 779f7be commit 68d636b
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 36 deletions.
22 changes: 19 additions & 3 deletions src/views/Brokering.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
</ion-header>

<ion-content>
<main>
<div class="empty-state" v-if="jobsLoading">
<ion-item lines="none">
<ion-spinner name="crescent" slot="start" />
{{ translate("Fetching jobs") }}
</ion-item>
</div>
<main v-else>
<section>
<ion-button expand="block" :disabled="!hasPermission(Actions.APP_JOB_UPDATE)" @click="addBatch()">{{ translate('Create new brokering job') }}</ion-button>

Expand Down Expand Up @@ -58,7 +64,7 @@
<MoreJobs v-if="getMoreJobs({...jobEnums, ...initialLoadJobEnums}, enumTypeId).length" :jobs="getMoreJobs({...jobEnums, ...initialLoadJobEnums}, enumTypeId)" />
</section>

<aside class="desktop-only" v-if="isDesktop" v-show="currentJob">
<aside class="desktop-only" v-if="isDesktop" v-show="currentJob && Object.keys(currentJob).length">
<JobConfiguration :status="currentJobStatus" :type="freqType" :key="currentJob" :isBrokerJob="orderBatchJobs.includes(currentJob) ? true : false"/>
</aside>
</main>
Expand All @@ -83,6 +89,7 @@ import {
IonMenuButton,
IonPage,
IonRow,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand Down Expand Up @@ -121,6 +128,7 @@ export default defineComponent({
IonMenuButton,
IonPage,
IonRow,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand All @@ -138,7 +146,8 @@ export default defineComponent({
isJobDetailAnimationCompleted: false,
isDesktop: isPlatform('desktop'),
enumTypeId: 'BROKER_SYS_JOB',
initialLoadJobEnums: JSON.parse(process.env?.VUE_APP_INITIAL_JOB_ENUMS as string) as any
initialLoadJobEnums: JSON.parse(process.env?.VUE_APP_INITIAL_JOB_ENUMS as string) as any,
jobsLoading: false
}
},
computed: {
Expand Down Expand Up @@ -209,6 +218,12 @@ export default defineComponent({
translate('Disabled')
},
async fetchJobs() {
this.jobsLoading = true;
this.currentJob = "";
await this.store.dispatch('job/updateCurrentJob', { });
this.currentJobStatus = "";
this.freqType = "";
this.isJobDetailAnimationCompleted = false;
await this.store.dispatch("job/fetchJobs", {
"inputFields": {
// If we fetch broker sys job by not passing systemJobEnumId filter then this api
Expand All @@ -225,6 +240,7 @@ export default defineComponent({
"systemJobEnumId_op": "in"
}
});
this.jobsLoading = false;
},
timeFromNow(time: any) {
const timeDiff = DateTime.fromMillis(time).diff(DateTime.local());
Expand Down
20 changes: 18 additions & 2 deletions src/views/Fulfillment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
</ion-header>

<ion-content>
<main>
<div class="empty-state" v-if="jobsLoading">
<ion-item lines="none">
<ion-spinner name="crescent" slot="start" />
{{ translate("Fetching jobs") }}
</ion-item>
</div>
<main v-else>
<section>
<ion-card>
<ion-card-header>
Expand Down Expand Up @@ -110,6 +116,7 @@ import {
IonLabel,
IonMenuButton,
IonPage,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand Down Expand Up @@ -142,6 +149,7 @@ export default defineComponent({
IonLabel,
IonMenuButton,
IonPage,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand All @@ -159,7 +167,8 @@ export default defineComponent({
isDesktop: isPlatform('desktop'),
autoCancelDays: '',
enumTypeId: 'FULFILLMENT_SYS_JOB',
initialLoadJobEnums: JSON.parse(process.env?.VUE_APP_INITIAL_JOB_ENUMS as string) as any
initialLoadJobEnums: JSON.parse(process.env?.VUE_APP_INITIAL_JOB_ENUMS as string) as any,
jobsLoading: false
}
},
computed: {
Expand Down Expand Up @@ -233,6 +242,12 @@ export default defineComponent({
}
},
async fetchJobs(){
this.jobsLoading = true;
this.currentJob = "";
await this.store.dispatch('job/updateCurrentJob', { });
this.currentJobStatus = "";
this.freqType = "";
this.isJobDetailAnimationCompleted = false;
await this.store.dispatch("job/fetchJobs", {
"inputFields": {
"enumTypeId": "FULFILLMENT_SYS_JOB"
Expand All @@ -241,6 +256,7 @@ export default defineComponent({
if (this.currentEComStore.productStoreId) {
this.getAutoCancelDays();
}
this.jobsLoading = false;
},
async getAutoCancelDays(){
const payload = {
Expand Down
24 changes: 20 additions & 4 deletions src/views/InitialLoad.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
</ion-header>

<ion-content>
<main>
<div class="empty-state" v-if="jobsLoading">
<ion-item lines="none">
<ion-spinner name="crescent" slot="start" />
{{ translate("Fetching jobs") }}
</ion-item>
</div>
<main v-else>
<section>
<ion-card>
<ion-card-header>
Expand Down Expand Up @@ -74,6 +80,7 @@ import {
IonLabel,
IonMenuButton,
IonPage,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand Down Expand Up @@ -103,6 +110,7 @@ export default defineComponent({
IonLabel,
IonMenuButton,
IonPage,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar
Expand All @@ -115,7 +123,8 @@ export default defineComponent({
job: {} as any,
lastShopifyOrderId: '',
isJobDetailAnimationCompleted: false,
isDesktop: isPlatform('desktop')
isDesktop: isPlatform('desktop'),
jobsLoading: false
}
},
mounted() {
Expand Down Expand Up @@ -207,14 +216,21 @@ export default defineComponent({
this.isJobDetailAnimationCompleted = true;
}
},
fetchJobs(){
this.store.dispatch("job/fetchJobs", {
async fetchJobs(){
this.jobsLoading = true;
this.currentSelectedJobModal = "";
await this.store.dispatch('job/updateCurrentJob', { });
this.job = {};
this.lastShopifyOrderId = "";
this.isJobDetailAnimationCompleted = false;
await this.store.dispatch("job/fetchJobs", {
"inputFields":{
"systemJobEnumId": Object.values(this.jobEnums),
"systemJobEnumId_op": "in"
}
})
this.store.dispatch('webhook/fetchWebhooks')
this.jobsLoading = false;
},
async updateWebhook(checked: boolean, enumId: string) {
const webhook = this.getCachedWebhook[this.webhookEnums[enumId]]
Expand Down
26 changes: 21 additions & 5 deletions src/views/Inventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
</ion-header>

<ion-content>
<main>
<div class="empty-state" v-if="jobsLoading">
<ion-item lines="none">
<ion-spinner name="crescent" slot="start" />
{{ translate("Fetching jobs") }}
</ion-item>
</div>
<main v-else>
<section>
<ion-card>
<ion-card-header>
Expand Down Expand Up @@ -56,6 +62,7 @@ import {
IonLabel,
IonMenuButton,
IonPage,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand Down Expand Up @@ -83,6 +90,7 @@ export default defineComponent({
IonLabel,
IonMenuButton,
IonPage,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand All @@ -100,6 +108,7 @@ export default defineComponent({
isDesktop: isPlatform('desktop'),
enumTypeId: 'INVENTORY_SYS_JOB',
webhookEnums: JSON.parse(process.env?.VUE_APP_WEBHOOK_ENUMS as string) as any,
jobsLoading: false
}
},
computed: {
Expand Down Expand Up @@ -165,16 +174,23 @@ export default defineComponent({
this.getTemporalExpr(this.getJobStatus(this.jobEnums[enumId]))?.description :
translate('Disabled')
},
fetchJobs(){
this.store.dispatch("job/fetchJobs", {
async fetchJobs(){
await this.store.dispatch("job/fetchJobs", {
"inputFields":{
"enumTypeId": "INVENTORY_SYS_JOB"
}
});
},
fetchData() {
async fetchData() {
this.jobsLoading = true;
this.currentJob = "";
await this.store.dispatch('job/updateCurrentJob', { });
this.currentJobStatus = "";
this.freqType = "";
this.isJobDetailAnimationCompleted = false;
this.store.dispatch('webhook/fetchWebhooks')
this.fetchJobs()
await this.fetchJobs()
this.jobsLoading = false;
}
},
mounted () {
Expand Down
15 changes: 14 additions & 1 deletion src/views/Miscellaneous.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
</ion-header>

<ion-content>
<main>
<div class="empty-state" v-if="jobsLoading">
<ion-item lines="none">
<ion-spinner name="crescent" slot="start" />
{{ translate("Fetching jobs") }}
</ion-item>
</div>
<main v-else>
<section>
<!-- Empty state -->
<div v-if="miscellaneousJobs?.length === 0">
Expand Down Expand Up @@ -108,6 +114,7 @@ export default defineComponent({
isJobDetailAnimationCompleted: false,
isDesktop: isPlatform('desktop'),
isRetrying: false,
jobsLoading: false
}
},
computed: {
Expand Down Expand Up @@ -150,7 +157,13 @@ export default defineComponent({
}
},
async getMiscellaneousJobs(viewSize = 100, viewIndex = 0) {
this.jobsLoading = true;
this.currentJob = "";
await this.store.dispatch('job/updateCurrentJob', { });
this.currentJobStatus = "";
this.isJobDetailAnimationCompleted = false;
await this.store.dispatch('job/fetchMiscellaneousJobs', {eComStoreId: this.getCurrentEComStore.productStoreId, viewSize, viewIndex});
this.jobsLoading = false;
},
async loadMoreMiscellaneousJobs (event: any) {
this.getMiscellaneousJobs(
Expand Down
20 changes: 18 additions & 2 deletions src/views/Orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
</ion-header>

<ion-content>
<main>
<div class="empty-state" v-if="jobsLoading">
<ion-item lines="none">
<ion-spinner name="crescent" slot="start" />
{{ translate("Fetching jobs") }}
</ion-item>
</div>
<main v-else>
<section>
<ion-card>
<ion-card-header>
Expand Down Expand Up @@ -105,6 +111,7 @@ import {
IonLabel,
IonMenuButton,
IonPage,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand Down Expand Up @@ -133,6 +140,7 @@ export default defineComponent({
IonLabel,
IonMenuButton,
IonPage,
IonSpinner,
IonTitle,
IonToggle,
IonToolbar,
Expand All @@ -150,7 +158,8 @@ export default defineComponent({
isJobDetailAnimationCompleted: false,
isDesktop: isPlatform('desktop'),
enumTypeId: 'ORDER_SYS_JOB',
initialLoadJobEnums: JSON.parse(process.env?.VUE_APP_INITIAL_JOB_ENUMS as string) as any
initialLoadJobEnums: JSON.parse(process.env?.VUE_APP_INITIAL_JOB_ENUMS as string) as any,
jobsLoading: false
}
},
computed: {
Expand Down Expand Up @@ -268,12 +277,19 @@ export default defineComponent({
translate('Disabled')
},
async fetchJobs(){
this.jobsLoading = true;
this.currentJob = ""
await this.store.dispatch('job/updateCurrentJob', { });
this.currentJobStatus = ""
this.freqType = ""
this.isJobDetailAnimationCompleted = false
this.store.dispatch('webhook/fetchWebhooks')
await this.store.dispatch("job/fetchJobs", {
"inputFields": {
"enumTypeId": "ORDER_SYS_JOB"
}
});
this.jobsLoading = false;
}
},
mounted () {
Expand Down
Loading

0 comments on commit 68d636b

Please sign in to comment.