Merge branch 'master' of https://bitbucket.org/sriramv18/sparqsineedge
This commit is contained in:
commit
c62d273c7a
@ -1,138 +1,142 @@
|
|||||||
<mat-card style="padding: 12px;">
|
<mat-card style="padding: 12px;">
|
||||||
<p>Personal Details</p>
|
<p>Personal Details</p>
|
||||||
<form *ngIf="loadDataStatus" [formGroup]="_personalForm" (submit)="submitPersonalForm(_personalForm.value)" novalidate>
|
<form *ngIf="loadDataStatus" [formGroup]="_personalForm" (submit)="submitPersonalForm(_personalForm.value)" novalidate>
|
||||||
|
<!-- start main applicant -->
|
||||||
|
<mat-card>
|
||||||
|
<mat-card-title>Main Applicant</mat-card-title>
|
||||||
|
<mat-card-content formArrayName="main_applicant_details">
|
||||||
|
<div *ngFor="let mainDetails of _personalForm.controls.main_applicant_details['controls']; let i = index;" [formGroupName]="i">
|
||||||
|
|
||||||
<mat-card-content>
|
<mat-form-field style="width: 35%">
|
||||||
<!-- start main applicant details -->
|
<input matInput placeholder="Name" formControlName="name_ans" type="text" required>
|
||||||
|
|
||||||
<div fxLayout="row wrap">
|
|
||||||
|
|
||||||
<div fxFlex="50" class="text-xs-left">
|
|
||||||
|
|
||||||
<mat-card>
|
|
||||||
<mat-card-title>Main Applicant</mat-card-title>
|
|
||||||
<mat-card-content>
|
|
||||||
<div [formArrayName]="'mainItem'" *ngFor="let mainDetails of pdMainapplicant.controls; let i = index;">
|
|
||||||
<div [formGroup]="mainDetails">
|
|
||||||
|
|
||||||
<mat-form-field style="width: 100%">
|
|
||||||
<input matInput placeholder="Name" formControlName="name_ans" type="text" required>
|
|
||||||
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field style="width: 100%">
|
<mat-form-field style="width: 10%">
|
||||||
|
|
||||||
|
<input matInput placeholder="Age" formControlName="age_ans" type="text" required (keypress)="keyPress($event)">
|
||||||
|
<mat-error *ngIf="mainDetails['controls'].age_ans.hasError('pattern') || mainDetails['controls'].age_ans.hasError('maxlength') || mainDetails['controls'].age_ans.hasError('minlength')">Enter Valid Age. </mat-error>
|
||||||
|
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 42%">
|
||||||
|
|
||||||
|
<input matInput placeholder="Entity" formControlName="entity_ans" type="text" required>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 49%">
|
||||||
|
<mat-select placeholder="Earning Status" formControlName="earning_ans" required>
|
||||||
|
<mat-option *ngFor="let earning of earningStatus" [value]="earning.earning_member_status_id" >
|
||||||
|
{{earning.earning_member_status}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 42%">
|
||||||
|
|
||||||
|
<mat-select placeholder="Educational Qualification" formControlName="qualification_ans" required>
|
||||||
|
<mat-option *ngFor="let education of qualifications" [value]="education.qualification_id" >
|
||||||
|
{{education.qualification_name}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<input matInput placeholder="Age" formControlName="age_ans" type="text" required (keypress)="keyPress($event)">
|
</mat-card-content>
|
||||||
<mat-error *ngIf="mainDetails['controls'].age_ans.hasError('pattern') || mainDetails['controls'].age_ans.hasError('maxlength') || mainDetails['controls'].age_ans.hasError('minlength')">Enter Valid Age. </mat-error>
|
</mat-card>
|
||||||
|
<!-- end main applicant -->
|
||||||
|
|
||||||
|
<!-- start co applicant form details -->
|
||||||
|
<mat-card>
|
||||||
|
<mat-card-title>Co Applicant</mat-card-title>
|
||||||
|
<mat-card-content formArrayName="co_applicant_details">
|
||||||
|
<mat-card *ngFor="let coDetails of _personalForm.controls.co_applicant_details['controls']; let c = index;" [formGroupName]="c">
|
||||||
|
<mat-card-content>
|
||||||
|
<mat-form-field style="width: 20%">
|
||||||
|
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||||
|
<input matInput placeholder="Name" formControlName="name_ans" type="text" required>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 10%">
|
||||||
|
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||||
|
|
||||||
|
<input matInput placeholder="Age" formControlName="age_ans" type="text" required>
|
||||||
|
<mat-error *ngIf="coDetails['controls'].age_ans.hasError('pattern') || coDetails['controls'].age_ans.hasError('maxlength') || coDetails['controls'].age_ans.hasError('minlength')">Enter Valid Age. </mat-error>
|
||||||
|
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 20%">
|
||||||
|
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||||
|
|
||||||
|
<input matInput placeholder="Entity" formControlName="entity_ans" type="text" required>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 34%">
|
||||||
|
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||||
|
<mat-select placeholder="Earning Status" formControlName="earning_ans" required>
|
||||||
|
<mat-option *ngFor="let earning of earningStatus" [value]="earning.earning_member_status_id" >
|
||||||
|
{{earning.earning_member_status}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field style="width: 100%">
|
<mat-form-field style="width: 34%">
|
||||||
|
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||||
<input matInput placeholder="Entity" formControlName="entity_ans" type="text" required>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field style="width: 100%">
|
|
||||||
|
|
||||||
<mat-select placeholder="Educational Qualification" formControlName="qualification_ans" required>
|
|
||||||
<mat-option *ngFor="let education of qualifications" [value]="education.qualification_id" >
|
|
||||||
{{education.qualification_name}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field style="width: 100%">
|
|
||||||
<mat-select placeholder="Earning Status" formControlName="earning_ans" required>
|
|
||||||
<mat-option *ngFor="let earning of earningStatus" [value]="earning.earning_member_status_id" >
|
|
||||||
{{earning.earning_member_status}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- end main applicant details -->
|
<mat-select placeholder="Educational Qualification" formControlName="qualification_ans" required>
|
||||||
|
<mat-option *ngFor="let education of qualifications" [value]="education.qualification_id" >
|
||||||
<!-- start co applicant form details -->
|
{{education.qualification_name}}
|
||||||
<div fxFlex="50" class="text-xs-left" [formArrayName]="'coItem'" *ngFor="let coDetails of pdCoapplicant.controls; let i = index;">
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
<mat-card>
|
|
||||||
<mat-card-title>Co Applicant</mat-card-title>
|
</mat-form-field>
|
||||||
<mat-card-content>
|
|
||||||
<div >
|
|
||||||
<div [formGroup]="coDetails">
|
<mat-form-field style="width: 48%">
|
||||||
<mat-form-field style="width: 100%">
|
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
<mat-select placeholder="Relationship With Main Applicant" formControlName="relation_ans" required>
|
||||||
<input matInput placeholder="Name" formControlName="name_ans" type="text" required>
|
<mat-option *ngFor="let rel of relationShipList" [value]="rel.relationship_id" >
|
||||||
</mat-form-field>
|
{{rel.name}}
|
||||||
<mat-form-field style="width: 100%">
|
</mat-option>
|
||||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
<input matInput placeholder="Age" formControlName="age_ans" type="text" required>
|
<button type="button" mat-raised-button mat-icon-button (click)="removeCoApplicant(c)"
|
||||||
<mat-error *ngIf="coDetails['controls'].age_ans.hasError('pattern') || coDetails['controls'].age_ans.hasError('maxlength') || coDetails['controls'].age_ans.hasError('minlength')">Enter Valid Age. </mat-error>
|
matTooltip="Remove Co Applicant" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="coDetails.controls.current_added_status.value==1">
|
||||||
|
<mat-icon>delete</mat-icon>
|
||||||
</mat-form-field>
|
</button>
|
||||||
<mat-form-field style="width: 100%">
|
|
||||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
|
||||||
|
|
||||||
<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="Educational Qualification" formControlName="qualification_ans" required>
|
|
||||||
<mat-option *ngFor="let education of qualifications" [value]="education.qualification_id" >
|
|
||||||
{{education.qualification_name}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
|
|
||||||
</mat-form-field>
|
</mat-card-content>
|
||||||
<mat-form-field style="width: 100%">
|
|
||||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
|
||||||
<mat-select placeholder="Earning Status" formControlName="earning_ans" required>
|
|
||||||
<mat-option *ngFor="let earning of earningStatus" [value]="earning.earning_member_status_id" >
|
|
||||||
{{earning.earning_member_status}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field style="width: 100%">
|
|
||||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
|
||||||
<mat-select placeholder="Relationship With Main Applicant" formControlName="relation_ans" required>
|
|
||||||
<mat-option *ngFor="let rel of relationShipList" [value]="rel.relationship_id" >
|
|
||||||
{{rel.name}}
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</mat-card-content>
|
|
||||||
|
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</mat-card-content>
|
||||||
|
<mat-card-actions align="end">
|
||||||
</div>
|
<button type="button" mat-raised-button mat-icon-button (click)="addCoApplicant()"
|
||||||
|
matTooltip="Add More Co Applicant" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary">
|
||||||
|
<mat-icon>add</mat-icon>
|
||||||
|
</button>
|
||||||
|
|
||||||
<div fxLayout="row">
|
</mat-card-actions>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- end co apllicant -->
|
||||||
|
|
||||||
|
<!-- <div fxLayout="row">
|
||||||
<div fxFlex="60" class="pb-0 text-sm-left">
|
<div fxFlex="60" class="pb-0 text-sm-left">
|
||||||
<mat-form-field appearance="outline" style="width: 100%">
|
<mat-form-field appearance="outline" style="width: 100%">
|
||||||
<mat-label>Remarks</mat-label>
|
<mat-label>Remarks</mat-label>
|
||||||
<textarea matInput placeholder="Remarks" formControlName="personal_info_form_remark" required></textarea>
|
<textarea matInput placeholder="Remarks" formControlName="personal_info_form_remark" required></textarea>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
<!-- end co applicant form details -->
|
<!-- end co applicant form details -->
|
||||||
</mat-card-content>
|
<!-- </mat-card-content> -->
|
||||||
|
|
||||||
<mat-card-actions>
|
<mat-card-actions>
|
||||||
<div fxFlexOffset="90" fxFlex="10" style="text-align:left;">
|
<div fxFlex="60" class="pb-0 text-sm-left" align="left">
|
||||||
|
<mat-form-field appearance="outline" style="width: 100%">
|
||||||
|
<mat-label>Remarks</mat-label>
|
||||||
|
<textarea matInput placeholder="Remarks" formControlName="personal_info_form_remark" required></textarea>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div fxFlex="40" align="end">
|
||||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="submit" matTooltip="Save" matTooltipPosition="above"><mat-icon>save</mat-icon></button>
|
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="submit" matTooltip="Save" matTooltipPosition="above"><mat-icon>save</mat-icon></button>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-actions>
|
</mat-card-actions>
|
||||||
|
|||||||
@ -3,4 +3,9 @@
|
|||||||
}
|
}
|
||||||
.mat-card-actions {
|
.mat-card-actions {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mat-form-field {
|
||||||
|
margin: 0 2%;
|
||||||
|
}
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ export class PersonalInfoComponent implements OnInit {
|
|||||||
|
|
||||||
//qualifications:any=["Graduate","Under Graduate","Post Graduate","Professional"];
|
//qualifications:any=["Graduate","Under Graduate","Post Graduate","Professional"];
|
||||||
//earningStatus:any=["Earning Member","House Wife","Student","Retired","Pensioner","Other Non earning member"];
|
//earningStatus:any=["Earning Member","House Wife","Student","Retired","Pensioner","Other Non earning member"];
|
||||||
|
loadDataStatus: boolean=true;
|
||||||
earningStatus:any=[];
|
earningStatus:any=[];
|
||||||
qualifications:any=[];
|
qualifications:any=[];
|
||||||
relationShipList:any=[];
|
relationShipList:any=[];
|
||||||
@ -25,15 +26,26 @@ export class PersonalInfoComponent implements OnInit {
|
|||||||
|
|
||||||
public mainApplicantQuestions : any = ["Name","Age","Entity","Educational Qualification","Earning Status"];
|
public mainApplicantQuestions : any = ["Name","Age","Entity","Educational Qualification","Earning Status"];
|
||||||
public coApplicantQuestions : any = ["Name","Age","Entity","Educational Qualification","Earning Status","Relationship"];
|
public coApplicantQuestions : any = ["Name","Age","Entity","Educational Qualification","Earning Status","Relationship"];
|
||||||
|
public const_main_applicant : any = {
|
||||||
|
"name_ans": '',
|
||||||
|
"age_ans":'',
|
||||||
|
"earning_ans": '',
|
||||||
|
"entity_ans": '',
|
||||||
|
"qualification_ans": '',
|
||||||
|
"current_added_status":1
|
||||||
|
};
|
||||||
|
public const_co_applicant : any = {
|
||||||
|
"name_ans": '',
|
||||||
|
"age_ans":'',
|
||||||
|
"earning_ans": '',
|
||||||
|
"entity_ans": '',
|
||||||
|
"qualification_ans": '',
|
||||||
|
"relation_ans": '',
|
||||||
|
"current_added_status":1
|
||||||
|
};
|
||||||
public mainApplicantDetails :any=[];
|
public mainApplicantDetails :any=[];
|
||||||
public coApplicantDetails :any=[];
|
public coApplicantDetails :any=[];
|
||||||
|
|
||||||
errorMessage:any;
|
errorMessage:any;
|
||||||
//coItem:any;
|
|
||||||
//mainItem:any;
|
|
||||||
|
|
||||||
repeat:number=3;
|
|
||||||
|
|
||||||
constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService) {
|
constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService) {
|
||||||
this.notifier = notifier;
|
this.notifier = notifier;
|
||||||
@ -41,7 +53,8 @@ export class PersonalInfoComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.loadPDDetails(this.pdid,this.form_id);
|
this.initFormDetails()
|
||||||
|
this.loadPDDetails();
|
||||||
this.getMasterDetails('RELATIONSHIPS',1);
|
this.getMasterDetails('RELATIONSHIPS',1);
|
||||||
this.getMasterDetails('EARNINGMEMBERSSTATUS',2);
|
this.getMasterDetails('EARNINGMEMBERSSTATUS',2);
|
||||||
this.getMasterDetails('EDUQUALIFICATION',3);
|
this.getMasterDetails('EDUQUALIFICATION',3);
|
||||||
@ -51,155 +64,71 @@ export class PersonalInfoComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load form pd details
|
// load form pd details
|
||||||
loadPDDetails(pd:string,form:number){
|
loadPDDetails(){
|
||||||
|
|
||||||
this._pd.getPDFormDetailsWithID(this.pdid,this.form_id).subscribe(
|
this._pd.getPDFormDetailsWithID(this.pdid,this.form_id).subscribe(
|
||||||
data => {
|
data => {
|
||||||
if (data.status == 200) {
|
const mainValue = <FormArray>this._personalForm.controls['main_applicant_details'];
|
||||||
this.loadFormWithIDData(data.records);
|
const coValue = <FormArray>this._personalForm.controls['co_applicant_details'];
|
||||||
|
mainValue.controls = [];
|
||||||
|
coValue.controls = [];
|
||||||
|
if (data.dataStatus == true) {
|
||||||
|
let retriveData = data.records;
|
||||||
|
this._personalForm.controls['personal_info_form_remark'].setValue(data.records.personal_info_form_remark ? data.records.personal_info_form_remark : '');
|
||||||
|
let pullMainApplicant = Object.keys(data.records.main_applicant_details).map(function(key) {
|
||||||
|
return data.records.main_applicant_details[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (pullMainApplicant.length > 0) {
|
||||||
|
pullMainApplicant.forEach(val => {
|
||||||
|
val.current_added_status=0
|
||||||
|
mainValue.push(this.loadMainApplicant(val));
|
||||||
|
});
|
||||||
|
// retriveData.main_applicant_details = pullMainApplicant;
|
||||||
|
} else {
|
||||||
|
mainValue.push(this.loadMainApplicant(this.const_main_applicant));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.records.co_applicant_details){
|
||||||
|
let pullCoApplicant = Object.keys(data.records.co_applicant_details).map(function(key) {
|
||||||
|
return data.records.co_applicant_details[key];
|
||||||
|
});
|
||||||
|
if (pullCoApplicant.length > 0) {
|
||||||
|
pullCoApplicant.forEach(val => {
|
||||||
|
val.current_added_status=0
|
||||||
|
coValue.push(this.loadCoApplicant(val));
|
||||||
|
});
|
||||||
|
// retriveData.co_applicant_details = pullCoApplicant;
|
||||||
|
} else {
|
||||||
|
coValue.push(this.loadCoApplicant(this.const_co_applicant));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
coValue.push(this.loadCoApplicant(this.const_co_applicant));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(data.status == 204){
|
else if(data.dataStatus == false){
|
||||||
|
this.mainApplicantDetails.forEach(item => {
|
||||||
this.loadFormData();
|
item.current_added_status=0
|
||||||
|
mainValue.push(this.loadDefaultMainApplicant(item))
|
||||||
|
});
|
||||||
|
|
||||||
|
// check co applicant
|
||||||
}
|
if(this.coApplicantDetails.length > 0){
|
||||||
|
this.coApplicantDetails.forEach(coItem => {
|
||||||
|
coItem.current_added_status=0
|
||||||
|
coValue.push(this.loadDefaultCoApplicant(coItem)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
coValue.push(this.loadCoApplicant(this.const_co_applicant))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}, error => this.errorMessage = <any> error);
|
}, error => this.errorMessage = <any> error);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadDataStatus: boolean;
|
|
||||||
|
|
||||||
loadFormWithIDData(data) {
|
|
||||||
// main applicant
|
|
||||||
var main_result = Object.keys(data.main_applicant_details).map(function(key) {
|
|
||||||
return data.main_applicant_details[key];
|
|
||||||
});
|
|
||||||
|
|
||||||
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.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])),
|
|
||||||
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 coApplicantGroup;
|
|
||||||
if(data.co_applicant_details!=undefined){
|
|
||||||
var co_result = Object.keys(data.co_applicant_details).map(function(key) {
|
|
||||||
return data.co_applicant_details[key];
|
|
||||||
});
|
|
||||||
|
|
||||||
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.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])),
|
|
||||||
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),
|
|
||||||
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
coApplicantGroup = new FormArray(this.coApplicantDetails.map((item,key) => new FormGroup({
|
|
||||||
name_ques:new FormControl(this.coApplicantQuestions[0]),
|
|
||||||
name_ans:new FormControl(item.applicant_name, Validators.required),
|
|
||||||
name_id:new FormControl(0),
|
|
||||||
age_ques:new FormControl(this.coApplicantQuestions[1]),
|
|
||||||
age_id:new FormControl(1),
|
|
||||||
age_ans:new FormControl(null, Validators.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])),
|
|
||||||
entity_ques: new FormControl(this.coApplicantQuestions[2]),
|
|
||||||
entity_id: new FormControl(2),
|
|
||||||
entity_ans:new FormControl(this.pd_all_details.pdmaster_details.customer_segment_abbr.substring(0,3).toUpperCase()==='SAL' ? 'Individual' : '', Validators.required),
|
|
||||||
qualification_ques: new FormControl(this.coApplicantQuestions[3]),
|
|
||||||
qualification_id: new FormControl(3),
|
|
||||||
qualification_ans:new FormControl(null, Validators.required),
|
|
||||||
earningStatus_ques:new FormControl(this.coApplicantQuestions[4]),
|
|
||||||
earning_id: new FormControl(4),
|
|
||||||
earning_ans:new FormControl(null, Validators.required),
|
|
||||||
relationShip_ques:new FormControl(this.coApplicantQuestions[5]),
|
|
||||||
relation_id:new FormControl(5),
|
|
||||||
relation_ans:new FormControl(null, Validators.required),
|
|
||||||
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this._personalForm = this._fb.group({
|
|
||||||
pdid:null,
|
|
||||||
form_id:null,
|
|
||||||
mainItem: mainApplicantGroup,
|
|
||||||
coItem: coApplicantGroup,
|
|
||||||
personal_info_form_remark: [data.personal_info_form_remark]
|
|
||||||
});
|
|
||||||
//console.log(this._personalForm);
|
|
||||||
this.loadDataStatus = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
loadFormData(){
|
|
||||||
|
|
||||||
// main applicant
|
|
||||||
let mainApplicantGroup = new FormArray(this.mainApplicantDetails.map((item,key) => new FormGroup({
|
|
||||||
name_ques:new FormControl(this.mainApplicantQuestions[0]),
|
|
||||||
name_ans:new FormControl(item.applicant_name, Validators.required),
|
|
||||||
name_id:new FormControl(0),
|
|
||||||
age_ques:new FormControl(this.mainApplicantQuestions[1]),
|
|
||||||
age_id:new FormControl(1),
|
|
||||||
age_ans:new FormControl(null, Validators.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])),
|
|
||||||
entity_ques: new FormControl(this.mainApplicantQuestions[2]),
|
|
||||||
entity_id: new FormControl(2),
|
|
||||||
entity_ans:new FormControl(this.pd_all_details.pdmaster_details.customer_segment_abbr.substring(0,3).toUpperCase()==='SAL' ? 'Individual' : '', Validators.required),
|
|
||||||
qualification_ques: new FormControl(this.mainApplicantQuestions[3]),
|
|
||||||
qualification_id: new FormControl(3),
|
|
||||||
qualification_ans:new FormControl(null, Validators.required),
|
|
||||||
earningStatus_ques:new FormControl(this.mainApplicantQuestions[4]),
|
|
||||||
earning_id: new FormControl(4),
|
|
||||||
earning_ans:new FormControl(null, Validators.required),
|
|
||||||
|
|
||||||
})));
|
|
||||||
// co applicant
|
|
||||||
let coApplicantGroup = new FormArray(this.coApplicantDetails.map((item,key) => new FormGroup({
|
|
||||||
name_ques:new FormControl(this.coApplicantQuestions[0]),
|
|
||||||
name_ans:new FormControl(item.applicant_name, Validators.required),
|
|
||||||
name_id:new FormControl(0),
|
|
||||||
age_ques:new FormControl(this.coApplicantQuestions[1]),
|
|
||||||
age_id:new FormControl(1),
|
|
||||||
age_ans:new FormControl(null, Validators.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])),
|
|
||||||
entity_ques: new FormControl(this.coApplicantQuestions[2]),
|
|
||||||
entity_id: new FormControl(2),
|
|
||||||
entity_ans:new FormControl(this.pd_all_details.pdmaster_details.customer_segment_abbr.substring(0,3).toUpperCase()==='SAL' ? 'Individual' : '', Validators.required),
|
|
||||||
qualification_ques: new FormControl(this.coApplicantQuestions[3]),
|
|
||||||
qualification_id: new FormControl(3),
|
|
||||||
qualification_ans:new FormControl(null, Validators.required),
|
|
||||||
earningStatus_ques:new FormControl(this.coApplicantQuestions[4]),
|
|
||||||
earning_id: new FormControl(4),
|
|
||||||
earning_ans:new FormControl(null, Validators.required),
|
|
||||||
relationShip_ques:new FormControl(this.coApplicantQuestions[5]),
|
|
||||||
relation_id:new FormControl(5),
|
|
||||||
relation_ans:new FormControl(null, Validators.required),
|
|
||||||
|
|
||||||
})));
|
|
||||||
|
|
||||||
this._personalForm = this._fb.group({
|
|
||||||
pdid:null,
|
|
||||||
form_id:null,
|
|
||||||
mainItem: mainApplicantGroup,
|
|
||||||
coItem: coApplicantGroup,
|
|
||||||
personal_info_form_remark:null
|
|
||||||
});
|
|
||||||
//console.log(this._personalForm);
|
|
||||||
this.loadDataStatus = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//get pd main applicant array values
|
|
||||||
get pdMainapplicant() { return this._personalForm.get('mainItem') as FormArray; }
|
|
||||||
|
|
||||||
// get pd co applicant array values
|
|
||||||
get pdCoapplicant() {return this._personalForm.get('coItem') as FormArray;}
|
|
||||||
|
|
||||||
// get all master details
|
// get all master details
|
||||||
getMasterDetails(table:string,type:number){
|
getMasterDetails(table:string,type:number){
|
||||||
this._pd.getAllMasterDatas(table).subscribe(
|
this._pd.getAllMasterDatas(table).subscribe(
|
||||||
@ -219,7 +148,92 @@ this.loadDataStatus = true;
|
|||||||
}
|
}
|
||||||
}, error => this.errorMessage = <any> error);
|
}, error => this.errorMessage = <any> error);
|
||||||
}
|
}
|
||||||
// submit forms details
|
|
||||||
|
|
||||||
|
/** On Key Press Event For Mobile Number */
|
||||||
|
keyPress(event: any) {
|
||||||
|
const pattern = /[0-9]/;
|
||||||
|
|
||||||
|
let inputChar = String.fromCharCode(event.charCode);
|
||||||
|
if (event.keyCode != 8 && !pattern.test(inputChar)) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// init form details
|
||||||
|
public initFormDetails(): void {
|
||||||
|
this._personalForm = this._fb.group({
|
||||||
|
pdid:this.pdid,
|
||||||
|
formid:this.form_id,
|
||||||
|
main_applicant_details: this._fb.array([]),
|
||||||
|
co_applicant_details: this._fb.array([]),
|
||||||
|
personal_info_form_remark:null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// add more co applicant details
|
||||||
|
addCoApplicant() {
|
||||||
|
const control = <FormArray>this._personalForm.controls['co_applicant_details'];
|
||||||
|
control.push(this.loadCoApplicant(this.const_co_applicant));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove co applicant details
|
||||||
|
removeCoApplicant(renoveIndex) {
|
||||||
|
const remove_control = <FormArray>this._personalForm.controls['co_applicant_details'];
|
||||||
|
remove_control.removeAt(renoveIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
// load main applicant
|
||||||
|
loadMainApplicant(applicant:any) {
|
||||||
|
return this._fb.group({
|
||||||
|
name_ans: [applicant.name_ans, Validators.required],
|
||||||
|
age_ans: [applicant.age_ans, Validators.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])],
|
||||||
|
entity_ans: [applicant.entity_ans, Validators.required],
|
||||||
|
qualification_ans: [applicant.qualification_ans, Validators.required],
|
||||||
|
earning_ans: [applicant.earning_ans, Validators.required],
|
||||||
|
current_added_status: [applicant.current_added_status],
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
// load co applicant
|
||||||
|
loadCoApplicant(applicant:any) {
|
||||||
|
return this._fb.group({
|
||||||
|
name_ans: [applicant.name_ans, Validators.required],
|
||||||
|
age_ans: [applicant.age_ans, Validators.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])],
|
||||||
|
entity_ans: [applicant.entity_ans, Validators.required],
|
||||||
|
qualification_ans: [applicant.qualification_ans, Validators.required],
|
||||||
|
earning_ans: [applicant.earning_ans, Validators.required],
|
||||||
|
relation_ans: [applicant.relation_ans, Validators.required],
|
||||||
|
current_added_status: [applicant.current_added_status],
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
// load default main applicant form data
|
||||||
|
loadDefaultMainApplicant(applicant:any){
|
||||||
|
return this._fb.group({
|
||||||
|
name_ans: [applicant.applicant_name, Validators.required],
|
||||||
|
age_ans: ['', Validators.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])],
|
||||||
|
entity_ans: [this.pd_all_details.pdmaster_details.customer_segment_abbr.substring(0,3).toUpperCase()==='SAL' ? 'Individual' : '', Validators.required],
|
||||||
|
qualification_ans: ['', Validators.required],
|
||||||
|
earning_ans: ['', Validators.required],
|
||||||
|
current_added_status: [applicant.current_added_status],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// load co applicant details
|
||||||
|
loadDefaultCoApplicant(applicant:any){
|
||||||
|
return this._fb.group({
|
||||||
|
name_ans: [applicant.applicant_name, Validators.required],
|
||||||
|
age_ans: ['', Validators.compose([Validators.required,Validators.minLength(1),Validators.maxLength(3),Validators.required,Validators.pattern('^[0-9]*$')])],
|
||||||
|
entity_ans: [this.pd_all_details.pdmaster_details.customer_segment_abbr.substring(0,3).toUpperCase()==='SAL' ? 'Individual' : '', Validators.required],
|
||||||
|
qualification_ans: ['', Validators.required],
|
||||||
|
earning_ans: ['', Validators.required],
|
||||||
|
relation_ans: ['', Validators.required],
|
||||||
|
current_added_status: [applicant.current_added_status],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// submit forms details
|
||||||
submitPersonalForm(formData:any) {
|
submitPersonalForm(formData:any) {
|
||||||
if (this._personalForm.invalid) {
|
if (this._personalForm.invalid) {
|
||||||
this.validateAllFormFields(this._personalForm);
|
this.validateAllFormFields(this._personalForm);
|
||||||
@ -231,8 +245,8 @@ submitPersonalForm(formData:any) {
|
|||||||
else{
|
else{
|
||||||
let main_applicantDetails:any=[];
|
let main_applicantDetails:any=[];
|
||||||
let co_applicantDetails:any=[];
|
let co_applicantDetails:any=[];
|
||||||
|
let new_co_applicant:any=[];
|
||||||
formData.mainItem.forEach((element,key) => {
|
formData.main_applicant_details.forEach((element,key) => {
|
||||||
if(key==0){
|
if(key==0){
|
||||||
main_applicantDetails.push({
|
main_applicantDetails.push({
|
||||||
"name_ans":element.name_ans,
|
"name_ans":element.name_ans,
|
||||||
@ -244,9 +258,8 @@ submitPersonalForm(formData:any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
formData.coItem.forEach((Coelement,Cokey) => {
|
formData.co_applicant_details.forEach((Coelement,Cokey) => {
|
||||||
co_applicantDetails.push({
|
co_applicantDetails.push({
|
||||||
|
|
||||||
"name_ans":Coelement.name_ans,
|
"name_ans":Coelement.name_ans,
|
||||||
"age_ans":Coelement.age_ans,
|
"age_ans":Coelement.age_ans,
|
||||||
"qualification_ans":Coelement.qualification_ans,
|
"qualification_ans":Coelement.qualification_ans,
|
||||||
@ -254,29 +267,64 @@ submitPersonalForm(formData:any) {
|
|||||||
"earning_ans":Coelement.earning_ans,
|
"earning_ans":Coelement.earning_ans,
|
||||||
"relation_ans":Coelement.relation_ans,
|
"relation_ans":Coelement.relation_ans,
|
||||||
})
|
})
|
||||||
|
// get new co applicant list for applicant table
|
||||||
|
if(Coelement.current_added_status==1){
|
||||||
|
new_co_applicant.push({
|
||||||
|
"fk_pd_id": this.pdid,
|
||||||
|
"pd_co_applicant_id": '',
|
||||||
|
"applicant_name":Coelement.name_ans,
|
||||||
|
"relation":Coelement.relation_ans,
|
||||||
|
"email":'',
|
||||||
|
"mobile_no":'',
|
||||||
|
"landline":'',
|
||||||
|
"applicant_type":0,
|
||||||
|
"isactive":1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
let save_details:any={
|
||||||
let save_details:any={
|
"pdid": this.pdid,
|
||||||
"pdid": this.pdid,
|
"formid": this.form_id,
|
||||||
"formid": this.form_id,
|
"main_applicant_details":main_applicantDetails,
|
||||||
"main_applicant_details":main_applicantDetails,
|
"co_applicant_details":co_applicantDetails,
|
||||||
"co_applicant_details":co_applicantDetails,
|
"personal_info_form_remark": this._personalForm.get('personal_info_form_remark').value
|
||||||
"personal_info_form_remark": this._personalForm.get('personal_info_form_remark').value
|
};
|
||||||
};
|
if(new_co_applicant.length > 0){
|
||||||
this._pd.savePDFormDetailsWithID(save_details).subscribe(result => {
|
this._pd.updatePdApplicant(new_co_applicant).subscribe(result => {
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
this.notifier.notify('success', 'Success.');
|
this.questionsSubmitCheck(save_details);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
}
|
}
|
||||||
}, error => {
|
}, error => {
|
||||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.questionsSubmitCheck(save_details);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// submit and check all questions
|
||||||
|
questionsSubmitCheck(questionAns: any) {
|
||||||
|
this._pd.savePDFormDetailsWithID(questionAns).subscribe(result => {
|
||||||
|
if (result.status == 200) {
|
||||||
|
this.notifier.notify('success', 'Success.');
|
||||||
|
this.loadPDDetails();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
}
|
||||||
|
}, error => {
|
||||||
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// validate all form group and form array fields
|
// validate all form group and form array fields
|
||||||
validateAllFormFields(formGroup: any) {
|
validateAllFormFields(formGroup: any) {
|
||||||
Object.keys(formGroup.controls).forEach(field => {
|
Object.keys(formGroup.controls).forEach(field => {
|
||||||
@ -290,16 +338,7 @@ validateAllFormFields(formGroup: any) {
|
|||||||
this.validateAllFormFields(control);
|
this.validateAllFormFields(control);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** On Key Press Event For Mobile Number */
|
|
||||||
keyPress(event: any) {
|
|
||||||
const pattern = /[0-9]/;
|
|
||||||
|
|
||||||
let inputChar = String.fromCharCode(event.charCode);
|
|
||||||
if (event.keyCode != 8 && !pattern.test(inputChar)) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user