diff --git a/src/locales/en.json b/src/locales/en.json index e713629a..c9315ea0 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -10,6 +10,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.", "Cancel job": "Cancel job", "Change": "Change", + "Channels": "Channels", "Check products": "Check products", "Clear All": "Clear All", "Click the backdrop to dismiss.": "Click the backdrop to dismiss.", diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index ab2a4278..9cd4f276 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -25,8 +25,18 @@ const fetchFacilitiesByProductStore = async (payload: any): Promise => { }); } + +const fetchChannels = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "POST", + data: payload + }) +} + export const UtilService = { fetchFacilitiesByProductStore, getServiceStatusDesc, - getShopifyConfig + getShopifyConfig, + fetchChannels } \ No newline at end of file diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index c0e779ed..bdc6415f 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -2,4 +2,5 @@ export default interface UtilState { statusDesc: any; shopifyConfig: any; facilitiesByProductStore: any; + channels: []; } \ No newline at end of file diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 8520d2a6..04d0b31e 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -81,6 +81,32 @@ const actions: ActionTree = { } return {}; }, + + async fetchChannels({ commit }) { + let channels = [] + const params = { + entityName: "FacilityGroup", + inputFields: { + facilityGroupTypeId: 'CHANNEL_FAC_GROUP' + }, + noConditionFind: 'Y', + orderBy: "facilityGroupName ASC", + fieldList: ["facilityGroupId", "facilityGroupTypeId", "facilityGroupName", "description"], + viewSize: 50 + } + + try { + const resp = await UtilService.fetchChannels(params) + if (!hasError(resp)) { + channels = resp.data.docs + } else { + throw resp.data + } + } catch (error) { + logger.error(error) + } + commit(types.UTIL_CHANNELS_UPDATED, channels) + }, async clearFacilitiesByProductStore({ commit }) { commit(types.UTIL_PRODUCT_STORE_FACILITY_UPDATED, {}) diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index f60b69dc..46ed083d 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -11,6 +11,9 @@ const getters: GetterTree = { }, getFacilityByProductStore(state) { return state.facilitiesByProductStore + }, + getChannels(state) { + return state.channels; } } export default getters; \ No newline at end of file diff --git a/src/store/modules/util/index.ts b/src/store/modules/util/index.ts index fb38d657..0846d1ec 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -10,7 +10,8 @@ const utilModule: Module = { state: { statusDesc: {}, shopifyConfig: {}, - facilitiesByProductStore: {} + facilitiesByProductStore: {}, + channels: [] }, getters, actions, diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index 160c6759..a7dc3abd 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -1,4 +1,5 @@ export const SN_UTIL = 'util' export const UTIL_SERVICE_STATUS_DESC_UPDATED = SN_UTIL + '/SERVICE_STATUS_DESC_UPDATED' export const UTIL_SHOPIFY_CONFIG_UPDATED = SN_UTIL + '/SHOPIFY_CONFIG_UPDATED' -export const UTIL_PRODUCT_STORE_FACILITY_UPDATED = SN_UTIL + '/PRODUCT_STORE_FACILITY_UPDATED' \ No newline at end of file +export const UTIL_PRODUCT_STORE_FACILITY_UPDATED = SN_UTIL + '/PRODUCT_STORE_FACILITY_UPDATED' +export const UTIL_CHANNELS_UPDATED = SN_UTIL + '/CHANNELS_UPDATED' diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index 54c80f30..0e0ad324 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -13,6 +13,9 @@ const mutations: MutationTree = { }, [types.UTIL_PRODUCT_STORE_FACILITY_UPDATED] (state, payload) { state.facilitiesByProductStore = payload + }, + [types.UTIL_CHANNELS_UPDATED](state, payload) { + state.channels = payload } } export default mutations; \ No newline at end of file diff --git a/src/views/ScheduleThreshold.vue b/src/views/ScheduleThreshold.vue index 8bfe4e76..0dde40fb 100644 --- a/src/views/ScheduleThreshold.vue +++ b/src/views/ScheduleThreshold.vue @@ -20,7 +20,13 @@ {{ threshold }} {{ $t('threshold') }} - + + {{ $t('Channels') }} + + + {{ channel?.facilityGroupName }} + + {{ $t("Name") }} @@ -115,6 +121,7 @@ import { IonIcon, IonInput, IonItem, + IonItemDivider, IonLabel, IonList, IonListHeader, @@ -123,6 +130,7 @@ import { IonReorder, IonReorderGroup, IonTitle, + IonToggle, IonToolbar } from '@ionic/vue'; import { defineComponent } from 'vue'; @@ -153,6 +161,7 @@ export default defineComponent({ IonIcon, IonInput, IonItem, + IonItemDivider, IonLabel, IonList, IonListHeader, @@ -161,6 +170,7 @@ export default defineComponent({ IonReorder, IonReorderGroup, IonTitle, + IonToggle, IonToolbar }, data() { @@ -175,13 +185,15 @@ export default defineComponent({ failedJobs: [] as any, successJobs: [] as any, job: {} as any, - isOpen: false + isOpen: false, + selectedChannels: [] as any } }, computed: { ...mapGetters({ currentEComStore: 'user/getCurrentEComStore', shopifyConfig: 'util/getShopifyConfig', + channels: 'util/getChannels', facilitiesByProductStore: 'util/getFacilityByProductStore', query: 'product/getQuery', temporalExpr: 'job/getTemporalExpr', @@ -399,7 +411,9 @@ export default defineComponent({ const resp = await this.store.dispatch('util/fetchFacilitiesByProductStore', { inputFields: { productStoreId, - facilityTypeId: 'CONFIGURATION' + facilityTypeId: 'CONFIGURATION', + facilityGroupId: this.selectedChannels, + facilityGroupId_op: 'in' }, entityName: 'ProductStoreFacilityDetail', fieldList: ['facilityId', 'productStoreId'], @@ -559,6 +573,23 @@ export default defineComponent({ } emitter.emit('dismissLoader'); + }, + updateChannels(event: CustomEvent, facilityGroupId: string) { + if (event.detail.checked && this.selectedChannels?.some((channel: any) => channel === facilityGroupId)) { + return; + } + + if (this.selectedChannels?.some((channel:any) => channel === facilityGroupId)) { + this.selectedChannels.splice(this.selectedChannels?.indexOf(facilityGroupId), 1); + } else { + this.selectedChannels.push(facilityGroupId); + } + }, + isChannelChecked(facilityGroupId: string) { + return this.selectedChannels?.some((channel: any) => channel === facilityGroupId) + }, + isChannelDisabled(facilityGroupId: string) { + return this.selectedChannels?.length == 1 && this.selectedChannels?.some((channel: any) => channel === facilityGroupId) } }, async ionViewWillEnter() { @@ -597,6 +628,10 @@ export default defineComponent({ // maintaining the initial order of jobs to take the diff from the updated seq after reordering this.initialJobsOrder = JSON.parse(JSON.stringify(this.jobsForReorder)) this.updatedJobsOrder = [ newJob ] + + //fetch channels and preselect all + await this.store.dispatch('util/fetchChannels') + this.selectedChannels = this.channels.map((channel: any) => channel.facilityGroupId) }, ionViewDidLeave() { // TODO: remove this initialization from the hook and update the code accordingly