From 43ba1ce9c8a65b94127e57da055ef9bca9a06c39 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Thu, 17 Oct 2024 15:14:56 +0530 Subject: [PATCH] Improved: Added a flag to prevent auto-population of the facility ID after it has been manually edited(#265) --- src/views/CreateFacility.vue | 9 +++++++-- src/views/CreateFacilityGroup.vue | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/views/CreateFacility.vue b/src/views/CreateFacility.vue index 0f12eecb..e058e973 100644 --- a/src/views/CreateFacility.vue +++ b/src/views/CreateFacility.vue @@ -110,7 +110,8 @@ export default defineComponent({ externalId: '', }, selectedFacilityTypeId: '' as any, - facilityTypesByParentTypeId: {} as any + facilityTypesByParentTypeId: {} as any, + isFacilityIdManuallySet: false, } }, async ionViewWillEnter() { @@ -138,9 +139,12 @@ export default defineComponent({ facilityId: '', externalId: '', } + this.isFacilityIdManuallySet = false; }, setFacilityId(event: any) { - this.formData.facilityId = generateInternalId(event.target.value) + if(!this.isFacilityIdManuallySet) { + this.formData.facilityId = generateInternalId(event.target.value) + } }, async createFacility() { if (!this.formData.facilityName?.trim()) { @@ -214,6 +218,7 @@ export default defineComponent({ this.formData.facilityId.length <= 20 ? (this as any).$refs.facilityId.$el.classList.add('ion-valid') : (this as any).$refs.facilityId.$el.classList.add('ion-invalid'); + this.isFacilityIdManuallySet = true; }, markFacilityIdTouched() { (this as any).$refs.facilityId.$el.classList.add('ion-touched'); diff --git a/src/views/CreateFacilityGroup.vue b/src/views/CreateFacilityGroup.vue index 1650db2c..52064a16 100644 --- a/src/views/CreateFacilityGroup.vue +++ b/src/views/CreateFacilityGroup.vue @@ -130,7 +130,8 @@ export default defineComponent({ description: '', }, isFacilityGroupTypeDisabled: false, - selectedProductStoreIds: [] + selectedProductStoreIds: [], + isFacilityGroupIdManuallySet: false } }, props: ['selectedFacilityGroupTypeId'], @@ -147,7 +148,9 @@ export default defineComponent({ this.selectedProductStoreIds = selectedProductStoreIds }, setFacilityGroupId(event: any) { - this.formData.facilityGroupId = generateInternalId(event.target.value) + if(!this.isFacilityGroupIdManuallySet) { + this.formData.facilityGroupId = generateInternalId(event.target.value) + } }, async createFacilityGroup() { if (!this.formData.facilityGroupName?.trim()) { @@ -236,6 +239,7 @@ export default defineComponent({ this.formData.facilityGroupId.length <= 20 ? (this as any).$refs.facilityGroupId.$el.classList.add('ion-valid') : (this as any).$refs.facilityGroupId.$el.classList.add('ion-invalid'); + this.isFacilityGroupIdManuallySet = true }, markFacilityGroupIdTouched() { (this as any).$refs.facilityGroupId.$el.classList.add('ion-touched');