From 89fec108c570732a7086b57e5cf6451d0f75708c Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 11 Dec 2023 12:00:48 +0530 Subject: [PATCH 1/4] Implemented: support to show external Id on the details page(#92) --- src/components/FacilityExternalIdModal.vue | 141 +++++++++++++++++++++ src/locales/en.json | 6 +- src/store/modules/facility/actions.ts | 4 +- src/views/FacilityDetails.vue | 47 ++++++- src/views/FindFacilities.vue | 7 +- 5 files changed, 198 insertions(+), 7 deletions(-) create mode 100644 src/components/FacilityExternalIdModal.vue diff --git a/src/components/FacilityExternalIdModal.vue b/src/components/FacilityExternalIdModal.vue new file mode 100644 index 00000000..1188582f --- /dev/null +++ b/src/components/FacilityExternalIdModal.vue @@ -0,0 +1,141 @@ + + + \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index be2b41df..8a2a4e0b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -67,12 +67,14 @@ "External mapping updated successfully": "External mapping updated successfully", "External mappings": "External mappings", "Facilities": "Facilities", + "Facility": "Facility", "Facility address created successfully.": "Facility address created successfully.", + "Facility address updated successfully.": "Facility address updated successfully.", "Facility created successfully.": "Facility created successfully.", "Facility configurations created successfully.": "Facility configurations created successfully.", - "Facility": "Facility", - "Facility address updated successfully.": "Facility address updated successfully.", "Facility details": "Facility details", + "Facility External ID": "Facility External ID", + "Facility external id udpated": "Facility external id udpated", "Facility ID": "Facility ID", "Facility latitude and longitude removed successfully.": "Facility latitude and longitude removed successfully.", "Facility latitude and longitude updated successfully.": "Facility latitude and longitude updated successfully.", diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 28701190..c78aaa52 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -88,7 +88,7 @@ const actions: ActionTree = { "entityName": "FacilityAndProductStore", "noConditionFind": "Y", "distinct": "Y", - "fieldList": ['facilityId', 'facilityName', 'facilityTypeId', 'maximumOrderLimit', 'defaultDaysToShip'], + "fieldList": ['facilityId', 'facilityName', 'facilityTypeId', 'maximumOrderLimit', 'defaultDaysToShip', "externalId"], ...payload } @@ -173,7 +173,7 @@ const actions: ActionTree = { entityName: "FacilityAndProductStore", noConditionFind: "Y", distinct: "Y", - fieldList: ['facilityId', 'facilityName', 'facilityTypeId', 'maximumOrderLimit', 'defaultDaysToShip'], + fieldList: ['facilityId', 'facilityName', 'facilityTypeId', 'maximumOrderLimit', 'defaultDaysToShip', "externalId"], viewSize: 1 } diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 79853786..b9ca3b5a 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -277,6 +277,21 @@ {{ translate("Edit") }} {{ translate("Remove") }} + + + + + + {{ translate('Facility External ID') }} + + + + {{ translate('Identification') }} + {{ current.externalId ? current.externalId : '-' }} + + {{ translate("Edit") }} + {{ translate("Remove") }} + @@ -429,6 +444,7 @@ import { FacilityService } from '@/services/FacilityService'; import { hasError } from '@/adapter'; import logger from '@/logger'; import FacilityShopifyMappingModal from '@/components/FacilityShopifyMappingModal.vue' +import FacilityExternalIdModal from '@/components/FacilityExternalIdModal.vue' import FacilityMappingModal from '@/components/FacilityMappingModal.vue' import { showToast } from '@/utils'; import OperatingHoursPopover from '@/components/OperatingHoursPopover.vue' @@ -474,7 +490,8 @@ export default defineComponent({ isCalendarFound: true, selectedCalendarId: '', isRegenerationRequired: true, - days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] + days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'], + externalId: '' } }, computed: { @@ -904,6 +921,25 @@ export default defineComponent({ showToast(translate('Failed to remove facility mapping')) } }, + async removeFacilityExternalID() { + try { + const payload = { + facilityId: this.current.facilityId, + externalId: '' + } + + const resp = await FacilityService.updateFacility(payload) + + if(!hasError(resp)) { + showToast(translate('Removed facility external ID')) + } else { + throw resp.data + } + } catch(err) { + logger.error('Failed to remove external id', err) + showToast(translate('Failed to remove external id')) + } + }, async removeShopifyFacilityMapping(shopifyFacilityMapping: any) { try { const payload = { @@ -933,6 +969,13 @@ export default defineComponent({ customMappingModal.present() }, + async editFacilityExternalId() { + const facilityExternalIdModal = await modalController.create({ + component: FacilityExternalIdModal + }) + + facilityExternalIdModal.present() + }, async editShopifyFacilityMapping(shopifyFacilityMapping: any) { const customMappingModal = await modalController.create({ component: FacilityShopifyMappingModal, @@ -1009,7 +1052,7 @@ export default defineComponent({ }) await alert.present() - }, + } }, setup() { const store = useStore(); diff --git a/src/views/FindFacilities.vue b/src/views/FindFacilities.vue index ddad01d9..5871c987 100644 --- a/src/views/FindFacilities.vue +++ b/src/views/FindFacilities.vue @@ -199,10 +199,15 @@ export default defineComponent({ }) }, async mounted() { - await this.fetchFacilities(); // We only need to fetch those types whose parent is not virtual facility await Promise.all([this.store.dispatch('util/fetchFacilityTypes', { parentTypeId: 'VIRTUAL_FACILITY', parentTypeId_op: 'notEqual', facilityTypeId: 'VIRTUAL_FACILITY', facilityTypeId_op: 'notEqual' }), this.store.dispatch('util/fetchProductStores')]) }, + async ionViewWillEnter() { + // fetching facilities information in the ionViewWillEnter hook as when updating facilityGroup or fulfillment limit + // from the details page and again coming to the list page, the UI does not gets updated when fetching information in + // the mounted hook + await this.fetchFacilities(); + }, methods: { async updateQuery() { await this.store.dispatch('facility/updateFacilityQuery', this.query) From d4d236967defa83ceb7af80ff035789066f62ac3 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 11 Dec 2023 12:33:35 +0530 Subject: [PATCH 2/4] Improved: remove external id function to update the facility details(#92) --- src/components/FacilityExternalIdModal.vue | 6 +++--- src/locales/en.json | 1 + src/views/FacilityDetails.vue | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/FacilityExternalIdModal.vue b/src/components/FacilityExternalIdModal.vue index 1188582f..5e0211cc 100644 --- a/src/components/FacilityExternalIdModal.vue +++ b/src/components/FacilityExternalIdModal.vue @@ -11,7 +11,7 @@ -
+ {{ translate("Facility details") }} @@ -97,7 +97,7 @@ export default defineComponent({ modalController.dismiss() }, async updateExternalId() { - if(!this.currentFacility.externalId.trim()) { + if(!this.currentFacility.externalId?.trim()) { showToast(translate('Please enter a valid value')) return; } @@ -114,7 +114,7 @@ export default defineComponent({ if(!hasError(resp)) { showToast(translate('Facility external id udpated')) - this.store.dispatch('facility/updateCurrentFacility', this.currentFacility) + await this.store.dispatch('facility/updateCurrentFacility', this.currentFacility) this.closeModal(); } else { throw resp.data diff --git a/src/locales/en.json b/src/locales/en.json index 8a2a4e0b..38795270 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -214,6 +214,7 @@ "Remove": "Remove", "Remove location": "Remove location", "Remove schedule": "Remove schedule", + "Removed facility external ID": "Removed facility external ID", "Removed facility mapping successfully": "Removed facility mapping successfully", "Removed shopify mapping successfully": "Removed shopify mapping successfully", "Rename": "Rename", diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index b9ca3b5a..e6cdc1c0 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -931,7 +931,9 @@ export default defineComponent({ const resp = await FacilityService.updateFacility(payload) if(!hasError(resp)) { + this.current.externalId = '' showToast(translate('Removed facility external ID')) + await this.store.dispatch('facility/updateCurrentFacility', this.current) } else { throw resp.data } From f89c978c217a5ae1fdbd0d72e8ac560560a3764c Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 11 Dec 2023 14:36:41 +0530 Subject: [PATCH 3/4] Improved: code to have support for autofocus inside the modal(#92) --- src/components/FacilityExternalIdModal.vue | 2 +- src/views/FacilityDetails.vue | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/FacilityExternalIdModal.vue b/src/components/FacilityExternalIdModal.vue index 5e0211cc..70dcdd83 100644 --- a/src/components/FacilityExternalIdModal.vue +++ b/src/components/FacilityExternalIdModal.vue @@ -28,7 +28,7 @@ {{ translate('Facility External ID') }} {{ translate("Identification") }} - + diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index e6cdc1c0..cf1a1ce0 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -289,7 +289,9 @@ {{ translate('Identification') }} {{ current.externalId ? current.externalId : '-' }} - {{ translate("Edit") }} + + {{ translate("Edit") }} {{ translate("Remove") }} @@ -751,7 +753,7 @@ export default defineComponent({ if(result.data != undefined && result.data !== this.current.maximumOrderLimit) { await this.updateFacility(result.data, this.current) // refetching the facility to update the maximumOrderLimit - await this.store.dispatch('facility/fetchCurrentFacility', this.facilityId) + await this.store.dispatch('facility/fetchCurrentFacility', { facilityId: this.facilityId, skipState: true }) } }, async updateFacility(maximumOrderLimit: number | string, facility: any) { From 866b17a2308ff28cfacb93acf69efea949e437c3 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 11 Dec 2023 14:39:03 +0530 Subject: [PATCH 4/4] Fixed: duplicate api call on enter when focus is on fab-button(#92) --- src/components/FacilityExternalIdModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/FacilityExternalIdModal.vue b/src/components/FacilityExternalIdModal.vue index 70dcdd83..ee6941dd 100644 --- a/src/components/FacilityExternalIdModal.vue +++ b/src/components/FacilityExternalIdModal.vue @@ -33,7 +33,7 @@ - +