Files restored from dev during the demo-backup merge were missing the standard license header (dev's copies predate that fix, which had only been applied on the demo line previously). Also fixed pre-existing lint debt surfaced by the edit: wrong component selector prefix and constructor-injection pattern in client-family-member-child-dialog.
125 lines
3.5 KiB
TypeScript
125 lines
3.5 KiB
TypeScript
/**
|
|
* Copyright since 2025 Mifos Initiative
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
import { Component, OnInit, inject } from '@angular/core';
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
import { UntypedFormBuilder, UntypedFormGroup, UntypedFormArray, Validators } from '@angular/forms';
|
|
|
|
import { MatIcon } from '@angular/material/icon';
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
import { MatInputModule } from '@angular/material/input';
|
|
import { MatSelectModule } from '@angular/material/select';
|
|
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
import { MatDialogModule } from '@angular/material/dialog';
|
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
import { ReactiveFormsModule } from '@angular/forms';
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
@Component({
|
|
selector: 'mifosx-client-family-member-child-dialog',
|
|
templateUrl: './client-family-member-child-dialog.component.html',
|
|
styleUrls: ['../client-family-member-dialog/client-family-member-dialog.component.scss'],
|
|
standalone: true,
|
|
imports: [
|
|
CommonModule,
|
|
ReactiveFormsModule,
|
|
MatDialogModule,
|
|
MatIcon,
|
|
MatButtonModule,
|
|
MatInputModule,
|
|
MatSelectModule,
|
|
MatDatepickerModule,
|
|
MatTooltipModule
|
|
]
|
|
})
|
|
export class ClientFamilyMemberChildDialogComponent implements OnInit {
|
|
dialogRef = inject(MatDialogRef<ClientFamilyMemberChildDialogComponent>);
|
|
data = inject(MAT_DIALOG_DATA);
|
|
private formBuilder = inject(UntypedFormBuilder);
|
|
|
|
childrenForm: UntypedFormGroup;
|
|
genderIdOptions: any[];
|
|
maxDate: Date = new Date();
|
|
|
|
constructor() {
|
|
this.genderIdOptions = this.data.genderIdOptions;
|
|
|
|
this.childrenForm = this.formBuilder.group({
|
|
children: this.formBuilder.array([])
|
|
});
|
|
}
|
|
|
|
ngOnInit() {
|
|
if (this.data.children && this.data.children.length > 0) {
|
|
this.data.children.forEach((child: any) => {
|
|
this.children.push(
|
|
this.formBuilder.group({
|
|
id: [child.id],
|
|
fullName: [
|
|
child.fullName,
|
|
Validators.required
|
|
],
|
|
genderId: [
|
|
child.genderId,
|
|
Validators.required
|
|
],
|
|
dateOfBirth: [child.dateOfBirth ? new Date(child.dateOfBirth) : ''],
|
|
nationality: [child.nationality || 'INDIAN'],
|
|
aadhaarNumber: [child.aadhaarNumber || ''],
|
|
panNumber: [
|
|
child.panNumber || '',
|
|
Validators.pattern(/^[A-Z]{5}[0-9]{4}[A-Z]{1}$/)
|
|
]
|
|
})
|
|
);
|
|
});
|
|
} else {
|
|
this.addChild();
|
|
}
|
|
}
|
|
|
|
get children(): UntypedFormArray {
|
|
return this.childrenForm.get('children') as UntypedFormArray;
|
|
}
|
|
|
|
createChildFormGroup(): UntypedFormGroup {
|
|
return this.formBuilder.group({
|
|
id: [''],
|
|
fullName: [
|
|
'',
|
|
Validators.required
|
|
],
|
|
genderId: [
|
|
'',
|
|
Validators.required
|
|
],
|
|
dateOfBirth: [''],
|
|
nationality: ['INDIAN'],
|
|
aadhaarNumber: [''],
|
|
panNumber: [
|
|
'',
|
|
Validators.pattern(/^[A-Z]{5}[0-9]{4}[A-Z]{1}$/)
|
|
]
|
|
});
|
|
}
|
|
|
|
addChild(): void {
|
|
this.children.push(this.createChildFormGroup());
|
|
}
|
|
|
|
removeChild(index: number): void {
|
|
this.children.removeAt(index);
|
|
}
|
|
|
|
submit(): void {
|
|
if (this.childrenForm.valid) {
|
|
this.dialogRef.close(this.children.value);
|
|
}
|
|
}
|
|
}
|