Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,23 @@ export class LocationInformationComponent {

ngOnInit() {
this.formData.forEach((item: any) => {
const validators = [];
if (item.isRequired) {
validators.push(Validators.required);
}
if (item.fieldName && item.allowText) {
this.locationInfoFormGroup.addControl(
item.fieldName,
new FormControl(null, [
Validators.pattern(this.allowTextValidator(item.allowText)),
Validators.minLength(parseInt(item?.allowMin)),
Validators.maxLength(parseInt(item?.allowMax)),
]),
);
} else {
this.locationInfoFormGroup.addControl(
item.fieldName,
new FormControl(null),
validators.push(
Validators.pattern(this.allowTextValidator(item.allowText)),
Validators.minLength(Number.parseInt(item?.allowMin)),
Validators.maxLength(Number.parseInt(item?.allowMax))
);
// Initialize filtered list with all options
if (item.options) {
this.filteredOptions[item.fieldName] = [...item.options];
}
} else if (item.options) {
this.filteredOptions[item.fieldName] = [...item.options];
}

this.locationInfoFormGroup.addControl(
item.fieldName,
new FormControl(null, validators)
);
});
this.locationInfoFormGroup.addControl('stateID', new FormControl());
this.locationInfoFormGroup.addControl('districtID', new FormControl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ export class OtherInformationComponent {
ngOnInit() {
console.log('this.otherInfoSubscription', this.otherInfoSubscription);
this.formData.forEach((item: any) => {
const validators = [];
if (item.isRequired) {
validators.push(Validators.required);
}
if (item.fieldName && item.allowText) {
this.otherInfoFormGroup.addControl(
item.fieldName,
new FormControl(null, [
Validators.pattern(this.allowTextValidator(item.allowText)),
Validators.minLength(parseInt(item?.allowMin)),
Validators.maxLength(parseInt(item?.allowMax)),
]),
);
} else {
this.otherInfoFormGroup.addControl(
item.fieldName,
new FormControl(null),
validators.push(
Validators.pattern(this.allowTextValidator(item.allowText)),
Validators.minLength(Number.parseInt(item?.allowMin)),
Validators.maxLength(Number.parseInt(item?.allowMax))
);
}
this.otherInfoFormGroup.addControl(
item.fieldName,
new FormControl(null, validators)
);
});
console.log('otherInfoFormGroup Data', this.otherInfoFormGroup);
if (this.patientRevisit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,27 @@ export class PersonalInformationComponent {
this.isEnableES = environment.isEnableES || false;
this.fetchLanguageResponse();
this.formData.forEach((item: any) => {
const validators = [];
if (item.isRequired) {
validators.push(Validators.required);
}
if (item.fieldName && item.allowText) {
this.personalInfoFormGroup.addControl(
item.fieldName,
new FormControl(null, [
Validators.pattern(this.allowTextValidator(item.allowText)),
Validators.minLength(parseInt(item?.allowMin)),
Validators.maxLength(parseInt(item?.allowMax)),
])
validators.push(
Validators.pattern(this.allowTextValidator(item.allowText)),
Validators.minLength(Number.parseInt(item?.allowMin)),
Validators.maxLength(Number.parseInt(item?.allowMax))
);
}
const existing = this.personalInfoFormGroup.get(item.fieldName);
if (existing) {
if (validators.length) {
existing.addValidators(validators);
existing.updateValueAndValidity({ emitEvent: false });
}
} else {
this.personalInfoFormGroup.addControl(
item.fieldName,
new FormControl(null)
new FormControl(null, validators)
);
}
});
Expand Down
34 changes: 34 additions & 0 deletions v2/registrar/registration/registration.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,32 @@ export class RegistrationComponent {
return this.currentStep >= this.enabledStepKeys.length - 1;
}

private stepFormGroup(key: string): FormGroup | null {
switch (key) {
case 'personal':
return this.personalInfoFormGroup;
case 'location':
return this.locationInfoFormGroup;
case 'other':
return this.otherInfoFormGroup;
case 'abha':
return this.abhaInfoFormGroup;
default:
return null;
}
}

nextStep() {
const group = this.stepFormGroup(this.activeStepKey);
if (group?.invalid) {
group.markAllAsTouched();
this.confirmationService.alert(
this.currentLanguageSet?.alerts?.info?.mandatoryFields ||
'Please fill all the mandatory fields',
'info'
);
return;
}
if (this.currentStep < this.enabledStepKeys.length - 1) {
this.currentStep++;
}
Expand Down Expand Up @@ -335,6 +360,15 @@ export class RegistrationComponent {


submitBeneficiaryDetails() {
if (this.mainForm.invalid) {
this.mainForm.markAllAsTouched();
this.confirmationService.alert(
this.currentLanguageSet?.alerts?.info?.mandatoryFields ||
'Please fill all the mandatory fields',
'info'
);
return;
}
console.log('registration data', this.mainForm);
const newDate = this.dateFormatChange();
const valueToSend = this.mainForm.value;
Expand Down
44 changes: 34 additions & 10 deletions v2/registrar/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
this.handleESSearchResponse(response);
},
(error: any) => {
this.confirmationService.alert(error, 'error');
this.confirmationService.alert(
error?.error?.errorMessage || error?.message || 'Something went wrong',
'error',
);
}
);
}
Expand Down Expand Up @@ -220,7 +223,10 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
this.handleESSearchResponse(response);
},
(error: any) => {
this.confirmationService.alert(error, 'error');
this.confirmationService.alert(
error?.error?.errorMessage || error?.message || 'Something went wrong',
'error',
);
}
);
} else {
Expand Down Expand Up @@ -370,7 +376,8 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
if (!beneficiaryList || beneficiaryList.length <= 0) {
this.resetWorklist();
this.confirmationService.alert(
this.currentLanguageSet.alerts.info.beneficiarynotfound,
this.currentLanguageSet?.alerts?.info?.beneficiarynotfound ||
'Beneficiary not found',
'info',
);
} else {
Expand All @@ -381,12 +388,16 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
console.log('hi', JSON.stringify(beneficiaryList, null, 4));
},
(error) => {
this.confirmationService.alert(error, 'error');
this.confirmationService.alert(
error?.error?.errorMessage || error?.message || 'Something went wrong',
'error',
);
},
);
} else {
this.confirmationService.alert(
this.currentLanguageSet.alerts.info.phoneDetails,
this.currentLanguageSet?.alerts?.info?.phoneDetails ||
'Please enter the required search details',
'info',
);
}
Expand Down Expand Up @@ -554,7 +565,10 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
else this.confirmationService.alert(result.status, 'warn');
},
(error) => {
this.confirmationService.alert(error, 'error');
this.confirmationService.alert(
error?.error?.errorMessage || error?.message || 'Something went wrong',
'error',
);
},
);
}
Expand Down Expand Up @@ -604,7 +618,9 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
this.resetWorklist();
this.quicksearchTerm = null;
this.confirmationService.alert(
this.currentLanguageSet.alerts.info.beneficiaryNotFound,
this.currentLanguageSet?.alerts?.info?.beneficiarynotfound ||
this.currentLanguageSet?.alerts?.info?.beneficiaryNotFound ||
'Beneficiary not found',
'info',
);
} else {
Expand All @@ -614,7 +630,10 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
console.log('ES Advanced Search Result:', JSON.stringify(response, null, 4));
},
(error) => {
this.confirmationService.alert(error, 'error');
this.confirmationService.alert(
error?.error?.errorMessage || error?.message || 'Something went wrong',
'error',
);
},
);
} else {
Expand All @@ -630,7 +649,9 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
this.resetWorklist();
this.quicksearchTerm = null;
this.confirmationService.alert(
this.currentLanguageSet.alerts.info.beneficiaryNotFound,
this.currentLanguageSet?.alerts?.info?.beneficiarynotfound ||
this.currentLanguageSet?.alerts?.info?.beneficiaryNotFound ||
'Beneficiary not found',
'info',
);
} else {
Expand All @@ -639,7 +660,10 @@ export class SearchComponent implements OnInit, DoCheck, AfterViewChecked, OnDes
console.log(JSON.stringify(beneficiaryList, null, 4));
},
(error) => {
this.confirmationService.alert(error, 'error');
this.confirmationService.alert(
error?.error?.errorMessage || error?.message || 'Something went wrong',
'error',
);
},
);
}
Expand Down
1 change: 1 addition & 0 deletions v2/ui/paginator/paginator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import { mergeClasses } from '../utils/merge-classes';
</div>
}
<z-pagination
class="mx-0 w-auto justify-end"
[zPageIndex]="currentPage()"
[zTotal]="totalPages()"
(zPageIndexChange)="currentPage.set($event)"></z-pagination>
Expand Down