diff --git a/package-lock.json b/package-lock.json index 82ef4150..d22a1002 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@casl/ability": "^6.0.0", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.2.6", - "@hotwax/dxp-components": "^1.15.5", + "@hotwax/dxp-components": "^1.16.0", "@hotwax/oms-api": "^1.16.0", "@ionic/core": "^7.6.0", "@ionic/vue": "^7.6.0", @@ -2792,9 +2792,9 @@ "integrity": "sha512-zpUjGoY7LBlKeiP0V7tonrmoey8HQ5THQmyixQ+IDtrjmEJNBjynW/Ef3gC0FUNNPuVqxWPZdT5CVgaETLGTwg==" }, "node_modules/@hotwax/dxp-components": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.15.5.tgz", - "integrity": "sha512-aOzipZwVk/fL6K7/BShsvE3eYqH8LagEQQpaNCPFtSs18KHgolGQxcKT3dQ1KRLTCmoKJugc7ut9uyxZVL5krg==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.16.0.tgz", + "integrity": "sha512-9HUrR58Sk9H3wryYGWfGfctcM9hRqq9pnLbaShnNf0mZeK/vTAIqqTPHcObfeKXkSaPtrqS6E/1Y/+Ysmv6v5A==", "dependencies": { "@hotwax/oms-api": "^1.8.1", "@ionic/core": "^7.6.0", diff --git a/package.json b/package.json index d82ed320..ed97400a 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@casl/ability": "^6.0.0", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.2.6", - "@hotwax/dxp-components": "^1.15.5", + "@hotwax/dxp-components": "^1.16.0", "@hotwax/oms-api": "^1.16.0", "@ionic/core": "^7.6.0", "@ionic/vue": "^7.6.0", diff --git a/src/adapter/index.ts b/src/adapter/index.ts index 84c6e5c6..43466c72 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -1,5 +1,5 @@ -import { api, client, getConfig, fetchGoodIdentificationTypes, getUserFacilities, hasError, initialise, logout, resetConfig, updateInstanceUrl, updateToken, setUserTimeZone, - getAvailableTimeZones, getProductIdentificationPref, setProductIdentificationPref} from '@hotwax/oms-api' +import { api, client, getConfig, fetchGoodIdentificationTypes, getUserFacilities, getUserPreference, hasError, initialise, logout, resetConfig, updateInstanceUrl, updateToken, setUserTimeZone, + getAvailableTimeZones, getProductIdentificationPref, setProductIdentificationPref, setUserPreference} from '@hotwax/oms-api' export { api, @@ -8,6 +8,7 @@ export { getConfig, getUserFacilities, getProductIdentificationPref, + getUserPreference, hasError, initialise, logout, @@ -16,5 +17,6 @@ export { updateToken, setUserTimeZone, setProductIdentificationPref, + setUserPreference, getAvailableTimeZones } \ No newline at end of file diff --git a/src/components/Menu.vue b/src/components/Menu.vue index f188d99e..308fbf22 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -36,6 +36,7 @@ import { computed, defineComponent } from "vue"; import { mapGetters } from "vuex"; import { calendar, download, gitPullRequestOutline, settings } from "ionicons/icons"; import { useStore } from "@/store"; +import { useUserStore } from "@hotwax/dxp-components" import { useRouter } from "vue-router"; export default defineComponent({ @@ -55,12 +56,14 @@ export default defineComponent({ computed: { ...mapGetters({ isUserAuthenticated: 'user/isUserAuthenticated', - currentFacility: 'user/getCurrentFacility', }) }, setup() { const store = useStore(); const router = useRouter(); + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) + const appPages = [ { title: "Shipments", @@ -97,6 +100,7 @@ export default defineComponent({ }) return { + currentFacility, selectedIndex, appPages, download, diff --git a/src/locales/en.json b/src/locales/en.json index 06344236..ad24d036 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -35,6 +35,7 @@ "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.", + "Fetching facilities": "Fetching facilities", "Fetching time zones": "Fetching time zones", "Force scan": "Force scan", "Force scan preference updated successfully.": "Force scan preference updated successfully.", @@ -56,6 +57,7 @@ "Logging out": "Logging out", "Logout": "Logout", "Make sure you have entered all the inventory you received. You cannot edit this information after proceeding.": "Make sure you have entered all the inventory you received. { space } You cannot edit this information after proceeding.", + "No facilities found": "No facilities found", "No more shipments found": "No more shipments found", "None": "None", "No results found": "No results found", @@ -111,6 +113,7 @@ "Searched item is not present within the shipment:": "Searched item is not present within the shipment: {itemName}", "secondary identifier": "secondary identifier", "Search": "Search", + "Search facilities": "Search facilities", "Search purchase orders": "Search purchase orders", "Search returns": "Search returns", "Search time zones": "Search time zones", @@ -120,6 +123,7 @@ "Select": "Select", "Select all": "Select all", "Select facility": "Select facility", + "Select Facility": "Select Facility", "Selected TimeZone": "Selected TimeZone", "Select a different time zone": "Select a different time zone", "Select time zone": "Select time zone", diff --git a/src/main.ts b/src/main.ts index a14a331d..cc10d276 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 { fetchGoodIdentificationTypes, getConfig, initialise, setUserTimeZone, getAvailableTimeZones, getProductIdentificationPref, setProductIdentificationPref } from '@/adapter' +import { fetchGoodIdentificationTypes, getConfig, initialise, setUserTimeZone, getAvailableTimeZones, getProductIdentificationPref, getUserFacilities, getUserPreference, setProductIdentificationPref, setUserPreference } from '@/adapter' import localeMessages from './locales'; const app = createApp(App) @@ -61,7 +61,10 @@ const app = createApp(App) setProductIdentificationPref, getAvailableTimeZones, hasPermission, - fetchGoodIdentificationTypes + fetchGoodIdentificationTypes, + getUserPreference, + getUserFacilities, + setUserPreference }); // Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters diff --git a/src/services/ProductService.ts b/src/services/ProductService.ts index 160f6616..bb73840a 100644 --- a/src/services/ProductService.ts +++ b/src/services/ProductService.ts @@ -1,5 +1,5 @@ import { api, hasError } from '@/adapter'; -import store from '@/store'; +import { getCurrentFacilityId } from '@/utils'; const fetchProducts = async (query: any): Promise => { return api({ @@ -14,7 +14,7 @@ const getInventoryAvailableByFacility = async (productId: any): Promise => let productQoh = '' const payload = { productId: productId, - facilityId: store.getters['user/getCurrentFacility']?.facilityId + facilityId: getCurrentFacilityId() } try { diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 93881b9d..2a775561 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -3,7 +3,7 @@ import { ActionTree } from 'vuex' import RootState from '@/store/RootState' import OrderState from './OrderState' import * as types from './mutation-types' -import { hasError, showToast } from '@/utils' +import { hasError, showToast, getCurrentFacilityId } from '@/utils' import { getProductIdentificationValue, translate } from '@hotwax/dxp-components' import emitter from "@/event-bus"; import store from "@/store"; @@ -82,7 +82,7 @@ const actions: ActionTree = { }, "query": "docType:ORDER", "filter": [ - `orderTypeId: PURCHASE_ORDER AND orderId: ${orderId} AND orderStatusId: (ORDER_APPROVED OR ORDER_CREATED OR ORDER_COMPLETED) AND facilityId: ${this.state.user.currentFacility.facilityId}` + `orderTypeId: PURCHASE_ORDER AND orderId: ${orderId} AND orderStatusId: (ORDER_APPROVED OR ORDER_CREATED OR ORDER_COMPLETED) AND facilityId: ${getCurrentFacilityId()}` ] } } @@ -111,7 +111,7 @@ const actions: ActionTree = { try { const params = { orderId: payload.orderId, - facilityId: this.state.user.currentFacility.facilityId + facilityId: getCurrentFacilityId() } resp = await OrderService.createPurchaseShipment(params) @@ -160,7 +160,7 @@ const actions: ActionTree = { const params = { orderId: payload.orderId, - destinationFacilityId: this.state.user.currentFacility.facilityId, + destinationFacilityId: getCurrentFacilityId(), "type": "PURCHASE_SHIPMENT", "status": "PURCH_SHIP_CREATED", "items": payload.items @@ -168,7 +168,7 @@ const actions: ActionTree = { resp = await OrderService.createIncomingShipment({"payload": params}) if (resp.status === 200 && !hasError(resp) && resp.data.shipmentId) { - const facilityLocations = await this.dispatch('user/getFacilityLocations', this.state.user.currentFacility.facilityId); + const facilityLocations = await this.dispatch('user/getFacilityLocations', getCurrentFacilityId()); if (facilityLocations.length){ const locationSeqId = facilityLocations[0].locationSeqId payload.items.map((item: any) => { @@ -208,7 +208,7 @@ const actions: ActionTree = { "orderBy": 'datetimeReceived DESC', "viewSize": "250" } - const facilityLocations = await this.dispatch('user/getFacilityLocations', this.state.user.currentFacility.facilityId); + const facilityLocations = await this.dispatch('user/getFacilityLocations', getCurrentFacilityId()); const locationSeqId = facilityLocations.length > 0 ? facilityLocations[0].locationSeqId : ""; resp = await OrderService.fetchPOHistory(params) if (resp.status === 200 && !hasError(resp) && resp.data?.count > 0) { diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 495ab4a9..181a286f 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -3,8 +3,8 @@ import { ActionTree } from 'vuex' import RootState from '@/store/RootState' import ShipmentState from './ShipmentState' import * as types from './mutation-types' -import { hasError, showToast } from '@/utils' -import { getProductIdentificationValue, translate } from '@hotwax/dxp-components' +import { hasError, showToast, getCurrentFacilityId } from '@/utils' +import { getProductIdentificationValue, translate, useUserStore } from '@hotwax/dxp-components' import emitter from '@/event-bus' import store from "@/store"; import { DateTime } from 'luxon'; @@ -72,8 +72,7 @@ const actions: ActionTree = { const shipmentAttributes = await ShipmentService.fetchShipmentAttributes([shipmentDetail.shipmentId]) shipmentDetail.externalOrderId = shipmentAttributes?.[shipmentDetail.shipmentId]?.['EXTERNAL_ORDER_ID'] shipmentDetail.externalOrderName = shipmentAttributes?.[shipmentDetail.shipmentId]?.['EXTERNAL_ORDER_NAME'] - - const facilityLocations = await this.dispatch('user/getFacilityLocations', this.state.user.currentFacility.facilityId); + const facilityLocations = await this.dispatch('user/getFacilityLocations', getCurrentFacilityId()); if(facilityLocations.length){ const locationSeqId = facilityLocations[0].locationSeqId resp.data.items.map((item: any) => { @@ -118,7 +117,7 @@ const actions: ActionTree = { const params = { shipmentId: payload.shipmentId, - facilityId: this.state.user.currentFacility.facilityId, + facilityId: getCurrentFacilityId(), shipmentItemSeqId: item.itemSeqId, productId: item.productId, quantityAccepted: item.quantityAccepted, @@ -153,7 +152,7 @@ const actions: ActionTree = { const uploadData = payload.items.map((item: any) => { return { shipmentId: payload.shipmentId, - facilityId: this.state.user.currentFacility.facilityId, + facilityId: getCurrentFacilityId(), shipmentItemSeqId: item.itemSeqId, productId: item.productId, quantityAccepted: item.quantityAccepted, diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index cb10271c..9662871a 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -1,7 +1,6 @@ export default interface UserState { token: string; current: any; - currentFacility: object | null; currentEComStore: object; instanceUrl: string; facilityLocationsByFacilityId: any; diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index e252f7f6..63dae224 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -3,16 +3,16 @@ import { ActionTree } from 'vuex' import RootState from '@/store/RootState' import UserState from './UserState' import * as types from './mutation-types' -import { hasError, showToast } from '@/utils' +import { getCurrentFacilityId, hasError, showToast } from '@/utils' import { Settings } from 'luxon'; -import { getUserFacilities, logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter' +import { logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter' import { getServerPermissionsFromRules, prepareAppPermissions, resetPermissions, setPermissions } from '@/authorization' -import { translate, useAuthStore, useProductIdentificationStore } from '@hotwax/dxp-components' +import { translate, useAuthStore, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components' import emitter from '@/event-bus' import store from '@/store' @@ -57,8 +57,8 @@ const actions: ActionTree = { //fetching user facilities const isAdminUser = appPermissions.some((appPermission: any) => appPermission?.action === "APP_RECVG_ADMIN"); - const baseURL = store.getters['user/getBaseUrl']; - const facilities = await getUserFacilities(token, baseURL, userProfile?.partyId, "", isAdminUser); + const facilities = await useUserStore().getUserFacilities(userProfile?.partyId, "", isAdminUser) + await useUserStore().getFacilityPreference('SELECTED_FACILITY') if (!facilities.length) throw 'Unable to login. User is not assocaited with any facility' @@ -71,9 +71,8 @@ const actions: ActionTree = { return uniqueFacilities }, []); - const currentFacility = userProfile.facilities[0]; - const currentEComStore = await UserService.getEComStores(token, currentFacility.facilityId); - + const currentFacility: any = getCurrentFacilityId(); + const currentEComStore = await UserService.getEComStores(token, currentFacility?.facilityId); const productStoreId = currentEComStore?.productStoreId; await useProductIdentificationStore().getIdentificationPref(productStoreId) @@ -87,7 +86,6 @@ const actions: ActionTree = { // TODO user single mutation commit(types.USER_INFO_UPDATED, userProfile); - commit(types.USER_CURRENT_FACILITY_UPDATED, currentFacility); commit(types.USER_CURRENT_ECOM_STORE_UPDATED, currentEComStore); commit(types.USER_PERMISSIONS_UPDATED, appPermissions); commit(types.USER_TOKEN_CHANGED, { newToken: token }) @@ -173,13 +171,12 @@ const actions: ActionTree = { /** * update current facility information */ - async setFacility ({ commit, dispatch }, payload) { + async setFacility ({ commit, dispatch }, facilityId) { const token = store.getters['user/getUserToken']; - const eComStore = await UserService.getEComStores(token, payload.facility.facilityId); + const eComStore = await UserService.getEComStores(token, facilityId); commit(types.USER_CURRENT_ECOM_STORE_UPDATED, eComStore); - commit(types.USER_CURRENT_FACILITY_UPDATED, payload.facility); - await dispatch('getFacilityLocations', payload.facility.facilityId) + await dispatch('getFacilityLocations', facilityId) eComStore?.productStoreId ? this.dispatch('util/getForceScanSetting', eComStore.productStoreId) : this.dispatch('util/updateForceScanStatus', false) eComStore?.productStoreId ? this.dispatch('util/getBarcodeIdentificationPref', eComStore.productStoreId) : this.dispatch('util/updateBarcodeIdentificationPref', "internalName") }, diff --git a/src/store/modules/user/getters.ts b/src/store/modules/user/getters.ts index 7a584b2b..02a01e2e 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -20,9 +20,6 @@ const getters: GetterTree = { getUserProfile (state) { return state.current }, - getCurrentFacility (state){ - return state.currentFacility - }, getInstanceUrl (state) { const baseUrl = process.env.VUE_APP_BASE_URL; return baseUrl ? baseUrl : state.instanceUrl; diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index c66cd8e1..0a1b3eda 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -10,7 +10,6 @@ const userModule: Module = { state: { token: '', current: {}, - currentFacility: {}, currentEComStore: {}, permissions: [], instanceUrl: '', diff --git a/src/store/modules/user/mutation-types.ts b/src/store/modules/user/mutation-types.ts index f8fe7be5..0d249e6a 100644 --- a/src/store/modules/user/mutation-types.ts +++ b/src/store/modules/user/mutation-types.ts @@ -2,7 +2,6 @@ export const SN_USER = 'user' export const USER_TOKEN_CHANGED = SN_USER + '/TOKEN_CHANGED' export const USER_END_SESSION = SN_USER + '/END_SESSION' export const USER_INFO_UPDATED = SN_USER + '/INFO_UPDATED' -export const USER_CURRENT_FACILITY_UPDATED = SN_USER + '/CURRENT_FACILITY_UPDATED' 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' diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index df65bfb1..d466be40 100644 --- a/src/store/modules/user/mutations.ts +++ b/src/store/modules/user/mutations.ts @@ -9,16 +9,12 @@ const mutations: MutationTree = { [types.USER_END_SESSION] (state) { state.token = '' state.current = {} - state.currentFacility = {}, state.facilityLocationsByFacilityId = {}, state.permissions = [] }, [types.USER_INFO_UPDATED] (state, payload) { state.current = payload }, - [types.USER_CURRENT_FACILITY_UPDATED] (state, payload) { - state.currentFacility = payload; - }, [types.USER_INSTANCE_URL_UPDATED] (state, payload) { state.instanceUrl = payload; }, diff --git a/src/utils/index.ts b/src/utils/index.ts index b699b0ca..4a3b0039 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,5 +1,5 @@ import { toastController } from '@ionic/vue'; -import { translate } from '@hotwax/dxp-components' +import { translate, useUserStore } from '@hotwax/dxp-components' import { Plugins } from '@capacitor/core'; import { DateTime } from "luxon"; @@ -52,4 +52,9 @@ const handleDateTimeInput = (dateTimeValue: any) => { return DateTime.fromISO(dateTime).toMillis() } -export { handleDateTimeInput, showToast, hasError, copyToClipboard } +const getCurrentFacilityId = () => { + const currentFacility: any = useUserStore().getCurrentFacility; + return currentFacility?.facilityId +} + +export { handleDateTimeInput, getCurrentFacilityId, showToast, hasError, copyToClipboard } diff --git a/src/views/AddProductModal.vue b/src/views/AddProductModal.vue index ffff1eff..7bc4c0a3 100644 --- a/src/views/AddProductModal.vue +++ b/src/views/AddProductModal.vue @@ -69,7 +69,7 @@ import { defineComponent, computed } from 'vue'; import { closeOutline, checkmarkCircle } from 'ionicons/icons'; import { mapGetters } from 'vuex' import { useStore } from "@/store"; -import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore, useUserStore } 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', - currentFacility: 'user/getCurrentFacility', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId' }) }, @@ -168,10 +167,13 @@ export default defineComponent({ }, setup() { const store = useStore(); + const userStore = useUserStore() const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { + currentFacility, closeOutline, checkmarkCircle, store, diff --git a/src/views/AddProductToPOModal.vue b/src/views/AddProductToPOModal.vue index a45a0065..79bc5930 100644 --- a/src/views/AddProductToPOModal.vue +++ b/src/views/AddProductToPOModal.vue @@ -60,7 +60,7 @@ import { defineComponent, computed } from 'vue'; import { closeOutline, checkmarkCircle } from 'ionicons/icons'; import { mapGetters } from 'vuex' import { useStore } from "@/store"; -import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore, useUserStore } 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', - currentFacility: 'user/getCurrentFacility', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId' }) }, @@ -159,9 +158,13 @@ export default defineComponent({ }, setup() { const store = useStore(); + const userStore = useUserStore() const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref); + let currentFacility: any = computed(() => userStore.getCurrentFacility) + return { + currentFacility, closeOutline, checkmarkCircle, store, diff --git a/src/views/PurchaseOrderDetail.vue b/src/views/PurchaseOrderDetail.vue index eeb0c403..dcfa0cfc 100644 --- a/src/views/PurchaseOrderDetail.vue +++ b/src/views/PurchaseOrderDetail.vue @@ -64,7 +64,7 @@
- +
@@ -182,7 +182,7 @@ import { import { defineComponent, computed } from 'vue'; import { addOutline, cameraOutline, checkmarkDone, checkmarkDoneCircleOutline, copyOutline, eyeOffOutline, eyeOutline, locationOutline, saveOutline, timeOutline, warningOutline } from 'ionicons/icons'; import ReceivingHistoryModal from '@/views/ReceivingHistoryModal.vue' -import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore } from '@hotwax/dxp-components'; +import { DxpShopifyImg, translate, getProductIdentificationValue, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components'; import { useStore, mapGetters } from 'vuex'; import { useRouter } from 'vue-router'; import Scanner from "@/components/Scanner.vue" @@ -231,7 +231,6 @@ export default defineComponent({ getProduct: 'product/getProduct', getPOItemAccepted: 'order/getPOItemAccepted', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId', - currentFacility: 'user/getCurrentFacility', isForceScanEnabled: 'util/isForceScanEnabled', barcodeIdentifier: 'util/getBarcodeIdentificationPref', }) @@ -420,8 +419,10 @@ export default defineComponent({ setup() { const store = useStore(); const router = useRouter(); + const userStore = useUserStore() const productIdentificationStore = useProductIdentificationStore(); let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref); + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { Actions, @@ -431,6 +432,7 @@ export default defineComponent({ checkmarkDoneCircleOutline, copyOutline, copyToClipboard, + currentFacility, eyeOffOutline, eyeOutline, hasPermission, diff --git a/src/views/PurchaseOrders.vue b/src/views/PurchaseOrders.vue index 455f9dd5..649c7512 100644 --- a/src/views/PurchaseOrders.vue +++ b/src/views/PurchaseOrders.vue @@ -66,10 +66,10 @@ import { IonToolbar } from '@ionic/vue'; import { cloudDownloadOutline, reload } from 'ionicons/icons' -import { defineComponent } from 'vue'; +import { defineComponent, computed } from 'vue'; import { mapGetters, useStore } from 'vuex'; import PurchaseOrderItem from '@/components/PurchaseOrderItem.vue' -import { translate } from "@hotwax/dxp-components" +import { translate, useUserStore } from "@hotwax/dxp-components" export default defineComponent({ name: 'PurchaseOrders', @@ -102,7 +102,6 @@ export default defineComponent({ ...mapGetters({ orders: 'order/getPurchaseOrders', isScrollable: 'order/isScrollable', - currentFacility: 'user/getCurrentFacility' }) }, methods: { @@ -122,7 +121,7 @@ export default defineComponent({ "group.ngroups": true, } as any, "query": "*:*", - "filter": `docType: ORDER AND orderTypeId: PURCHASE_ORDER AND orderStatusId: ${this.selectedSegment === 'open' ? '(ORDER_APPROVED OR ORDER_CREATED)' : 'ORDER_COMPLETED'} AND facilityId: ${this.currentFacility.facilityId}` + "filter": `docType: ORDER AND orderTypeId: PURCHASE_ORDER AND orderStatusId: ${this.selectedSegment === 'open' ? '(ORDER_APPROVED OR ORDER_CREATED)' : 'ORDER_COMPLETED'} AND facilityId: ${this.currentFacility?.facilityId}` } } if(this.queryString) { @@ -155,9 +154,12 @@ export default defineComponent({ }, setup () { const store = useStore(); + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) return { cloudDownloadOutline, + currentFacility, reload, store, translate diff --git a/src/views/ReturnDetails.vue b/src/views/ReturnDetails.vue index 7b64e230..8c319927 100644 --- a/src/views/ReturnDetails.vue +++ b/src/views/ReturnDetails.vue @@ -167,7 +167,6 @@ export default defineComponent({ computed: { ...mapGetters({ current: 'return/getCurrent', - user: 'user/getCurrentFacility', getProduct: 'product/getProduct', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId', returns: 'return/getReturns', diff --git a/src/views/Returns.vue b/src/views/Returns.vue index 0195daa7..3b976e15 100644 --- a/src/views/Returns.vue +++ b/src/views/Returns.vue @@ -67,10 +67,10 @@ import { IonToolbar } from '@ionic/vue'; import { cloudDownloadOutline, reload } from 'ionicons/icons' -import { defineComponent } from 'vue' +import { defineComponent, computed } from 'vue' import { mapGetters, useStore } from 'vuex' import ReturnListItem from '@/components/ReturnListItem.vue' -import { translate } from "@hotwax/dxp-components" +import { translate, useUserStore } from "@hotwax/dxp-components" export default defineComponent({ name: "Returns", @@ -94,7 +94,6 @@ export default defineComponent({ computed: { ...mapGetters({ returns: 'return/getReturns', - currentFacility: 'user/getCurrentFacility' }) }, data () { @@ -120,7 +119,7 @@ export default defineComponent({ const payload = { "entityName": "SalesReturnShipmentView", "inputFields": { - "destinationFacilityId": this.currentFacility.facilityId, + "destinationFacilityId": this.currentFacility?.facilityId, "statusId": "PURCH_SHIP_RECEIVED", "statusId_op": this.selectedSegment === "open" ? "notEqual" : "equals" }, @@ -172,8 +171,12 @@ export default defineComponent({ }, setup() { const store = useStore(); + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) + return { cloudDownloadOutline, + currentFacility, reload, store, translate diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 3713c611..9fcc3891 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -37,22 +37,7 @@
- - - - - {{ translate("Facility") }} - - - - {{ translate('Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.') }} - - - - {{ facility.facilityName }} - - - +

@@ -129,7 +114,6 @@ export default defineComponent({ computed: { ...mapGetters({ userProfile: 'user/getUserProfile', - currentFacility: 'user/getCurrentFacility', currentEComStore: 'user/getCurrentEComStore', isForceScanEnabled: 'util/isForceScanEnabled', barcodeIdentificationPref: 'util/getBarcodeIdentificationPref' @@ -142,16 +126,9 @@ export default defineComponent({ async timeZoneUpdated(tzId: string) { await this.store.dispatch("user/setUserTimeZone", tzId) }, - setFacility (facility: any) { - // Checking if current facility is not equal to the facility selected to avoid extra api call on logging in again after logout. - if(this.currentFacility.facilityId != facility['detail'].value && this.userProfile?.facilities) { - this.userProfile?.facilities?.map((fac: any) => { - if (fac.facilityId == facility['detail'].value) { - this.store.dispatch('shipment/clearShipments'); - this.store.dispatch('user/setFacility', {'facility': fac}); - } - }) - } + async updateFacility(facility: any) { + this.store.dispatch('shipment/clearShipments'); + await this.store.dispatch('user/setFacility', facility?.facilityId); }, async presentAlert () { const alert = await alertController.create({ diff --git a/src/views/ShipmentDetails.vue b/src/views/ShipmentDetails.vue index 04cec0e1..1a25b800 100644 --- a/src/views/ShipmentDetails.vue +++ b/src/views/ShipmentDetails.vue @@ -167,10 +167,8 @@ export default defineComponent({ computed: { ...mapGetters({ current: 'shipment/getCurrent', - user: 'user/getCurrentFacility', getProduct: 'product/getProduct', facilityLocationsByFacilityId: 'user/getFacilityLocationsByFacilityId', - currentFacility: 'user/getCurrentFacility', isForceScanEnabled: 'util/isForceScanEnabled', barcodeIdentifier: 'util/getBarcodeIdentificationPref', }), diff --git a/src/views/Shipments.vue b/src/views/Shipments.vue index ac8a338e..cc71a51e 100644 --- a/src/views/Shipments.vue +++ b/src/views/Shipments.vue @@ -67,10 +67,10 @@ import { IonToolbar } from '@ionic/vue'; import { cloudDownloadOutline, reload } from 'ionicons/icons' -import { defineComponent } from 'vue' +import { defineComponent, computed } from 'vue' import { mapGetters, useStore } from 'vuex' import ShipmentListItem from '@/components/ShipmentListItem.vue' -import { translate } from "@hotwax/dxp-components" +import { translate, useUserStore } from "@hotwax/dxp-components" export default defineComponent({ name: "Shipments", @@ -94,7 +94,6 @@ export default defineComponent({ computed: { ...mapGetters({ shipments: 'shipment/getShipments', - user: 'user/getCurrentFacility' }) }, data() { @@ -121,7 +120,7 @@ export default defineComponent({ const viewIndex = vIndex ? vIndex : 0; const payload = { "inputFields": { - "destinationFacilityId": this.user.facilityId, + "destinationFacilityId": this.currentFacility.facilityId, "statusId": this.selectedSegment === "open" ? "PURCH_SHIP_SHIPPED" : "PURCH_SHIP_RECEIVED", "grp_op": "AND", "shipmentTypeId_value": "INCOMING_SHIPMENT", @@ -171,8 +170,12 @@ export default defineComponent({ }, setup() { const store = useStore(); + const userStore = useUserStore() + let currentFacility: any = computed(() => userStore.getCurrentFacility) + return { cloudDownloadOutline, + currentFacility, reload, store, translate