diff --git a/src/components/FacilityExternalIdModal.vue b/src/components/FacilityExternalIdModal.vue new file mode 100644 index 00000000..ee6941dd --- /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 2e6f7b31..9ca11f92 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.", @@ -213,6 +215,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/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..cf1a1ce0 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -277,6 +277,23 @@ {{ translate("Edit") }} {{ translate("Remove") }} + + + + + + {{ translate('Facility External ID') }} + + + + {{ translate('Identification') }} + {{ current.externalId ? current.externalId : '-' }} + + + {{ translate("Edit") }} + {{ translate("Remove") }} + @@ -429,6 +446,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 +492,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: { @@ -734,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) { @@ -904,6 +923,27 @@ 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)) { + this.current.externalId = '' + showToast(translate('Removed facility external ID')) + await this.store.dispatch('facility/updateCurrentFacility', this.current) + } 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 +973,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 +1056,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)