From 2fc44a9ad462a53a29749328e5d479efddea3f15 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 20 Nov 2023 16:07:52 +0530 Subject: [PATCH 1/7] Implemented: support to create the locations data dynamic(#18) --- src/services/FacilityService.ts | 9 ++++++++ src/store/modules/facility/FacilityState.ts | 1 - src/store/modules/facility/actions.ts | 24 +++++++++++++++++++++ src/store/modules/facility/index.ts | 1 - src/views/FacilityDetails.vue | 15 +++++++------ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/services/FacilityService.ts b/src/services/FacilityService.ts index d5a5a083..db2deba9 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -123,7 +123,16 @@ const updateFacility = async (payload: any): Promise => { }) } +const fetchFacilityLocations = async(payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + export const FacilityService = { + fetchFacilityLocations, fetchFacilityOnlineGroupInformation, fetchFacilityOrderCounts, fetchFacilitiesOrderCount, diff --git a/src/store/modules/facility/FacilityState.ts b/src/store/modules/facility/FacilityState.ts index 2b9f8839..89006344 100644 --- a/src/store/modules/facility/FacilityState.ts +++ b/src/store/modules/facility/FacilityState.ts @@ -4,7 +4,6 @@ export default interface FacilityState { productStoreId: string, facilityTypeId: string }; - selectedFacility: object; facilities: { list: Array, total: number diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 26d197b3..81392486 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -160,6 +160,30 @@ const actions: ActionTree = { facilityTypeId: '' }) commit(types.FACILITY_LIST_UPDATED , { facilities: [], total: 0 }); + commit(types.FACILITY_CURRENT_UPDATED, {}); + }, + + async fetchFacilityLocations({ state }, payload) { + try { + const params = { + inputFields: { + facilityId: payload.facilityId + }, + entityName: "FacilityLocation", + fieldList: ["facilityId", "locationSeqId", "areaId", "aisleId", "sectionId", "levelId", "positionId"], + viewSize: 100 + } + + const resp = await FacilityService.fetchFacilityLocations(params) + + if(!hasError(resp) && resp.data.count > 0) { + state.current.locations = resp.data.docs + } else { + throw resp.data + } + } catch(err) { + logger.error('Failed to find the facility locations', err) + } } } diff --git a/src/store/modules/facility/index.ts b/src/store/modules/facility/index.ts index bc563c53..5d4a24e0 100644 --- a/src/store/modules/facility/index.ts +++ b/src/store/modules/facility/index.ts @@ -13,7 +13,6 @@ const facilityModule: Module = { productStoreId: '', facilityTypeId: '' }, - selectedFacility: {}, facilities: { list: [], total: 0 diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 574b0573..30c7ffee 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -325,37 +325,37 @@ {{ translate("Add locations to facility") }} -
+
- {{ "locations id" }} + {{ location.locationSeqId }}

{{ "pick/primary" }}

- AI + {{ location.areaId }}

{{ translate("area") }}

- AL + {{ location.aisleId }}

{{ translate("aisle") }}

- SI + {{ location.sectionId }}

{{ translate("section") }}

- SI + {{ location.levelId }}

{{ translate("level") }}

- 1 + {{ location.positionId }}

{{ translate("sequence") }}

@@ -476,6 +476,7 @@ export default defineComponent({ props: ["facilityId"], async ionViewWillEnter() { await this.store.dispatch('facility/fetchCurrentFacility', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityLocations', { facilityId: this.facilityId }) this.isLoading = false }, methods: { From 2282d174efec21378d11bdda3e65cb12fd2ccba0 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 20 Nov 2023 16:54:51 +0530 Subject: [PATCH 2/7] Implemented: support to fetch location type enumeration desc(#18) --- src/services/UtilService.ts | 10 ++++++ src/store/modules/facility/actions.ts | 6 ++-- src/store/modules/facility/mutation-types.ts | 3 +- src/store/modules/facility/mutations.ts | 3 ++ src/store/modules/util/UtilState.ts | 1 + src/store/modules/util/actions.ts | 37 ++++++++++++++++++++ src/store/modules/util/getters.ts | 3 ++ src/store/modules/util/index.ts | 3 +- src/store/modules/util/mutation-types.ts | 3 +- src/store/modules/util/mutations.ts | 3 ++ src/views/FacilityDetails.vue | 7 ++-- 11 files changed, 70 insertions(+), 9 deletions(-) diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 85365974..67c53bc1 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -18,8 +18,18 @@ const fetchProductStores = async (payload: any): Promise => { }) } +const fetchLocationTypes = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "POST", + data: payload, + cache: true + }) +} + export const UtilService = { fetchFacilityTypes, + fetchLocationTypes, fetchProductStores } diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 81392486..4e61154a 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -163,21 +163,21 @@ const actions: ActionTree = { commit(types.FACILITY_CURRENT_UPDATED, {}); }, - async fetchFacilityLocations({ state }, payload) { + async fetchFacilityLocations({ commit }, payload) { try { const params = { inputFields: { facilityId: payload.facilityId }, entityName: "FacilityLocation", - fieldList: ["facilityId", "locationSeqId", "areaId", "aisleId", "sectionId", "levelId", "positionId"], + fieldList: ["facilityId", "locationSeqId", "locationTypeEnumId", "areaId", "aisleId", "sectionId", "levelId", "positionId"], viewSize: 100 } const resp = await FacilityService.fetchFacilityLocations(params) if(!hasError(resp) && resp.data.count > 0) { - state.current.locations = resp.data.docs + commit(types.FACILITY_CURRENT_LOCATION_UPDATED, resp.data.docs) } else { throw resp.data } diff --git a/src/store/modules/facility/mutation-types.ts b/src/store/modules/facility/mutation-types.ts index 4676bdb0..45007698 100644 --- a/src/store/modules/facility/mutation-types.ts +++ b/src/store/modules/facility/mutation-types.ts @@ -1,4 +1,5 @@ export const SN_FACILITY = 'facility' export const FACILITY_LIST_UPDATED = SN_FACILITY + '/LIST_UPDATED' export const FACILITY_QUERY_UPDATED = SN_FACILITY + '/QUERY_UPDATED' -export const FACILITY_CURRENT_UPDATED = SN_FACILITY + '/CURRENT_UPDATED' \ No newline at end of file +export const FACILITY_CURRENT_UPDATED = SN_FACILITY + '/CURRENT_UPDATED' +export const FACILITY_CURRENT_LOCATION_UPDATED = SN_FACILITY + '/CURRENT_LOCATION_UPDATED' \ No newline at end of file diff --git a/src/store/modules/facility/mutations.ts b/src/store/modules/facility/mutations.ts index fab0e52c..c6e11f6b 100644 --- a/src/store/modules/facility/mutations.ts +++ b/src/store/modules/facility/mutations.ts @@ -12,6 +12,9 @@ const mutations: MutationTree = { }, [types.FACILITY_CURRENT_UPDATED](state, payload) { state.current = payload + }, + [types.FACILITY_CURRENT_LOCATION_UPDATED](state, payload) { + state.current.locations = payload } } export default mutations; \ No newline at end of file diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index d6f63851..63ded06e 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -1,4 +1,5 @@ export default interface UtilState { productStores: any[]; facilityTypes: object; + locationTypes: object; } \ No newline at end of file diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 5375800b..158c7581 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -62,6 +62,43 @@ const actions: ActionTree = { commit(types.UTIL_FACILITY_TYPES_UPDATED, facilityTypes) }, + async fetchLocationTypes({ commit, state }) { + const cachedLocationTypes = JSON.parse(JSON.stringify(state.locationTypes)) + + // not fetching location type information again if already present, as it will not be changed so frequently + if(cachedLocationTypes.length) { + return; + } + + let locationTypes = [] + const params = { + inputFields: { + enumTypeId: 'FACLOC_TYPE' + }, + viewSize: 100, + noConditionFind: 'Y', + entityName: 'Enumeration', + fieldList: ['enumId', 'description'] + } as any + + try { + const resp = await UtilService.fetchLocationTypes(params) + if (!hasError(resp)) { + locationTypes = resp.data.docs.reduce((locationType: any, type: any) => { + locationType[type.enumId] = type.description + + return locationType + }, {}) + } else { + throw resp.data + } + } catch (error) { + logger.error(error) + } + + commit(types.UTIL_LOCATION_TYPES_UPDATED, locationTypes) + }, + clearUtilState({ commit }) { commit(types.UTIL_PRODUCT_STORES_UPDATED, []) commit(types.UTIL_FACILITY_TYPES_UPDATED, []) diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index 0b2f9c6d..73b01c5f 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -8,6 +8,9 @@ const getters: GetterTree = { }, getFacilityTypes(state) { return state.facilityTypes + }, + getLocationTypes(state) { + return state.locationTypes } } 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 5470f963..b152ff86 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -9,7 +9,8 @@ const utilModule: Module = { namespaced: true, state: { productStores: [], - facilityTypes: {} + facilityTypes: {}, + locationTypes: {} }, getters, actions, diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index 0901fa26..f5a7f1b6 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -1,3 +1,4 @@ export const SN_UTIL = 'util' export const UTIL_PRODUCT_STORES_UPDATED = SN_UTIL + '/PRODUCT_STORES_UPDATED' -export const UTIL_FACILITY_TYPES_UPDATED = SN_UTIL + '/FACILITY_TYPES_UPDATED' \ No newline at end of file +export const UTIL_FACILITY_TYPES_UPDATED = SN_UTIL + '/FACILITY_TYPES_UPDATED' +export const UTIL_LOCATION_TYPES_UPDATED = SN_UTIL + '/LOCATION_TYPES_UPDATED' \ No newline at end of file diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index 5d84d496..10531900 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -8,6 +8,9 @@ const mutations: MutationTree = { }, [types.UTIL_FACILITY_TYPES_UPDATED](state, payload) { state.facilityTypes = payload + }, + [types.UTIL_LOCATION_TYPES_UPDATED](state, payload) { + state.locationTypes = payload } } export default mutations; \ No newline at end of file diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 30c7ffee..4f98e529 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -330,7 +330,7 @@ {{ location.locationSeqId }} -

{{ "pick/primary" }}

+

{{ locationTypes[location.locationTypeEnumId] }}

@@ -470,13 +470,14 @@ export default defineComponent({ }, computed: { ...mapGetters({ - current: 'facility/getCurrent' + current: 'facility/getCurrent', + locationTypes: 'util/getLocationTypes' }) }, props: ["facilityId"], async ionViewWillEnter() { await this.store.dispatch('facility/fetchCurrentFacility', { facilityId: this.facilityId }) - await this.store.dispatch('facility/fetchFacilityLocations', { facilityId: this.facilityId }) + await Promise.all([this.store.dispatch('facility/fetchFacilityLocations', { facilityId: this.facilityId }), this.store.dispatch('util/fetchLocationTypes')]) this.isLoading = false }, methods: { From 25f6e346a78de1d13aacf4f430018372e552d3b9 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 21 Nov 2023 10:20:12 +0530 Subject: [PATCH 3/7] Implemented: support for updating facility location(#18) --- src/components/AddLocationModal.vue | 91 ++++++++++++++++++++--- src/components/LocationDetailsPopover.vue | 22 +++++- src/services/FacilityService.ts | 29 +++++++- src/store/modules/facility/actions.ts | 22 ++++++ src/views/FacilityDetails.vue | 5 +- 5 files changed, 154 insertions(+), 15 deletions(-) diff --git a/src/components/AddLocationModal.vue b/src/components/AddLocationModal.vue index 0993a396..d58894d4 100644 --- a/src/components/AddLocationModal.vue +++ b/src/components/AddLocationModal.vue @@ -20,28 +20,28 @@ {{ translate("Area") }} * - + {{ translate("Aisle") }} * - + {{ translate("Section") }} * - + {{ translate("Level") }} * - + {{ translate("Sequence") }} - + - + @@ -69,6 +69,11 @@ import { import { defineComponent } from "vue"; import { closeOutline, saveOutline } from "ionicons/icons"; import { translate } from '@hotwax/dxp-components' +import { FacilityService } from "@/services/FacilityService"; +import { mapGetters } from 'vuex' +import { hasError } from "@/adapter"; +import { showToast } from "@/utils"; +import logger from "@/logger"; export default defineComponent({ name: "AddLocationModal", @@ -89,11 +94,79 @@ export default defineComponent({ IonTitle, IonToolbar }, - methods: { - closeModal() { - modalController.dismiss() + props: ["location"], + data() { + return { + locationInfo: {} as any } }, + mounted() { + this.locationInfo = this.location ? JSON.parse(JSON.stringify(this.location)) : {} + }, + computed: { + ...mapGetters({ + current: 'facility/getCurrent' + }) + }, + methods: { + closeModal(result?: string) { + modalController.dismiss({ result }); + }, + saveFacilityLocation() { + if(!this.locationInfo.aisleId.trim() || !this.locationInfo.areaId.trim() || !this.locationInfo.positionId.trim() || !this.locationInfo.sectionId.trim() || !this.locationInfo.levelId.trim()) { + showToast(translate('Please fill all the required fields')) + return; + } + + // checking for locationSeqId as when adding new facility we won't be having locationSeqId + if(this.location.locationSeqId) { + this.updateFacilityLocation() + } else { + this.addFacilityLocation() + } + }, + async addFacilityLocation() { + const params = { + facilityId: this.current.facilityId, + ...this.locationInfo + } + + try { + const resp = await FacilityService.createFacilityLocation(params) + + if(!hasError(resp)) { + showToast(translate('Facility location created successfully')) + this.closeModal('success'); + } else { + throw resp.data + } + } catch(err) { + showToast(translate('Failed to create facility location')) + logger.error('Failed to create facility location', err) + } + }, + + async updateFacilityLocation() { + const params = { + facilityId: this.current.facilityId, + ...this.locationInfo + } + + try { + const resp = await FacilityService.updateFacilityLocation(params) + + if(!hasError(resp)) { + showToast(translate('Facility location updated successfully')) + this.closeModal('success'); + } else { + throw resp.data + } + } catch(err) { + showToast(translate('Failed to update facility location')) + logger.error('Failed to update facility location', err) + } + }, + }, setup() { return { closeOutline, diff --git a/src/components/LocationDetailsPopover.vue b/src/components/LocationDetailsPopover.vue index 82c079f9..11e08486 100644 --- a/src/components/LocationDetailsPopover.vue +++ b/src/components/LocationDetailsPopover.vue @@ -5,7 +5,7 @@ {{ translate("Edit location") }} - + {{ translate("Remove location") }} @@ -18,11 +18,13 @@ import { IonItem, IonList, IonListHeader, - modalController + modalController, +popoverController } from "@ionic/vue"; import { defineComponent } from "vue"; import { translate } from "@hotwax/dxp-components"; import AddLocationModal from "./AddLocationModal.vue"; +import { useStore } from "vuex"; export default defineComponent({ name: "LocationDetailsPopover", @@ -32,17 +34,31 @@ export default defineComponent({ IonList, IonListHeader }, + props: ["location"], methods: { async addLocationModal() { const addLocationModal = await modalController.create({ - component: AddLocationModal + component: AddLocationModal, + componentProps: { location: this.location } }) addLocationModal.present() + + addLocationModal.onDidDismiss().then((result: any) => { + if(result.data.result) { + popoverController.dismiss(); + } + }) + }, + removeLocation() { + this.store.dispatch('facility/deleteFacilityLocation', this.location) } }, setup() { + const store = useStore(); + return { + store, translate }; } diff --git a/src/services/FacilityService.ts b/src/services/FacilityService.ts index db2deba9..e7e5e415 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -131,11 +131,38 @@ const fetchFacilityLocations = async(payload: any): Promise => { }) } +const createFacilityLocation = async(payload: any): Promise => { + return api({ + url: "service/createFacilityLocation", + method: "post", + data: payload + }) +} + +const updateFacilityLocation = async(payload: any): Promise => { + return api({ + url: "service/updateFacilityLocation", + method: "post", + data: payload + }) +} + +const deleteFacilityLocation = async(payload: any): Promise => { + return api({ + url: "service/deleteFacilityLocation", + method: "post", + data: payload + }) +} + export const FacilityService = { + createFacilityLocation, + deleteFacilityLocation, fetchFacilityLocations, fetchFacilityOnlineGroupInformation, fetchFacilityOrderCounts, fetchFacilitiesOrderCount, fetchFacilities, - updateFacility + updateFacility, + updateFacilityLocation } \ No newline at end of file diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 4e61154a..b394d87d 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -6,6 +6,8 @@ import { FacilityService } from '@/services/FacilityService' import { hasError } from '@/adapter' import * as types from './mutation-types' import logger from '@/logger' +import { showToast } from '@/utils' +import { translate } from '@hotwax/dxp-components' const actions: ActionTree = { async fetchFacilities({ commit, state }, payload) { @@ -184,6 +186,26 @@ const actions: ActionTree = { } catch(err) { logger.error('Failed to find the facility locations', err) } + }, + + async deleteFacilityLocation({ dispatch }, payload) { + const params = { + facilityId: payload.facilityId, + locationSeqId: payload.locationSeqId + } + + try { + const resp = await FacilityService.deleteFacilityLocation(params) + + if(!hasError(resp)) { + dispatch('fetchFacilityLocation') + } else { + throw resp.data + } + } catch(err) { + showToast(translate('Failed to remove facility location')) + logger.error('Failed to remove facility location', err) + } } } diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 4f98e529..55cf6ddf 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -359,7 +359,7 @@

{{ translate("sequence") }}

- +
@@ -531,9 +531,10 @@ export default defineComponent({ selectOperatingTimeModal.present() }, - async openLocationDetailsPopover(ev: Event) { + async openLocationDetailsPopover(ev: Event, location: any) { const locationDetailsPopover = await popoverController.create({ component: LocationDetailsPopover, + componentProps: { location }, event: ev, showBackdrop: false }); From 6b28537b41b17c1066ddfc3557ac12e1cd138111 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 21 Nov 2023 10:26:07 +0530 Subject: [PATCH 4/7] Improved: location types options to be dynamic on UI(#18) --- src/components/AddLocationModal.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/AddLocationModal.vue b/src/components/AddLocationModal.vue index d58894d4..c5c0f4f8 100644 --- a/src/components/AddLocationModal.vue +++ b/src/components/AddLocationModal.vue @@ -13,9 +13,8 @@ {{ translate("Type") }} - - {{ "pick/primary" }} - {{ "bulk" }} + + {{ description }} @@ -105,7 +104,8 @@ export default defineComponent({ }, computed: { ...mapGetters({ - current: 'facility/getCurrent' + current: 'facility/getCurrent', + locationTypes: 'util/getLocationTypes' }) }, methods: { From 07f317bb234500fa1a63bf2ff778ab16745cab87 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 21 Nov 2023 10:32:42 +0530 Subject: [PATCH 5/7] Improved: handling of undefined values and closed the popover after remove action(#18) --- src/components/AddLocationModal.vue | 2 +- src/components/LocationDetailsPopover.vue | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/AddLocationModal.vue b/src/components/AddLocationModal.vue index c5c0f4f8..cbcf897e 100644 --- a/src/components/AddLocationModal.vue +++ b/src/components/AddLocationModal.vue @@ -113,7 +113,7 @@ export default defineComponent({ modalController.dismiss({ result }); }, saveFacilityLocation() { - if(!this.locationInfo.aisleId.trim() || !this.locationInfo.areaId.trim() || !this.locationInfo.positionId.trim() || !this.locationInfo.sectionId.trim() || !this.locationInfo.levelId.trim()) { + if(!this.locationInfo.aisleId?.trim() || !this.locationInfo.areaId?.trim() || !this.locationInfo.positionId?.trim() || !this.locationInfo.sectionId?.trim() || !this.locationInfo.levelId?.trim()) { showToast(translate('Please fill all the required fields')) return; } diff --git a/src/components/LocationDetailsPopover.vue b/src/components/LocationDetailsPopover.vue index 11e08486..fc906fd8 100644 --- a/src/components/LocationDetailsPopover.vue +++ b/src/components/LocationDetailsPopover.vue @@ -45,13 +45,14 @@ export default defineComponent({ addLocationModal.present() addLocationModal.onDidDismiss().then((result: any) => { - if(result.data.result) { + if(result.data?.result) { popoverController.dismiss(); } }) }, - removeLocation() { - this.store.dispatch('facility/deleteFacilityLocation', this.location) + async removeLocation() { + await this.store.dispatch('facility/deleteFacilityLocation', this.location) + popoverController.dismiss(); } }, setup() { From 3d52e499e00ee53755c3d7fe410e6cd2e7f9504c Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 21 Nov 2023 10:49:26 +0530 Subject: [PATCH 6/7] Improved: code to move the action to component(#18) --- src/components/LocationDetailsPopover.vue | 31 ++++++++++++++++++++--- src/store/modules/facility/actions.ts | 20 --------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/components/LocationDetailsPopover.vue b/src/components/LocationDetailsPopover.vue index fc906fd8..2a05110c 100644 --- a/src/components/LocationDetailsPopover.vue +++ b/src/components/LocationDetailsPopover.vue @@ -24,7 +24,11 @@ popoverController import { defineComponent } from "vue"; import { translate } from "@hotwax/dxp-components"; import AddLocationModal from "./AddLocationModal.vue"; -import { useStore } from "vuex"; +import { mapGetters, useStore } from "vuex"; +import { FacilityService } from "@/services/FacilityService"; +import { hasError } from "@/adapter"; +import { showToast } from "@/utils"; +import logger from "@/logger"; export default defineComponent({ name: "LocationDetailsPopover", @@ -34,6 +38,11 @@ export default defineComponent({ IonList, IonListHeader }, + computed: { + ...mapGetters({ + current: 'facility/getCurrent' + }) + }, props: ["location"], methods: { async addLocationModal() { @@ -51,8 +60,24 @@ export default defineComponent({ }) }, async removeLocation() { - await this.store.dispatch('facility/deleteFacilityLocation', this.location) - popoverController.dismiss(); + const params = { + facilityId: this.location.facilityId, + locationSeqId: this.location.locationSeqId + } + + try { + const resp = await FacilityService.deleteFacilityLocation(params) + + if(!hasError(resp)) { + this.store.dispatch('facility/fetchFacilityLocation') + popoverController.dismiss(); + } else { + throw resp.data + } + } catch(err) { + showToast(translate('Failed to remove facility location')) + logger.error('Failed to remove facility location', err) + } } }, setup() { diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index b394d87d..7f0ee344 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -186,26 +186,6 @@ const actions: ActionTree = { } catch(err) { logger.error('Failed to find the facility locations', err) } - }, - - async deleteFacilityLocation({ dispatch }, payload) { - const params = { - facilityId: payload.facilityId, - locationSeqId: payload.locationSeqId - } - - try { - const resp = await FacilityService.deleteFacilityLocation(params) - - if(!hasError(resp)) { - dispatch('fetchFacilityLocation') - } else { - throw resp.data - } - } catch(err) { - showToast(translate('Failed to remove facility location')) - logger.error('Failed to remove facility location', err) - } } } From 97fc0e1276933b4e92cc950de91707ae30e429e0 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 21 Nov 2023 11:08:33 +0530 Subject: [PATCH 7/7] Improved: UI to add translations and removed unwanted imports(#18) --- src/components/AddLocationModal.vue | 10 +++++----- src/locales/en.json | 23 +++++++++++++++-------- src/store/modules/facility/actions.ts | 2 -- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/components/AddLocationModal.vue b/src/components/AddLocationModal.vue index cbcf897e..e08e8b54 100644 --- a/src/components/AddLocationModal.vue +++ b/src/components/AddLocationModal.vue @@ -19,23 +19,23 @@ {{ translate("Area") }} * - + {{ translate("Aisle") }} * - + {{ translate("Section") }} * - + {{ translate("Level") }} * - + {{ translate("Sequence") }} - + diff --git a/src/locales/en.json b/src/locales/en.json index ddf814e9..ce273a53 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -7,14 +7,14 @@ "Address": "Address", "Address line 1": "Address line 1", "Address line 2": "Address line 2", - "aisle": "aisle", "Aisle": "Aisle", + "aisle": "aisle", "All": "All", "Allow pickup": "Allow pickup", "App": "App", "Apply": "Apply", - "area": "area", "Area": "Area", + "area": "area", "Back to Launchpad": "Back to Launchpad", "Built: ": "Built: { builtDateTime }", "Cancel": "Cancel", @@ -39,9 +39,15 @@ "Facility": "Facility", "Facility details": "Facility details", "Facility ID": "Facility ID", + "Facility location created successfully": "Facility location created successfully", + "Facility location updated successfully": "Facility location updated successfully", "Facility name": "Facility name", "Facility Management": "Facility Management", + "Failed to create facility location": "Failed to create facility location", "Failed to fetch facility information": "Failed to fetch facility information", + "Failed to find the facility locations": "Failed to find the facility locations", + "Failed to remove facility location": "Failed to remove facility location", + "Failed to update facility location": "Failed to update facility location", "Fetching TimeZones": "Fetching TimeZones", "Find Facilities": "Find Facilities", "Friday": "Friday", @@ -58,8 +64,8 @@ "Language": "Language", "Latitude": "Latitude", "Latitude & Longitude": "Latitude & Longitude", - "level": "level", "Level": "Level", + "level": "level", "Loading": "Loading", "Location": "Location", "Location details": "Location details", @@ -91,10 +97,11 @@ "orders allocated today": "{orderCount} orders allocated today", "orders in fulfillment queue": "{orderCount} orders in fulfillment queue", "Parking": "Parking", - "party id": "party id", "Party Id": "Party Id", + "party id": "party id", "Password": "Password", "Please contact the administrator.": "Please contact the administrator.", + "Please fill all the required fields": "Please fill all the required fields", "primary store": "primary store", "Product Store": "Product Store", "Product Stores": "Product Stores", @@ -102,12 +109,12 @@ "Reset": "Reset", "Remove": "Remove", "Remove location": "Remove location", - "role": "role", "Role": "Role", + "role": "role", "Saturday": "Saturday", "Save": "Save", - "section": "section", "Section": "Section", + "section": "section", "Select": "Select", "Search facilities": "Search facilities", "Search time zones": "Search time zones", @@ -119,8 +126,8 @@ "Select your preferred language.": "Select your preferred language.", "Sell Online": "Sell Online", "Sell Inventory Online": "Sell Inventory Online", - "sequence": "sequence", "Sequence": "Sequence", + "sequence": "sequence", "Settings": "Settings", "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.": "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.", "Shopify": "Shopify", @@ -131,8 +138,8 @@ "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.": "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.", "Staff": "Staff", "State": "State", - "Store": "Store", "store name": "store name", + "Store": "Store", "Sunday": "Sunday", "The timezone you select is used to ensure automations you schedule are always accurate to the time you select.": "The timezone you select is used to ensure automations you schedule are always accurate to the time you select.", "These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.": "These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.", diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 7f0ee344..4e61154a 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -6,8 +6,6 @@ import { FacilityService } from '@/services/FacilityService' import { hasError } from '@/adapter' import * as types from './mutation-types' import logger from '@/logger' -import { showToast } from '@/utils' -import { translate } from '@hotwax/dxp-components' const actions: ActionTree = { async fetchFacilities({ commit, state }, payload) {