From 43ba1ce9c8a65b94127e57da055ef9bca9a06c39 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Thu, 17 Oct 2024 15:14:56 +0530 Subject: [PATCH 1/3] 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'); From 6352f8e2a1da10a4e0138c9f605c3653e6681c18 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Wed, 20 Nov 2024 18:33:49 +0530 Subject: [PATCH 2/3] Improved: Added a flag to prevent auto-population of the virtualFacilityId after it has been manually edited(#265) --- src/components/CreateVirtualFacilityModal.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/CreateVirtualFacilityModal.vue b/src/components/CreateVirtualFacilityModal.vue index 155575c3..43ff1144 100644 --- a/src/components/CreateVirtualFacilityModal.vue +++ b/src/components/CreateVirtualFacilityModal.vue @@ -91,11 +91,14 @@ export default defineComponent({ facilityId: '', description: '', }, + isVirtualFacIdManuallySet: false } }, methods: { setFacilityId(event: any) { - this.formData.facilityId = generateInternalId(event.target.value) + if(!this.isVirtualFacIdManuallySet) { + this.formData.facilityId = generateInternalId(event.target.value) + } }, closeModal() { modalController.dismiss(); @@ -157,6 +160,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.isVirtualFacIdManuallySet = true; }, markFacilityIdTouched() { (this as any).$refs.facilityId.$el.classList.add('ion-touched'); From 5206c2c8d934599f81ee5ff861107d7b4399239b Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Wed, 20 Nov 2024 19:28:51 +0530 Subject: [PATCH 3/3] Improved: changed the variable name that checks the auto generation of facilityId(#265) --- src/components/CreateVirtualFacilityModal.vue | 6 +++--- src/views/CreateFacility.vue | 8 ++++---- src/views/CreateFacilityGroup.vue | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/CreateVirtualFacilityModal.vue b/src/components/CreateVirtualFacilityModal.vue index 43ff1144..de02d1b9 100644 --- a/src/components/CreateVirtualFacilityModal.vue +++ b/src/components/CreateVirtualFacilityModal.vue @@ -91,12 +91,12 @@ export default defineComponent({ facilityId: '', description: '', }, - isVirtualFacIdManuallySet: false + isAutoGenerateId: true } }, methods: { setFacilityId(event: any) { - if(!this.isVirtualFacIdManuallySet) { + if(this.isAutoGenerateId) { this.formData.facilityId = generateInternalId(event.target.value) } }, @@ -160,7 +160,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.isVirtualFacIdManuallySet = true; + this.isAutoGenerateId = false; }, markFacilityIdTouched() { (this as any).$refs.facilityId.$el.classList.add('ion-touched'); diff --git a/src/views/CreateFacility.vue b/src/views/CreateFacility.vue index e058e973..dbdb5969 100644 --- a/src/views/CreateFacility.vue +++ b/src/views/CreateFacility.vue @@ -111,7 +111,7 @@ export default defineComponent({ }, selectedFacilityTypeId: '' as any, facilityTypesByParentTypeId: {} as any, - isFacilityIdManuallySet: false, + isAutoGenerateId: true, } }, async ionViewWillEnter() { @@ -139,10 +139,10 @@ export default defineComponent({ facilityId: '', externalId: '', } - this.isFacilityIdManuallySet = false; + this.isAutoGenerateId = true; }, setFacilityId(event: any) { - if(!this.isFacilityIdManuallySet) { + if(this.isAutoGenerateId) { this.formData.facilityId = generateInternalId(event.target.value) } }, @@ -218,7 +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; + this.isAutoGenerateId = false; }, markFacilityIdTouched() { (this as any).$refs.facilityId.$el.classList.add('ion-touched'); diff --git a/src/views/CreateFacilityGroup.vue b/src/views/CreateFacilityGroup.vue index 52064a16..a336c677 100644 --- a/src/views/CreateFacilityGroup.vue +++ b/src/views/CreateFacilityGroup.vue @@ -131,7 +131,7 @@ export default defineComponent({ }, isFacilityGroupTypeDisabled: false, selectedProductStoreIds: [], - isFacilityGroupIdManuallySet: false + isAutoGenerateId: true } }, props: ['selectedFacilityGroupTypeId'], @@ -148,7 +148,7 @@ export default defineComponent({ this.selectedProductStoreIds = selectedProductStoreIds }, setFacilityGroupId(event: any) { - if(!this.isFacilityGroupIdManuallySet) { + if(this.isAutoGenerateId) { this.formData.facilityGroupId = generateInternalId(event.target.value) } }, @@ -239,7 +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 + this.isAutoGenerateId = false }, markFacilityGroupIdTouched() { (this as any).$refs.facilityGroupId.$el.classList.add('ion-touched');