Skip to content

Commit

Permalink
Improved: Added a flag to prevent auto-population of the facility ID …
Browse files Browse the repository at this point in the history
…after it has been manually edited(hotwax#265)
  • Loading branch information
R-Sourabh committed Oct 17, 2024
1 parent 33cbb71 commit 43ba1ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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,
isFacilityIdManuallySet: false,
}
},
async ionViewWillEnter() {
Expand Down Expand Up @@ -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()) {
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.isFacilityIdManuallySet = true;
},
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: [],
isFacilityGroupIdManuallySet: false
}
},
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.isFacilityGroupIdManuallySet) {
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.isFacilityGroupIdManuallySet = true
},
markFacilityGroupIdTouched() {
(this as any).$refs.facilityGroupId.$el.classList.add('ion-touched');
Expand Down

0 comments on commit 43ba1ce

Please sign in to comment.