diff --git a/src/components/MoreJobs.vue b/src/components/MoreJobs.vue index 7ec900c0..17f49edb 100644 --- a/src/components/MoreJobs.vue +++ b/src/components/MoreJobs.vue @@ -5,7 +5,7 @@ - {{ job.jobName }} + {{ job.enumName || job.jobName }} {{ job.statusId === "SERVICE_PENDING" ? temporalExpr(job.tempExprId)?.description : $t('Disabled') }} @@ -37,7 +37,7 @@ export default defineComponent({ IonLabel, IonList }, - props: ["jobs", "jobEnums"], + props: ["jobs"], computed: { ...mapGetters({ getJobStatus: 'job/getJobStatus', diff --git a/src/store/modules/job/JobState.ts b/src/store/modules/job/JobState.ts index 84ed5782..412920d9 100644 --- a/src/store/modules/job/JobState.ts +++ b/src/store/modules/job/JobState.ts @@ -16,16 +16,6 @@ export default interface JobState { list: any, total: 0 } - more: { - pending: { - list: any, - total: 0 - } - draft: { - list: any, - total: 0 - } - } current: any; temporalExp: any; enumIds: any; diff --git a/src/store/modules/job/actions.ts b/src/store/modules/job/actions.ts index f9a1f4ce..ac30ddef 100644 --- a/src/store/modules/job/actions.ts +++ b/src/store/modules/job/actions.ts @@ -357,7 +357,7 @@ const actions: ActionTree = { ...payload.inputFields }, "noConditionFind": "Y", - "viewSize": (payload.inputFields?.systemJobEnumId?.length * 3) + "viewSize": (payload.inputFields?.systemJobEnumId?.length * 3) || 50 } as any if (payload?.orderBy) { @@ -754,69 +754,6 @@ const actions: ActionTree = { console.error(err); } }, - async fetchMoreJobs({ commit }, payload) { - const fetchJobRequests = []; - let params = { - "inputFields": { - "enumTypeId": payload.inputFields.enumTypeId, - "statusId": "SERVICE_DRAFT", - "systemJobEnumId_op": "not-empty", - "shopId_fld0_value": store.state.user.currentShopifyConfig?.shopId, - "shopId_fld0_grp": "1", - "shopId_fld0_op": "equals", - "shopId_fld1_grp": "2", - "shopId_fld1_op": "empty" - } as any, - "fieldList": [ "systemJobEnumId", "runTime", "tempExprId", "parentJobId", "serviceName", "jobId", "jobName", "currentRetryCount", "statusId", "productStoreId", "runtimeDataId", "enumName", "shopId", "description" ], - "noConditionFind": "Y", - "viewSize": 30, // as we've not implemented infiniteScroll in moreJobs, we are passing viewSize hardcodedly as 30 - "viewIndex": 0 - } - - fetchJobRequests.push(JobService.fetchJobInformation(params).catch((err) => { - return err; - })) - - // Deep cloning in order to avoid mutating the same reference causing side effects - params = JSON.parse(JSON.stringify(params)); - - // Fetching pending jobs - params.inputFields.statusId = "SERVICE_PENDING"; - params.inputFields.productStoreId = this.state.user.currentEComStore.productStoreId; - fetchJobRequests.push(JobService.fetchJobInformation(params).catch((err) => { - return err; - })) - - try { - const resp = await Promise.all(fetchJobRequests) - const moreJobs = resp.reduce((responseJobs: any, response: any) => { - response.status === 200 && !hasError(response) && response.data.docs && (responseJobs = [...responseJobs, ...response.data.docs]); - return responseJobs; - }, []) - - if(moreJobs.length) { - const morePendingJobs = moreJobs.filter((job: any) => job.statusId === "SERVICE_PENDING") - const moreDraftJobs = moreJobs.filter((job: any) => job.statusId === "SERVICE_DRAFT") - - commit(types.JOB_MORE_UPDATED, { - pendingJobs: morePendingJobs, - pendingTotal: morePendingJobs.length, - draftJobs: moreDraftJobs, - draftTotal: moreDraftJobs.length, - }); - } else { - commit(types.JOB_MORE_UPDATED, { - pendingJobs: [], - pendingTotal: 0, - draftJobs: [], - draftTotal: 0, - }); - } - } catch (err) { - console.error(err); - showToast(translate("Something went wrong")); - } - }, setPipelineFilters({ commit, state }, payload) { const pipelineFilters = JSON.parse(JSON.stringify(state.pipelineFilters)); const pipelineFilter = (pipelineFilters as any)[payload.type] diff --git a/src/store/modules/job/getters.ts b/src/store/modules/job/getters.ts index 31c0f6a8..258e09d9 100644 --- a/src/store/modules/job/getters.ts +++ b/src/store/modules/job/getters.ts @@ -57,17 +57,15 @@ const getters: GetterTree = { isMiscellaneousJobsScrollable: (state) => { return state.miscellaneous.list?.length > 0 && state.miscellaneous.list?.length < state.miscellaneous.total }, - getMoreJobs (state){ - let jobs = state.more.draft.list.reduce((jobs: any, draftJob: any) => { - jobs[draftJob.systemJobEnumId] = draftJob; - return jobs; - }, {}) - jobs = state.more.pending.list.reduce((jobs: any, pendingJob: any) => { - jobs[pendingJob.systemJobEnumId] = pendingJob; - return jobs; - }, jobs) + getMoreJobs: (state) => (jobEnums: any, enumTypeId: string): any => { + const orderJobEnumIds = Object.values(jobEnums) as any; - return Object.values(jobs) + return Object.keys(state.cached).reduce((jobs: any, enumId: string) => { + if(state.cached[enumId]?.enumTypeId === enumTypeId && !orderJobEnumIds.includes(enumId)) { + jobs.push(state.cached[enumId]) + } + return jobs + }, []) }, getPipelineFilters: (state) => { return state.pipelineFilters; diff --git a/src/store/modules/job/index.ts b/src/store/modules/job/index.ts index 7ac3b724..646642f0 100644 --- a/src/store/modules/job/index.ts +++ b/src/store/modules/job/index.ts @@ -25,16 +25,6 @@ const jobModule: Module = { list: [], total: 0 }, - more: { - pending: { - list: [], - total: 0 - }, - draft: { - list: [], - total: 0 - }, - }, temporalExp: [], enumIds: {}, current: {}, diff --git a/src/store/modules/job/mutation-types.ts b/src/store/modules/job/mutation-types.ts index 55e48757..dc22175f 100644 --- a/src/store/modules/job/mutation-types.ts +++ b/src/store/modules/job/mutation-types.ts @@ -8,6 +8,5 @@ export const JOB_HISTORY_UPDATED = SN_JOB + '/HISTORY_UPDATED' export const JOB_RUNNING_UPDATED = SN_JOB + '/RUNNING_UPDATED' export const JOB_CURRENT_UPDATED = SN_JOB + '/CURRENT_UPDATED' export const JOB_MISCELLANEOUS_UPDATED = SN_JOB + '/MISCELLANEOUS_UPDATED' -export const JOB_MORE_UPDATED = SN_JOB + '/MORE_UPDATED' export const JOB_PIPELINE_FILTERS_UPDATED = SN_JOB + '/PIPELINE_FILTERS_UPDATED' export const JOB_PIPELINE_FILTERS_CLEARED = SN_JOB + '/PIPELINE_FILTERS_CLEARED' diff --git a/src/store/modules/job/mutations.ts b/src/store/modules/job/mutations.ts index 83ab6eae..57bd6d47 100644 --- a/src/store/modules/job/mutations.ts +++ b/src/store/modules/job/mutations.ts @@ -45,12 +45,6 @@ const mutations: MutationTree = { state.miscellaneous.list = payload.jobs; state.miscellaneous.total = payload.total; }, - [types.JOB_MORE_UPDATED] (state, payload){ - state.more.pending.list = payload.pendingJobs; - state.more.pending.total = payload.pendingTotal; - state.more.draft.list = payload.draftJobs; - state.more.draft.total = payload.draftTotal; - }, [types.JOB_PIPELINE_FILTERS_UPDATED] (state, payload){ state.pipelineFilters = payload.pipelineFilters; }, diff --git a/src/views/Inventory.vue b/src/views/Inventory.vue index a860a526..b259e90a 100644 --- a/src/views/Inventory.vue +++ b/src/views/Inventory.vue @@ -33,7 +33,7 @@ - +