diff --git a/src/components/Menu.vue b/src/components/Menu.vue index c251b43e..d9b72095 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -31,11 +31,19 @@

{{ instanceUrl }}

- {{ eComStore.storeName }} -

{{ currentShopifyConfig.name ? currentShopifyConfig.name : currentShopifyConfig.shopifyConfigName }}

{{ userProfile?.userTimeZone }}
+ + + {{ store.storeName }} + + + + +

{{ currentShopifyConfig.name ? currentShopifyConfig.name : currentShopifyConfig.shopifyConfigName }}

+
+
@@ -54,6 +62,8 @@ import { IonMenu, IonMenuToggle, IonNote, + IonSelect, + IonSelectOption, IonTitle, IonToolbar } from "@ionic/vue"; @@ -61,6 +71,7 @@ import { defineComponent, ref } from "vue"; import { mapGetters } from "vuex"; import { pulseOutline, calendarNumberOutline, terminalOutline, ticketOutline, albumsOutline, shirtOutline, settings, iceCreamOutline, libraryOutline } from "ionicons/icons"; import { useStore } from "@/store"; +import emitter from "@/event-bus" export default defineComponent({ name: "Menu", components: { @@ -75,6 +86,8 @@ export default defineComponent({ IonMenu, IonMenuToggle, IonNote, + IonSelect, + IonSelectOption, IonTitle, IonToolbar }, @@ -94,6 +107,14 @@ export default defineComponent({ currentShopifyConfig: 'user/getCurrentShopifyConfig' }) }, + methods: { + async setEComStore(event: CustomEvent) { + if(this.userProfile) { + await this.store.dispatch('user/setEcomStore', { 'productStoreId': event.detail.value }) + emitter.emit("productStoreChanged") + } + }, + }, watch:{ $route (to) { // When logout and login it should point to Oth index diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 59dd70e4..77237dfd 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -136,7 +136,6 @@ const actions: ActionTree = { if(!productStore) { productStore = this.state.user.current.stores.find((store: any) => store.productStoreId === payload.productStoreId); } - commit(types.USER_CURRENT_ECOM_STORE_UPDATED, productStore); dispatch('getShopifyConfig', productStore.productStoreId); await UserService.setUserPreference({ diff --git a/src/views/InitialLoad.vue b/src/views/InitialLoad.vue index 46902808..f14b1696 100644 --- a/src/views/InitialLoad.vue +++ b/src/views/InitialLoad.vue @@ -115,14 +115,12 @@ export default defineComponent({ isDesktop: isPlatform('desktop') } }, - mounted () { - this.store.dispatch("job/fetchJobs", { - "inputFields":{ - "systemJobEnumId": Object.values(this.jobEnums), - "systemJobEnumId_op": "in" - } - }) - this.store.dispatch('webhook/fetchWebhooks') + mounted() { + this.fetchJobs(); + emitter.on("productStoreChanged", this.fetchJobs); + }, + unmounted() { + emitter.off("productStoreChanged", this.fetchJobs); }, computed: { ...mapGetters({ @@ -195,6 +193,15 @@ export default defineComponent({ this.isJobDetailAnimationCompleted = true; } }, + fetchJobs(){ + this.store.dispatch("job/fetchJobs", { + "inputFields":{ + "systemJobEnumId": Object.values(this.jobEnums), + "systemJobEnumId_op": "in" + } + }) + this.store.dispatch('webhook/fetchWebhooks') + }, async updateWebhook(checked: boolean, enumId: string) { const webhook = this.getCachedWebhook[this.webhookEnums[enumId]] diff --git a/src/views/Inventory.vue b/src/views/Inventory.vue index 1fd5f62c..f554f97b 100644 --- a/src/views/Inventory.vue +++ b/src/views/Inventory.vue @@ -171,17 +171,22 @@ export default defineComponent({ return this.getTemporalExpr(this.getJobStatus(this.jobEnums[enumId]))?.description ? this.getTemporalExpr(this.getJobStatus(this.jobEnums[enumId]))?.description : this.$t('Disabled') + }, + fetchJobs(){ + this.store.dispatch("job/fetchJobs", { + "inputFields":{ + "enumTypeId": "INVENTORY_SYS_JOB" + } + }); } }, mounted () { - this.store.dispatch("job/fetchJobs", { - "inputFields":{ - "enumTypeId": "INVENTORY_SYS_JOB" - } - }); + this.fetchJobs(); + emitter.on("productStoreChanged", this.fetchJobs); emitter.on('viewJobConfiguration', this.viewJobConfiguration) }, unmounted() { + emitter.off("productStoreChanged", this.fetchJobs); emitter.off('viewJobConfiguration', this.viewJobConfiguration) }, setup() { diff --git a/src/views/Orders.vue b/src/views/Orders.vue index 427f96a6..b2403918 100644 --- a/src/views/Orders.vue +++ b/src/views/Orders.vue @@ -455,6 +455,23 @@ export default defineComponent({ }); return jobAlert.present(); }, + fetchJobs(){ + this.store.dispatch("job/fetchJobs", { + "inputFields": { + "enumTypeId": "ORDER_SYS_JOB" + } + }); + this.store.dispatch("job/fetchJobs", { + "inputFields": { + "systemJobEnumId": Object.values(this.batchJobEnums).map((jobEnum: any) => jobEnum.id), + "systemJobEnumId_op": "in" + } + }); + this.store.dispatch('webhook/fetchWebhooks') + if (this.currentEComStore.productStoreId) { + this.getAutoCancelDays(); + } + }, async getAutoCancelDays(){ const payload = { "inputFields": { @@ -479,24 +496,12 @@ export default defineComponent({ } }, mounted () { - this.store.dispatch("job/fetchJobs", { - "inputFields":{ - "enumTypeId": "ORDER_SYS_JOB" - } - }); - this.store.dispatch("job/fetchJobs", { - "inputFields":{ - "systemJobEnumId": Object.values(this.batchJobEnums).map((jobEnum: any) => jobEnum.id), - "systemJobEnumId_op": "in" - } - }); - this.store.dispatch('webhook/fetchWebhooks') - if (this.currentEComStore.productStoreId) { - this.getAutoCancelDays(); - } + this.fetchJobs(); + emitter.on("productStoreChanged", this.fetchJobs); emitter.on('viewJobConfiguration', this.viewJobConfiguration) }, unmounted() { + emitter.off("productStoreChanged", this.fetchJobs); emitter.off('viewJobConfiguration', this.viewJobConfiguration) }, setup() { diff --git a/src/views/Pipeline.vue b/src/views/Pipeline.vue index 872250b4..a98faf17 100644 --- a/src/views/Pipeline.vue +++ b/src/views/Pipeline.vue @@ -37,7 +37,7 @@

{{ $t("There are no jobs pending right now")}}

- + {{ $t('retry') }} @@ -97,7 +97,7 @@

{{ $t("There are no jobs running right now")}}

- + {{ $t('retry') }} @@ -167,7 +167,7 @@

{{ $t("No jobs have run yet")}}

- + {{ $t('retry') }} @@ -457,8 +457,8 @@ export default defineComponent({ event.target.complete(); }) }, - async refreshJobs(event: any) { - this.isRetrying = true; + async refreshJobs(event: any, isRetrying = false ) { + this.isRetrying = isRetrying; if(this.segmentSelected === 'pending') { this.getPendingJobs().then(() => { if(event) event.target.complete(); @@ -589,9 +589,11 @@ export default defineComponent({ await this.store.dispatch('job/updateCurrentJob', { job: {} }); }, mounted(){ + emitter.on("productStoreChanged", this.refreshJobs); emitter.on("pinnedJobsUpdated", (this as any).updateSelectedPinnedJob); }, unmounted(){ + emitter.off("productStoreChanged", this.refreshJobs); emitter.off('jobUpdated', this.updateJobs); emitter.off("pinnedJobsUpdated", (this as any).updateSelectedPinnedJob); }, diff --git a/src/views/PreOrder.vue b/src/views/PreOrder.vue index f79ec194..4bfecf67 100644 --- a/src/views/PreOrder.vue +++ b/src/views/PreOrder.vue @@ -311,18 +311,23 @@ export default defineComponent({ return this.getTemporalExpr(this.getJobStatus(this.jobEnums[enumId]))?.description ? this.getTemporalExpr(this.getJobStatus(this.jobEnums[enumId]))?.description : this.$t('Disabled') + }, + fetchJobs(){ + this.store.dispatch("job/fetchJobs", { + "inputFields":{ + "enumTypeId": "PRE_ORD_SYS_JOB" + } + }); } }, mounted () { - this.store.dispatch("job/fetchJobs", { - "inputFields":{ - "enumTypeId": "PRE_ORD_SYS_JOB" - } - }); + this.fetchJobs(); + emitter.on("productStoreChanged", this.fetchJobs); emitter.on('viewJobConfiguration', this.viewJobConfiguration) }, unmounted() { emitter.on('viewJobConfiguration', this.viewJobConfiguration) + emitter.off("productStoreChanged", this.fetchJobs); }, setup() { const store = useStore(); diff --git a/src/views/Product.vue b/src/views/Product.vue index e15238b7..dbdf1e68 100644 --- a/src/views/Product.vue +++ b/src/views/Product.vue @@ -127,15 +127,13 @@ export default defineComponent({ } }, mounted () { - this.store.dispatch("job/fetchJobs", { - "inputFields":{ - "enumTypeId": "PRODUCT_SYS_JOB" - } - }); + this.fetchJobs(); + emitter.on("productStoreChanged", this.fetchJobs); this.store.dispatch('webhook/fetchWebhooks') emitter.on('viewJobConfiguration', this.viewJobConfiguration) }, unmounted() { + emitter.off("productStoreChanged", this.fetchJobs); emitter.off('viewJobConfiguration', this.viewJobConfiguration) }, methods: { @@ -179,6 +177,14 @@ export default defineComponent({ return this.getTemporalExpr(this.getJobStatus(this.jobEnums[enumId]))?.description ? this.getTemporalExpr(this.getJobStatus(this.jobEnums[enumId]))?.description : this.$t('Disabled') + }, + fetchJobs(){ + this.store.dispatch("job/fetchJobs", { + "inputFields":{ + "enumTypeId": "PRODUCT_SYS_JOB" + } + }); + this.store.dispatch('webhook/fetchWebhooks') } }, setup() {