personal info form changes : kdk
This commit is contained in:
parent
4e0a4bbf84
commit
22dbdf39af
@ -1,4 +1,4 @@
|
||||
<form [formGroup]="_personalForm" (submit)="submitPersonalForm(_personalForm.value)">
|
||||
<form *ngIf="loadDataStatus" [formGroup]="_personalForm" (submit)="submitPersonalForm(_personalForm.value)">
|
||||
|
||||
<!-- start main applicant details -->
|
||||
|
||||
@ -13,19 +13,19 @@
|
||||
<div [formGroup]="mainDetails">
|
||||
|
||||
<mat-form-field style="width: 100%">
|
||||
<input matInput [placeholder]="mainDetails.controls.name_ques.value" formControlName="name_ans" type="text" required>
|
||||
<input matInput placeholder="Name" formControlName="name_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
|
||||
<input matInput [placeholder]="mainDetails.controls.age_ques.value" formControlName="age_ans" type="text" required>
|
||||
<input matInput placeholder="Age" formControlName="age_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
|
||||
<input matInput [placeholder]="mainDetails.controls.entity_ques.value" formControlName="entity_ans" type="text" required>
|
||||
<input matInput placeholder="Entity" formControlName="entity_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
|
||||
<mat-select [placeholder]="mainDetails.controls.qualification_ques.value" formControlName="qualification_ans" required>
|
||||
<mat-select placeholder="Educational Qualification" formControlName="qualification_ans" required>
|
||||
<mat-option *ngFor="let education of qualifications" [value]="education" >
|
||||
{{education}}
|
||||
</mat-option>
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-select [placeholder]="mainDetails.controls.earningStatus_ques.value" formControlName="earning_ans" required>
|
||||
<mat-select placeholder="Earning Status" formControlName="earning_ans" required>
|
||||
<mat-option *ngFor="let earning of earningStatus" [value]="earning" >
|
||||
{{earning}}
|
||||
</mat-option>
|
||||
@ -61,22 +61,22 @@
|
||||
<div [formGroup]="coDetails">
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<input matInput [placeholder]="coDetails.controls.name_ques.value" formControlName="name_ans" type="text" required>
|
||||
<input matInput placeholder="Name" formControlName="name_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
|
||||
<input matInput [placeholder]="coDetails.controls.age_ques.value" formControlName="age_ans" type="text" required>
|
||||
<input matInput placeholder="Age" formControlName="age_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
|
||||
<input matInput [placeholder]="coDetails.controls.entity_ques.value" formControlName="entity_ans" type="text" required>
|
||||
<input matInput placeholder="Entity" formControlName="entity_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
|
||||
<mat-select [placeholder]="coDetails.controls.qualification_ques.value" formControlName="qualification_ans" required>
|
||||
<mat-select placeholder="Educational Qualification" formControlName="qualification_ans" required>
|
||||
<mat-option *ngFor="let education of qualifications" [value]="education" >
|
||||
{{education}}
|
||||
</mat-option>
|
||||
@ -85,7 +85,7 @@
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<mat-select [placeholder]="coDetails.controls.earningStatus_ques.value" formControlName="earning_ans" required>
|
||||
<mat-select placeholder="Earning Status" formControlName="earning_ans" required>
|
||||
<mat-option *ngFor="let earning of earningStatus" [value]="earning" >
|
||||
{{earning}}
|
||||
</mat-option>
|
||||
@ -93,7 +93,7 @@
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<mat-select [placeholder]="coDetails.controls.relationShip_ques.value" formControlName="relation_ans" required>
|
||||
<mat-select placeholder="Relationship" formControlName="relation_ans" required>
|
||||
<mat-option *ngFor="let rel of relationShipList" [value]="rel.relationship_id" >
|
||||
{{rel.name}}
|
||||
</mat-option>
|
||||
|
||||
@ -52,7 +52,7 @@ export class PersonalInfoComponent implements OnInit {
|
||||
this._pd.getPDFormDetailsWithID(this.pdid,this.form_id).subscribe(
|
||||
data => {
|
||||
if (data.status == 200) {
|
||||
|
||||
this.loadFormWithIDData(data.records);
|
||||
|
||||
}
|
||||
else if(data.status == 204){
|
||||
@ -85,7 +85,48 @@ export class PersonalInfoComponent implements OnInit {
|
||||
|
||||
}
|
||||
}, error => this.errorMessage = <any> error);
|
||||
}
|
||||
}
|
||||
|
||||
loadDataStatus: boolean;
|
||||
|
||||
loadFormWithIDData(data) {
|
||||
var main_result = Object.keys(data.main_applicant_details).map(function(key) {
|
||||
return data.main_applicant_details[key];
|
||||
});
|
||||
var co_result = Object.keys(data.co_applicant_details).map(function(key) {
|
||||
return data.co_applicant_details[key];
|
||||
});
|
||||
|
||||
// main applicant
|
||||
let mainApplicantGroup = new FormArray(main_result.map((item,key) => new FormGroup({
|
||||
name_ans:new FormControl(item.name_ans, Validators.required),
|
||||
age_ans:new FormControl(item.age_ans, Validators.required),
|
||||
entity_ans:new FormControl(item.entity_ans, Validators.required),
|
||||
qualification_ans:new FormControl(item.qualification_ans, Validators.required),
|
||||
earning_ans:new FormControl(item.earning_ans, Validators.required),
|
||||
})));
|
||||
// co applicant
|
||||
let iterateCoApp=[];
|
||||
|
||||
let coApplicantGroup = new FormArray(co_result.map((item,key) => new FormGroup({
|
||||
name_ans:new FormControl(item.name_ans, Validators.required),
|
||||
age_ans:new FormControl(item.age_ans, Validators.required),
|
||||
entity_ans:new FormControl(item.entity_ans, Validators.required),
|
||||
qualification_ans:new FormControl(item.qualification_ans, Validators.required),
|
||||
earning_ans:new FormControl(item.earning_ans, Validators.required),
|
||||
relation_ans:new FormControl(item.relation_ans, Validators.required),
|
||||
|
||||
})));
|
||||
|
||||
this._personalForm = this._fb.group({
|
||||
pdid:null,
|
||||
form_id:null,
|
||||
mainItem: mainApplicantGroup,
|
||||
coItem: coApplicantGroup,
|
||||
});
|
||||
//console.log(this._personalForm);
|
||||
this.loadDataStatus = true;
|
||||
}
|
||||
|
||||
loadFormData(mainApp,coApp){
|
||||
// main applicant
|
||||
@ -139,7 +180,7 @@ export class PersonalInfoComponent implements OnInit {
|
||||
coItem: coApplicantGroup,
|
||||
});
|
||||
//console.log(this._personalForm);
|
||||
|
||||
this.loadDataStatus = true;
|
||||
}
|
||||
|
||||
//get pd main applicant array values
|
||||
@ -163,11 +204,12 @@ export class PersonalInfoComponent implements OnInit {
|
||||
// submit forms details
|
||||
submitPersonalForm(formData:any) {
|
||||
if(this._personalForm.valid){
|
||||
let applicantDetails:any=[];
|
||||
let main_applicantDetails:any=[];
|
||||
let co_applicantDetails:any=[];
|
||||
|
||||
formData.mainItem.forEach((element,key) => {
|
||||
if(key==0){
|
||||
applicantDetails.push({
|
||||
main_applicantDetails.push({
|
||||
"name_ans":element.name_ans,
|
||||
"age_ans":element.age_ans,
|
||||
"entity_ans":element.entity_ans,
|
||||
@ -178,7 +220,7 @@ submitPersonalForm(formData:any) {
|
||||
|
||||
});
|
||||
formData.coItem.forEach((Coelement,Cokey) => {
|
||||
applicantDetails.push({
|
||||
co_applicantDetails.push({
|
||||
|
||||
"name_ans":Coelement.name_ans,
|
||||
"age_ans":Coelement.age_ans,
|
||||
@ -193,7 +235,8 @@ submitPersonalForm(formData:any) {
|
||||
let save_details:any={
|
||||
"pdid": this.pdid,
|
||||
"formid": this.form_id,
|
||||
"applicant_details":applicantDetails
|
||||
"main_applicant_details":main_applicantDetails,
|
||||
"co_applicant_details":co_applicantDetails
|
||||
};
|
||||
this._pd.savePDFormDetailsWithID(save_details).subscribe(result => {
|
||||
if (result.status == 200) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user