Skip to content

Commit

Permalink
Merge pull request #326 from R-Sourabh/#265-id-auto-population
Browse files Browse the repository at this point in the history
Improved: Added a flag to prevent auto-population of the facility ID after it has been manually edited(#265)
  • Loading branch information
ravilodhi authored Nov 21, 2024
2 parents d0a7da3 + 5206c2c commit 17340e7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/components/CreateVirtualFacilityModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ export default defineComponent({
facilityId: '',
description: '',
},
isAutoGenerateId: true
}
},
methods: {
setFacilityId(event: any) {
this.formData.facilityId = generateInternalId(event.target.value)
if(this.isAutoGenerateId) {
this.formData.facilityId = generateInternalId(event.target.value)
}
},
closeModal() {
modalController.dismiss();
Expand Down Expand Up @@ -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.isAutoGenerateId = false;
},
markFacilityIdTouched() {
(this as any).$refs.facilityId.$el.classList.add('ion-touched');
Expand Down
9 changes: 7 additions & 2 deletions src/views/CreateFacility.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export default defineComponent({
externalId: '',
},
selectedFacilityTypeId: '' as any,
facilityTypesByParentTypeId: {} as any
facilityTypesByParentTypeId: {} as any,
isAutoGenerateId: true,
}
},
async ionViewWillEnter() {
Expand Down Expand Up @@ -138,9 +139,12 @@ export default defineComponent({
facilityId: '',
externalId: '',
}
this.isAutoGenerateId = true;
},
setFacilityId(event: any) {
this.formData.facilityId = generateInternalId(event.target.value)
if(this.isAutoGenerateId) {
this.formData.facilityId = generateInternalId(event.target.value)
}
},
async createFacility() {
if (!this.formData.facilityName?.trim()) {
Expand Down Expand Up @@ -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.isAutoGenerateId = false;
},
markFacilityIdTouched() {
(this as any).$refs.facilityId.$el.classList.add('ion-touched');
Expand Down
8 changes: 6 additions & 2 deletions src/views/CreateFacilityGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export default defineComponent({
description: '',
},
isFacilityGroupTypeDisabled: false,
selectedProductStoreIds: []
selectedProductStoreIds: [],
isAutoGenerateId: true
}
},
props: ['selectedFacilityGroupTypeId'],
Expand All @@ -147,7 +148,9 @@ export default defineComponent({
this.selectedProductStoreIds = selectedProductStoreIds
},
setFacilityGroupId(event: any) {
this.formData.facilityGroupId = generateInternalId(event.target.value)
if(this.isAutoGenerateId) {
this.formData.facilityGroupId = generateInternalId(event.target.value)
}
},
async createFacilityGroup() {
if (!this.formData.facilityGroupName?.trim()) {
Expand Down Expand Up @@ -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.isAutoGenerateId = false
},
markFacilityGroupIdTouched() {
(this as any).$refs.facilityGroupId.$el.classList.add('ion-touched');
Expand Down

0 comments on commit 17340e7

Please sign in to comment.