diff --git a/.env.example b/.env.example index bce60a96..02c8612c 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,5 @@ VUE_APP_BASE_URL= VUE_APP_VIEW_SIZE=10 VUE_APP_PERMISSION_ID="RECEIVING_APP_VIEW" VUE_APP_ALIAS={} -VUE_APP_PRDT_IDENT=["productId", "groupId", "groupName", "internalName", "parentProductName", "sku", "title", "SHOPIFY_PROD_SKU", "ERP_ID", "UPCA"] VUE_APP_DEFAULT_LOG_LEVEL="error" VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login" \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 901c6a04..2e26e718 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17613,4 +17613,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index c69c1636..63400353 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,7 +17,7 @@ import { mapGetters, useStore } from "vuex"; import { Settings } from 'luxon'; import { initialise, resetConfig } from '@/adapter' import { useRouter } from 'vue-router'; -import { translate } from "@hotwax/dxp-components" +import { translate , useProductIdentificationStore } from "@hotwax/dxp-components" export default defineComponent({ name: 'App', @@ -36,7 +36,6 @@ export default defineComponent({ computed: { ...mapGetters({ currentEComStore: 'user/getCurrentEComStore', - productIdentifications: 'util/getProductIdentifications', userProfile: 'user/getUserProfile', userToken: 'user/getUserToken', instanceUrl: 'user/getInstanceUrl' @@ -100,15 +99,13 @@ export default defineComponent({ emitter.on('presentLoader', this.presentLoader); emitter.on('dismissLoader', this.dismissLoader); }, - async mounted() { - if(this.productIdentifications.length <= 0) { - // TODO: fetch product identifications from enumeration instead of storing it in env - this.store.dispatch('util/setProductIdentifications', process.env.VUE_APP_PRDT_IDENT ? JSON.parse(process.env.VUE_APP_PRDT_IDENT) : []) + async mounted(){ + if(this.userToken) { + // Get product identification from api using dxp-component + await useProductIdentificationStore().getIdentificationPref(this.currentEComStore?.productStoreId) + .catch((error) => console.error(error)); } - if(this.userProfile) { - this.store.dispatch('user/getProductIdentificationPref', this.currentEComStore.productStoreId); - } // Handles case when user resumes or reloads the app // Luxon timezzone should be set with the user's selected timezone if (this.userProfile && this.userProfile.userTimeZone) { diff --git a/src/adapter/index.ts b/src/adapter/index.ts index 368ee94d..8482fae0 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -1,11 +1,12 @@ import { api, client, getConfig, getUserFacilities, hasError, initialise, logout, resetConfig, updateInstanceUrl, updateToken, setUserTimeZone, - getAvailableTimeZones } from '@hotwax/oms-api' + getAvailableTimeZones, getProductIdentificationPref, setProductIdentificationPref} from '@hotwax/oms-api' export { api, client, getConfig, getUserFacilities, + getProductIdentificationPref, hasError, initialise, logout, @@ -13,5 +14,6 @@ export { updateInstanceUrl, updateToken, setUserTimeZone, + setProductIdentificationPref, getAvailableTimeZones } \ No newline at end of file diff --git a/src/components/ClosePurchaseOrderModal.vue b/src/components/ClosePurchaseOrderModal.vue index 5f47cd1e..5424a71a 100644 --- a/src/components/ClosePurchaseOrderModal.vue +++ b/src/components/ClosePurchaseOrderModal.vue @@ -62,10 +62,10 @@ import { } from '@ionic/vue'; import { Actions, hasPermission } from '@/authorization' import { closeOutline, checkmarkCircle, arrowBackOutline, saveOutline } from 'ionicons/icons'; -import { defineComponent } from 'vue'; +import { defineComponent, computed } from 'vue'; import { mapGetters, useStore } from 'vuex' import { OrderService } from "@/services/OrderService"; -import { DxpShopifyImg, translate, getProductIdentificationValue } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; import { useRouter } from 'vue-router'; export default defineComponent({ @@ -93,7 +93,6 @@ export default defineComponent({ getProduct: 'product/getProduct', getPOItemAccepted: 'order/getPOItemAccepted', order: 'order/getCurrent', - productIdentificationPref: 'user/getProductIdentificationPref', purchaseOrders: 'order/getPurchaseOrders' }) }, @@ -206,6 +205,8 @@ export default defineComponent({ setup() { const router = useRouter() const store = useStore() + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) return { arrowBackOutline, @@ -218,7 +219,8 @@ export default defineComponent({ saveOutline, store, translate, - getProductIdentificationValue + getProductIdentificationValue, + productIdentificationPref }; } }); diff --git a/src/locales/en.json b/src/locales/en.json index 0133169a..8d36c657 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -32,7 +32,6 @@ "Failed to receive shipment": "Failed to receive shipment", "Failed to receive some of the items": "Failed to receive some of the items", "Failed to update force scan preference.": "Failed to update force scan preference.", - "Failed to update product identifier preference": "Failed to update product identifier preference", "facility location": "facility location", "Facility locations were not found corresponding to destination facility of return shipment. Please add facility locations to avoid receive return shipment failure.": "Facility locations were not found corresponding to destination facility of return shipment. Please add facility locations to avoid receive return shipment failure.", "Failed to update barcode identification preference.": "Failed to update barcode identification preference.", @@ -73,9 +72,9 @@ "primary identifier": "primary identifier", "Primary identifier": "Primary identifier", "Primary Product Identifier": "Primary Product Identifier", + "Primary": "Primary", "Proceed": "Proceed", "Product Identifier": "Product Identifier", - "Product identifier preference updated": "Product identifier preference updated", "Product is already received:": "Product is already received: {itemName}", "Purchase Order": "Purchase Order", "Purchase Order Details": "Purchase Order Details", @@ -111,6 +110,7 @@ "Search returns": "Search returns", "Search time zones": "Search time zones", "Search SKU or product name": "Search SKU or product name", + "Secondary": "Secondary", "Secondary Product Identifier": "Secondary Product Identifier", "Select": "Select", "Select all": "Select all", diff --git a/src/main.ts b/src/main.ts index 36cd1c36..b26f9a42 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,7 +32,7 @@ import permissionRules from '@/authorization/Rules'; import permissionActions from '@/authorization/Actions'; import { dxpComponents } from '@hotwax/dxp-components' import { login, logout, loader } from './user-utils'; -import { getConfig, initialise, setUserTimeZone, getAvailableTimeZones } from '@/adapter' +import { getConfig, initialise, setUserTimeZone, getAvailableTimeZones, getProductIdentificationPref, setProductIdentificationPref } from '@/adapter' import localeMessages from './locales'; const app = createApp(App) @@ -53,9 +53,11 @@ const app = createApp(App) loader, appLoginUrl: process.env.VUE_APP_LOGIN_URL as string, getConfig, + getProductIdentificationPref, initialise, localeMessages, setUserTimeZone, + setProductIdentificationPref, getAvailableTimeZones }); diff --git a/src/services/UserService.ts b/src/services/UserService.ts index ef103910..e67a1504 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -96,31 +96,6 @@ const setUserPreference = async (payload: any): Promise => { }); } -const updateProductIdentificationPref = async (payload: any): Promise => { - return api({ - url: "service/updateProductStoreSetting", - method: "post", - data: payload - }); -} - -const createProductIdentificationPref = async (payload: any): Promise => { - return api({ - url: "service/createProductStoreSetting", - method: "post", - data: payload - }); -} - -const getProductIdentificationPref = async (payload: any): Promise => { - return api({ - url: "performFind", - //TODO Due to security reasons service model OMS 1.0 does not support sending parameters in get request that's why we use post here - method: "post", - data: payload, - cache: true - }); -} const getUserPermissions = async (payload: any, token: any): Promise => { const baseURL = store.getters['user/getBaseUrl']; @@ -217,9 +192,6 @@ export const UserService = { getUserPermissions, getFacilityLocations, getEComStores, - getProductIdentificationPref, - createProductIdentificationPref, - updateProductIdentificationPref, setUserPreference, checkPermission } \ No newline at end of file diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index 05dae63f..cb10271c 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -5,7 +5,6 @@ export default interface UserState { currentEComStore: object; instanceUrl: string; facilityLocationsByFacilityId: any; - productIdentificationPref: any; permissions: any; pwaState: any; } \ No newline at end of file diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 3f6f5ea5..1faa9f19 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -12,7 +12,7 @@ import { resetPermissions, setPermissions } from '@/authorization' -import { translate, useAuthStore } from '@hotwax/dxp-components' +import { translate, useAuthStore, useProductIdentificationStore } from '@hotwax/dxp-components' import emitter from '@/event-bus' import store from '@/store' @@ -74,6 +74,11 @@ const actions: ActionTree = { const currentFacility = userProfile.facilities[0]; const currentEComStore = await UserService.getEComStores(token, currentFacility.facilityId); + const productStoreId = currentEComStore?.productStoreId; + + await useProductIdentificationStore().getIdentificationPref(productStoreId) + .catch((error) => console.error(error)); + setPermissions(appPermissions); if (userProfile.userTimeZone) { Settings.defaultZone = userProfile.userTimeZone; @@ -89,8 +94,6 @@ const actions: ActionTree = { // Get facility location of selected facility dispatch('getFacilityLocations', currentFacility.facilityId); // TODO: fetch product identifications from enumeration instead of storing it in env - this.dispatch('util/setProductIdentifications', process.env.VUE_APP_PRDT_IDENT ? JSON.parse(process.env.VUE_APP_PRDT_IDENT) : []) - dispatch('getProductIdentificationPref', currentEComStore?.productStoreId); this.dispatch('util/getForceScanSetting', currentEComStore?.productStoreId); this.dispatch('util/getBarcodeIdentificationPref', currentEComStore?.productStoreId); } catch (err: any) { @@ -135,7 +138,6 @@ const actions: ActionTree = { // TODO add any other tasks if need commit(types.USER_END_SESSION) - this.dispatch('util/setProductIdentifications', []) this.dispatch('order/clearPurchaseOrders'); this.dispatch('util/updateForceScanStatus', false) this.dispatch('util/updateBarcodeIdentificationPref', "") @@ -163,7 +165,7 @@ const actions: ActionTree = { 'userPrefTypeId': 'SELECTED_BRAND', 'userPrefValue': payload.eComStore.productStoreId }); - await dispatch('getProductIdentificationPref', payload.eComStore.productStoreId); + await useProductIdentificationStore().getIdentificationPref(payload.eComStore.productStoreId); this.dispatch('util/getForceScanSetting', payload.ecomStore.productStoreId) this.dispatch('util/getBarcodeIdentificationPref', payload.ecomStore.productStoreId) }, @@ -235,119 +237,6 @@ const actions: ActionTree = { return []; } }, - - async setProductIdentificationPref({ commit, state }, payload) { - let prefValue = JSON.parse(JSON.stringify(state.productIdentificationPref)) - const eComStoreId = (state.currentEComStore as any).productStoreId - - let fromDate; - - try { - const resp = await UserService.getProductIdentificationPref({ - "inputFields": { - "productStoreId": eComStoreId, - "settingTypeEnumId": "PRDT_IDEN_PREF" - }, - "filterByDate": 'Y', - "entityName": "ProductStoreSetting", - "fieldList": ["fromDate"], - "viewSize": 1 - }) as any - if(resp.status == 200 && resp.data.count > 0) { - fromDate = resp.data.docs[0].fromDate - } - } catch(err) { - console.error(err) - } - - // when selecting none as ecom store, not updating the pref as it's not possible to save pref with empty productStoreId - if(!(state.currentEComStore as any).productStoreId || !fromDate) { - showToast(translate('Unable to update product identifier preference')) - commit(types.USER_PREF_PRODUCT_IDENT_CHANGED, prefValue) - return; - } - - prefValue[payload.id] = payload.value - - const params = { - "fromDate": fromDate, - "productStoreId": eComStoreId, - "settingTypeEnumId": "PRDT_IDEN_PREF", - "settingValue": JSON.stringify(prefValue) - } - - try { - const resp = await UserService.updateProductIdentificationPref(params) as any - - if(resp.status == 200) { - showToast(translate('Product identifier preference updated')) - } else { - showToast(translate('Failed to update product identifier preference')) - prefValue = JSON.parse(JSON.stringify(state.productIdentificationPref)) - } - } catch(err) { - showToast(translate('Failed to update product identifier preference')) - prefValue = JSON.parse(JSON.stringify(state.productIdentificationPref)) - console.error(err) - } - commit(types.USER_PREF_PRODUCT_IDENT_CHANGED, prefValue) - }, - - async createProductIdentificationPref({ commit, state }) { - const prefValue = { - primaryId: 'productId', - secondaryId: '' - } - - const params = { - "fromDate": Date.now(), - "productStoreId": (state.currentEComStore as any).productStoreId, - "settingTypeEnumId": "PRDT_IDEN_PREF", - "settingValue": JSON.stringify(prefValue) - } - - try { - await UserService.createProductIdentificationPref(params) as any - } catch(err) { - console.error(err) - } - - // not checking for resp success and fail case as every time we need to update the state with the - // default value when creating a pref - commit(types.USER_PREF_PRODUCT_IDENT_CHANGED, prefValue) - }, - - async getProductIdentificationPref({ commit, dispatch }, eComStoreId) { - - // when selecting none as ecom store, not fetching the pref as it returns all the entries with the pref id - if(!eComStoreId) { - commit(types.USER_PREF_PRODUCT_IDENT_CHANGED, {'primaryId': 'productId', 'secondaryId': ''}) - return; - } - - const payload = { - "inputFields": { - "productStoreId": eComStoreId, - "settingTypeEnumId": "PRDT_IDEN_PREF" - }, - "filterByDate": 'Y', - "entityName": "ProductStoreSetting", - "fieldList": ["settingValue", "fromDate"], - "viewSize": 1 - } - - try { - const resp = await UserService.getProductIdentificationPref(payload) as any - if(resp.status == 200 && resp.data.count > 0) { - const respValue = JSON.parse(resp.data.docs[0].settingValue) - commit(types.USER_PREF_PRODUCT_IDENT_CHANGED, {'primaryId': respValue['primaryId'], 'secondaryId': respValue['secondaryId']}) - } else if(resp.status == 200 && resp.data.error) { - dispatch('createProductIdentificationPref') - } - } catch(err) { - console.error(err) - } - }, updatePwaState({ commit }, payload) { commit(types.USER_PWA_STATE_UPDATED, payload); diff --git a/src/store/modules/user/getters.ts b/src/store/modules/user/getters.ts index 79aa853b..7a584b2b 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -36,9 +36,6 @@ const getters: GetterTree = { getFacilityLocationsByFacilityId: (state) => (facilityId: string) => { return state.facilityLocationsByFacilityId[facilityId]; }, - getProductIdentificationPref: (state) => { - return state.productIdentificationPref; - }, getPwaState(state) { return state.pwaState; } diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index b2ac1a25..c66cd8e1 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -15,10 +15,6 @@ const userModule: Module = { permissions: [], instanceUrl: '', facilityLocationsByFacilityId: {}, - productIdentificationPref: { - primaryId: 'productId', - secondaryId: '' - }, pwaState: { updateExists: false, registration: null, diff --git a/src/store/modules/user/mutation-types.ts b/src/store/modules/user/mutation-types.ts index 34385352..f8fe7be5 100644 --- a/src/store/modules/user/mutation-types.ts +++ b/src/store/modules/user/mutation-types.ts @@ -6,6 +6,5 @@ export const USER_CURRENT_FACILITY_UPDATED = SN_USER + '/CURRENT_FACILITY_UPDATE export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED' export const USER_CURRENT_ECOM_STORE_UPDATED = SN_USER + '/CURRENT_ECOM_STORE_UPDATED' export const USER_FACILITY_LOCATIONS_BY_FACILITY_ID = SN_USER + '/FACILITY_LOCATIONS_BY_FACILITY_ID' -export const USER_PREF_PRODUCT_IDENT_CHANGED = SN_USER + '/PREF_PRODUCT_IDENT_CHANGED' export const USER_PERMISSIONS_UPDATED = SN_USER + '/PERMISSIONS_UPDATED' export const USER_PWA_STATE_UPDATED = SN_USER + '/PWA_STATE_UPDATED' \ No newline at end of file diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index 206a09ef..df65bfb1 100644 --- a/src/store/modules/user/mutations.ts +++ b/src/store/modules/user/mutations.ts @@ -28,9 +28,6 @@ const mutations: MutationTree = { [types.USER_FACILITY_LOCATIONS_BY_FACILITY_ID] (state, payload) { state.facilityLocationsByFacilityId[payload.facilityId] = payload.facilityLocations; }, - [types.USER_PREF_PRODUCT_IDENT_CHANGED](state, payload) { - state.productIdentificationPref = payload - }, [types.USER_PERMISSIONS_UPDATED] (state, payload) { state.permissions = payload }, diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index 3966daf5..23cb54c5 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -1,6 +1,5 @@ export default interface UtilState { status: any; - productIdentifications: Array; isForceScanEnabled: boolean; barcodeIdentificationPref: any; } \ No newline at end of file diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 4ab98e13..1f5ed247 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -47,9 +47,6 @@ const actions: ActionTree = { } return cachedStatus; }, - async setProductIdentifications({ commit }, payload) { - commit(types.UTIL_PRODUCT_IDENT_UPDATED, payload) - }, async getForceScanSetting({ commit, dispatch }, eComStoreId) { const payload = { diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index 2c308a40..39723a4e 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -1,14 +1,16 @@ import { GetterTree } from 'vuex' import RootState from '@/store/RootState' import UtilState from './UtilState'; +import { computed } from 'vue'; +import { useProductIdentificationStore } from '@hotwax/dxp-components'; + + + const getters: GetterTree = { getStatusDesc: (state) => (statusId: string) => { return state.status[statusId] }, - getProductIdentifications: (state) => { - return state.productIdentifications - }, isForceScanEnabled(state) { return state.isForceScanEnabled }, @@ -16,7 +18,9 @@ const getters: GetterTree = { return state.barcodeIdentificationPref }, getBarcodeIdentificationValue(state, getters, rootState, rootGetters) { - return rootGetters['user/getProductIdentificationPref'][state.barcodeIdentificationPref] + const productIdentificationStore = useProductIdentificationStore(); + const productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) as any; + return productIdentificationPref.value[state.barcodeIdentificationPref] } } 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 3afbf758..680e6368 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -9,7 +9,6 @@ const utilModule: Module = { namespaced: true, state: { status: {}, - productIdentifications: [], isForceScanEnabled: false, barcodeIdentificationPref: "" }, diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index f85b5304..9c7c02ec 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -1,5 +1,4 @@ export const SN_UTIL = 'util' export const UTIL_STATUS_UPDATED = SN_UTIL + '/STATUS_UPDATED' -export const UTIL_PRODUCT_IDENT_UPDATED = SN_UTIL + '/PRODUCT_IDENT_UPDATED' export const UTIL_FORCE_SCAN_STATUS_UPDATED = SN_UTIL + '/FORCE_SCAN_STATUS_UPDATED' export const UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED = SN_UTIL + '/BARCODE_IDENTIFICATION_PREF_UPDATED' diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index f1971c1e..46e4f55a 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -6,9 +6,6 @@ const mutations: MutationTree = { [types.UTIL_STATUS_UPDATED](state, payload) { state.status = payload }, - [types.UTIL_PRODUCT_IDENT_UPDATED](state, payload) { - state.productIdentifications = payload - }, [types.UTIL_FORCE_SCAN_STATUS_UPDATED](state, payload) { state.isForceScanEnabled = payload }, diff --git a/src/views/AddProductModal.vue b/src/views/AddProductModal.vue index 08abfaa0..ffff1eff 100644 --- a/src/views/AddProductModal.vue +++ b/src/views/AddProductModal.vue @@ -65,11 +65,11 @@ import { IonToolbar, modalController, } from '@ionic/vue'; -import { defineComponent } from 'vue'; +import { defineComponent, computed } from 'vue'; import { closeOutline, checkmarkCircle } from 'ionicons/icons'; import { mapGetters } from 'vuex' import { useStore } from "@/store"; -import { DxpShopifyImg, translate, getProductIdentificationValue } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; import { showToast } from '@/utils' export default defineComponent({ @@ -104,7 +104,6 @@ export default defineComponent({ getProduct: 'product/getProduct', isScrollable: 'product/isScrollable', isProductAvailableInShipment: 'product/isProductAvailableInShipment', - productIdentificationPref: 'user/getProductIdentificationPref', currentFacility: 'user/getCurrentFacility', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId' }) @@ -169,12 +168,16 @@ export default defineComponent({ }, setup() { const store = useStore(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + return { closeOutline, checkmarkCircle, store, translate, - getProductIdentificationValue + getProductIdentificationValue, + productIdentificationPref }; }, }); diff --git a/src/views/AddProductToPOModal.vue b/src/views/AddProductToPOModal.vue index 9a3f1911..a45a0065 100644 --- a/src/views/AddProductToPOModal.vue +++ b/src/views/AddProductToPOModal.vue @@ -56,11 +56,11 @@ import { IonToolbar, modalController, } from '@ionic/vue'; -import { defineComponent } from 'vue'; +import { defineComponent, computed } from 'vue'; import { closeOutline, checkmarkCircle } from 'ionicons/icons'; import { mapGetters } from 'vuex' import { useStore } from "@/store"; -import { DxpShopifyImg, translate, getProductIdentificationValue } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; import { showToast } from '@/utils' export default defineComponent({ @@ -95,7 +95,6 @@ export default defineComponent({ getProduct: 'product/getProduct', isScrollable: 'product/isScrollable', isProductAvailableInOrder: 'order/isProductAvailableInOrder', - productIdentificationPref: 'user/getProductIdentificationPref', currentFacility: 'user/getCurrentFacility', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId' }) @@ -160,12 +159,15 @@ export default defineComponent({ }, setup() { const store = useStore(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref); return { closeOutline, checkmarkCircle, store, translate, getProductIdentificationValue, + productIdentificationPref }; }, }); diff --git a/src/views/PurchaseOrderDetail.vue b/src/views/PurchaseOrderDetail.vue index ab183b3a..c55fc3cf 100644 --- a/src/views/PurchaseOrderDetail.vue +++ b/src/views/PurchaseOrderDetail.vue @@ -177,10 +177,10 @@ import { alertController, modalController } from '@ionic/vue'; -import { defineComponent } from 'vue'; +import { defineComponent, computed } from 'vue'; import { addOutline, cameraOutline, checkmarkDone, copyOutline, eyeOffOutline, eyeOutline, locationOutline, saveOutline, timeOutline } from 'ionicons/icons'; import ReceivingHistoryModal from '@/views/ReceivingHistoryModal.vue' -import { DxpShopifyImg, translate, getProductIdentificationValue } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; import { useStore, mapGetters } from 'vuex'; import { useRouter } from 'vue-router'; import Scanner from "@/components/Scanner.vue" @@ -230,7 +230,6 @@ export default defineComponent({ getPOItemAccepted: 'order/getPOItemAccepted', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId', currentFacility: 'user/getCurrentFacility', - productIdentificationPref: 'user/getProductIdentificationPref', isForceScanEnabled: 'util/isForceScanEnabled', }) }, @@ -389,6 +388,8 @@ export default defineComponent({ setup() { const store = useStore(); const router = useRouter(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref); return { Actions, @@ -406,7 +407,8 @@ export default defineComponent({ store, timeOutline, translate, - getProductIdentificationValue + getProductIdentificationValue, + productIdentificationPref, }; }, }); diff --git a/src/views/ReturnDetails.vue b/src/views/ReturnDetails.vue index 3b73015d..52508f0e 100644 --- a/src/views/ReturnDetails.vue +++ b/src/views/ReturnDetails.vue @@ -106,11 +106,11 @@ import { modalController, alertController, } from '@ionic/vue'; -import { defineComponent } from 'vue'; +import { defineComponent, computed } from 'vue'; import { checkmarkDone, barcodeOutline, locationOutline } from 'ionicons/icons'; import { mapGetters, useStore } from "vuex"; import AddProductModal from '@/views/AddProductModal.vue' -import { DxpShopifyImg, translate, getProductIdentificationValue } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; import { useRouter } from 'vue-router'; import Scanner from "@/components/Scanner.vue"; import ImageModal from '@/components/ImageModal.vue'; @@ -171,7 +171,6 @@ export default defineComponent({ returns: 'return/getReturns', validStatusChange: 'return/isReturnReceivable', isReturnReceivable: 'return/isReturnReceivable', - productIdentificationPref: 'user/getProductIdentificationPref', isForceScanEnabled: 'util/isForceScanEnabled', }), }, @@ -285,6 +284,8 @@ export default defineComponent({ setup() { const store = useStore(); const router = useRouter(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) return { Actions, @@ -295,7 +296,8 @@ export default defineComponent({ store, router, translate, - getProductIdentificationValue + getProductIdentificationValue, + productIdentificationPref }; }, }); diff --git a/src/views/Settings.vue b/src/views/Settings.vue index e4ed01f6..87dbb0c5 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -59,29 +59,7 @@
- - - - {{ translate('Product Identifier') }} - - - - - {{ translate('Choosing a product identifier allows you to view products with your preferred identifiers.') }} - - - - - {{ identification }} - - - - - {{ identification }} - {{ translate("None") }} - - - + @@ -115,7 +93,7 @@ import { useRouter } from 'vue-router'; import Image from '@/components/Image.vue' import { DateTime } from 'luxon'; import { Actions, hasPermission } from '@/authorization'; -import { translate } from "@hotwax/dxp-components" +import { DxpProductIdentifier, translate } from "@hotwax/dxp-components" export default defineComponent({ name: 'Settings', @@ -154,8 +132,6 @@ export default defineComponent({ userProfile: 'user/getUserProfile', currentFacility: 'user/getCurrentFacility', currentEComStore: 'user/getCurrentEComStore', - productIdentifications: 'util/getProductIdentifications', - productIdentificationPref: 'user/getProductIdentificationPref', isForceScanEnabled: 'util/isForceScanEnabled', barcodeIdentificationPref: 'util/getBarcodeIdentificationPref' }) @@ -218,13 +194,6 @@ export default defineComponent({ goToLaunchpad() { window.location.href = `${process.env.VUE_APP_LOGIN_URL}` }, - setProductIdentificationPref(value: string, id: string) { - // Not dispatching an action if the value for id is same as saved in state - if(this.productIdentificationPref[id] == value) { - return; - } - this.store.dispatch('user/setProductIdentificationPref', { id, value }) - }, setBarcodeIdentificationPref(value: string) { this.store.dispatch('util/setBarcodeIdentificationPref', value) }, diff --git a/src/views/ShipmentDetails.vue b/src/views/ShipmentDetails.vue index 4087256d..2497d3ba 100644 --- a/src/views/ShipmentDetails.vue +++ b/src/views/ShipmentDetails.vue @@ -112,11 +112,11 @@ import { modalController, alertController, } from '@ionic/vue'; -import { defineComponent } from 'vue'; +import { defineComponent, computed } from 'vue'; import { add, checkmarkDone, cameraOutline, locationOutline } from 'ionicons/icons'; import { mapGetters, useStore } from "vuex"; import AddProductModal from '@/views/AddProductModal.vue' -import { DxpShopifyImg, translate, getProductIdentificationValue } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; import { useRouter } from 'vue-router'; import Scanner from "@/components/Scanner.vue"; import LocationPopover from '@/components/LocationPopover.vue' @@ -166,7 +166,6 @@ export default defineComponent({ getProduct: 'product/getProduct', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId', currentFacility: 'user/getCurrentFacility', - productIdentificationPref: 'user/getProductIdentificationPref', isForceScanEnabled: 'util/isForceScanEnabled', }), }, @@ -303,6 +302,8 @@ export default defineComponent({ setup() { const store = useStore(); const router = useRouter(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) return { Actions, @@ -314,7 +315,8 @@ export default defineComponent({ store, router, translate, - getProductIdentificationValue + getProductIdentificationValue, + productIdentificationPref }; }, });