personal discussion changes
This commit is contained in:
parent
5425dc72de
commit
bf2ed84d30
@ -1,4 +1,4 @@
|
||||
<form [formGroup]="_personalForm">
|
||||
<form [formGroup]="_personalForm" (submit)="submitPersonalForm(_personalForm.value)">
|
||||
|
||||
<!-- start main applicant details -->
|
||||
|
||||
@ -12,38 +12,33 @@
|
||||
<div [formArrayName]="'mainItem'" *ngFor="let mainDetails of pdMainapplicant.controls; let i = index;">
|
||||
<div [formGroup]="mainDetails">
|
||||
|
||||
<mat-form-field style="width: 100%" *ngIf="mainDetails.controls.pd_question_type.value==0">
|
||||
<!-- <mat-label>{{mainDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<input matInput [placeholder]="mainDetails.controls.pd_question.value" formControlName="pd_answer" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="mainDetails.controls.pd_question_type.value==1">
|
||||
<!-- <mat-label>{{mainDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<mat-form-field style="width: 100%">
|
||||
<input matInput [placeholder]="mainDetails.controls.name_ques.value" formControlName="name_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
|
||||
<input matInput [placeholder]="mainDetails.controls.pd_question.value" formControlName="pd_answer" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="mainDetails.controls.pd_question_type.value==2">
|
||||
<!-- <mat-label>{{mainDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<input matInput [placeholder]="mainDetails.controls.age_ques.value" formControlName="age_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
|
||||
<input matInput [placeholder]="mainDetails.controls.pd_question.value" formControlName="pd_answer" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="mainDetails.controls.pd_question_type.value==3">
|
||||
<!-- <mat-label>{{mainDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<input matInput [placeholder]="mainDetails.controls.entity_ques.value" formControlName="entity_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
|
||||
<mat-select [placeholder]="mainDetails.controls.pd_question.value" formControlName="pd_answer" required>
|
||||
<mat-option *ngFor="let education of qualifications" [value]="education" >
|
||||
{{education}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-select [placeholder]="mainDetails.controls.qualification_ques.value" formControlName="qualification_ans" required>
|
||||
<mat-option *ngFor="let education of qualifications" [value]="education" >
|
||||
{{education}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="mainDetails.controls.pd_question_type.value==4">
|
||||
<!-- <mat-label>{{mainDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<mat-select [placeholder]="mainDetails.controls.pd_question.value" formControlName="pd_answer" required>
|
||||
<mat-option *ngFor="let earning of earningStatus" [value]="earning" >
|
||||
{{earning}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-select [placeholder]="mainDetails.controls.earningStatus_ques.value" formControlName="earning_ans" required>
|
||||
<mat-option *ngFor="let earning of earningStatus" [value]="earning" >
|
||||
{{earning}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -57,48 +52,48 @@
|
||||
<!-- end main applicant details -->
|
||||
|
||||
<!-- start co applicant form details -->
|
||||
<div fxFlex="50" class="text-xs-left">
|
||||
<div fxFlex="50" class="text-xs-left" [formArrayName]="'coItem'" *ngFor="let coDetails of pdCoapplicant.controls; let i = index;">
|
||||
|
||||
<mat-card>
|
||||
<mat-card-title>Co Applicant</mat-card-title>
|
||||
<mat-card-content>
|
||||
<div [formArrayName]="'coItem'" *ngFor="let coDetails of pdCoapplicant.controls; let i = index;">
|
||||
<div >
|
||||
<div [formGroup]="coDetails">
|
||||
<mat-form-field style="width: 100%" *ngIf="coDetails.controls.pd_question_type.value==0">
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<input matInput [placeholder]="coDetails.controls.pd_question.value" formControlName="pd_answer" type="text" required>
|
||||
<input matInput [placeholder]="coDetails.controls.name_ques.value" formControlName="name_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="coDetails.controls.pd_question_type.value==1">
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
|
||||
<input matInput [placeholder]="coDetails.controls.pd_question.value" formControlName="pd_answer" type="text" required>
|
||||
<input matInput [placeholder]="coDetails.controls.age_ques.value" formControlName="age_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="coDetails.controls.pd_question_type.value==2">
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
|
||||
<input matInput [placeholder]="coDetails.controls.pd_question.value" formControlName="pd_answer" type="text" required>
|
||||
<input matInput [placeholder]="coDetails.controls.entity_ques.value" formControlName="entity_ans" type="text" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="coDetails.controls.pd_question_type.value==3">
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
|
||||
<mat-select [placeholder]="coDetails.controls.pd_question.value" formControlName="pd_answer" required>
|
||||
<mat-select [placeholder]="coDetails.controls.qualification_ques.value" formControlName="qualification_ans" required>
|
||||
<mat-option *ngFor="let education of qualifications" [value]="education" >
|
||||
{{education}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="coDetails.controls.pd_question_type.value==4">
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<mat-select [placeholder]="coDetails.controls.pd_question.value" formControlName="pd_answer" required>
|
||||
<mat-select [placeholder]="coDetails.controls.earningStatus_ques.value" formControlName="earning_ans" required>
|
||||
<mat-option *ngFor="let earning of earningStatus" [value]="earning" >
|
||||
{{earning}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 100%" *ngIf="coDetails.controls.pd_question_type.value==5">
|
||||
<mat-form-field style="width: 100%">
|
||||
<!-- <mat-label>{{coDetails.controls.pd_question.value}}</mat-label> -->
|
||||
<mat-select [placeholder]="coDetails.controls.pd_question.value" formControlName="pd_answer" required>
|
||||
<mat-select [placeholder]="coDetails.controls.relationShip_ques.value" formControlName="relation_ans" required>
|
||||
<mat-option *ngFor="let rel of relationShipList" [value]="rel.relationship_id" >
|
||||
{{rel.name}}
|
||||
</mat-option>
|
||||
@ -109,17 +104,17 @@
|
||||
|
||||
|
||||
</mat-card-content>
|
||||
<mat-card-actions align="end">
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="submit" matTooltip="Save" matTooltipPosition="above" [disabled]="!_personalForm.valid "><mat-icon>save</mat-icon></button>
|
||||
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- end co applicant form details -->
|
||||
<mat-card-actions align="end">
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="submit" matTooltip="Save" matTooltipPosition="above" [disabled]="!_personalForm.valid "><mat-icon>save</mat-icon></button>
|
||||
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
@ -15,12 +15,17 @@ export class PersonalInfoComponent implements OnInit {
|
||||
earningStatus:any=["Earning Member","House Wife","Student","Retired","Pensioner","Other Non earning member"];
|
||||
relationShipList:any=[];
|
||||
@Input() pdid : string;
|
||||
@Input() pd_all_details:any;
|
||||
form_id:number;
|
||||
private notifier: NotifierService;
|
||||
public _personalForm: FormGroup;
|
||||
|
||||
public mainApplicantQuestions : any = ["Name","Age","Entity","Educational Qualification","Earning Status"];
|
||||
public coApplicantQuestions : any = ["Name","Age","Entity","Educational Qualification","Earning Status","Relationship"];
|
||||
|
||||
public mainApplicantDetails :any=[];
|
||||
public coApplicantDetails :any=[];
|
||||
|
||||
errorMessage:any;
|
||||
//coItem:any;
|
||||
//mainItem:any;
|
||||
@ -35,44 +40,97 @@ export class PersonalInfoComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
|
||||
this.loadPDDetails(this.pdid,this.form_id);
|
||||
this.loadFormData();
|
||||
this.getRelationMaster();
|
||||
}
|
||||
this.mainApplicantDetails = this.pd_all_details.pdapplicants_detials.filter(item => item.applicant_type == 1);
|
||||
// console.log(this.mainApplicantDetails)
|
||||
this.coApplicantDetails = this.pd_all_details.pdapplicants_detials.filter(item => item.applicant_type == 0);
|
||||
}
|
||||
|
||||
// load form pd details
|
||||
loadPDDetails(pd:string,form:number){
|
||||
|
||||
// this._pd.getAllMasterDatas(pdid,form_id).subscribe(
|
||||
// data => {
|
||||
// if (data.status == 200) {
|
||||
// this.relationShipList=data.records;
|
||||
this._pd.getPDFormDetailsWithID(this.pdid,this.form_id).subscribe(
|
||||
data => {
|
||||
if (data.status == 200) {
|
||||
|
||||
// }
|
||||
// }, error => this.errorMessage = <any> error);
|
||||
|
||||
}
|
||||
else if(data.status == 204){
|
||||
let defaultMainApp=[];
|
||||
let defaultCoApp=[];
|
||||
// generate default main applicant form details
|
||||
if(this.mainApplicantDetails.length>0){
|
||||
for(let j=0;j<this.mainApplicantQuestions.length; j++)
|
||||
{
|
||||
if(j==0){
|
||||
let generateRow = {
|
||||
"pd_question":"",
|
||||
"pd_answer": this.mainApplicantDetails[0].applicant_name,
|
||||
}
|
||||
defaultMainApp.push(generateRow);
|
||||
}
|
||||
else{
|
||||
let generateRow = {
|
||||
"pd_question":"",
|
||||
"pd_answer": "",
|
||||
}
|
||||
defaultMainApp.push(generateRow);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
this.loadFormData(defaultMainApp,this.coApplicantDetails);
|
||||
|
||||
|
||||
}
|
||||
}, error => this.errorMessage = <any> error);
|
||||
}
|
||||
|
||||
loadFormData(){
|
||||
loadFormData(mainApp,coApp){
|
||||
// main applicant
|
||||
let mainApplicantGroup = new FormArray(this.mainApplicantQuestions.map((item,key) => new FormGroup({
|
||||
fk_pd_id:new FormControl(null),
|
||||
pd_question:new FormControl(this.mainApplicantQuestions[key]),
|
||||
pd_question_type:new FormControl(key),
|
||||
pd_detail_answer_id: new FormControl(null),
|
||||
pd_answer_id: new FormControl(null,),
|
||||
pd_answer: new FormControl(null,Validators.required),
|
||||
pd_answer_weightage:new FormControl(null),
|
||||
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.required),
|
||||
entity_ques: new FormControl(this.mainApplicantQuestions[2]),
|
||||
entity_id: new FormControl(2),
|
||||
entity_ans:new FormControl(null, 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.coApplicantQuestions.map((item,key) => new FormGroup({
|
||||
fk_pd_id:new FormControl(null),
|
||||
pd_question:new FormControl(this.coApplicantQuestions[key]),
|
||||
pd_question_type:new FormControl(key),
|
||||
pd_detail_answer_id: new FormControl(null),
|
||||
pd_answer_id: new FormControl(null),
|
||||
pd_answer: new FormControl(null, Validators.required),
|
||||
pd_answer_weightage:new FormControl(null),
|
||||
})));
|
||||
let iterateCoApp=[];
|
||||
|
||||
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.required),
|
||||
entity_ques: new FormControl(this.coApplicantQuestions[2]),
|
||||
entity_id: new FormControl(2),
|
||||
entity_ans:new FormControl(null, 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,
|
||||
@ -80,8 +138,8 @@ export class PersonalInfoComponent implements OnInit {
|
||||
mainItem: mainApplicantGroup,
|
||||
coItem: coApplicantGroup,
|
||||
});
|
||||
//console.log(this._personalForm);
|
||||
|
||||
console.log(this._personalForm.controls.coItem)
|
||||
}
|
||||
|
||||
//get pd main applicant array values
|
||||
@ -102,5 +160,41 @@ export class PersonalInfoComponent implements OnInit {
|
||||
}, error => this.errorMessage = <any> error);
|
||||
}
|
||||
|
||||
// submit forms details
|
||||
submitPersonalForm(formData:any) {
|
||||
if(this._personalForm.valid){
|
||||
let applicantDetails:any=[];
|
||||
|
||||
formData.mainItem.forEach((element,key) => {
|
||||
if(key==0){
|
||||
applicantDetails.push(element)
|
||||
}
|
||||
console.log(element);
|
||||
console.log(key);
|
||||
|
||||
});
|
||||
formData.coItem.forEach((Coelement,Cokey) => {
|
||||
applicantDetails.push(Coelement)
|
||||
|
||||
});
|
||||
|
||||
let save_details:any={
|
||||
"pdid": this.pdid,
|
||||
"formid": this.form_id,
|
||||
"applicant_details":applicantDetails
|
||||
};
|
||||
this._pd.savePDQuestions(save_details).subscribe(result => {
|
||||
if (result.status == 200) {
|
||||
this.notifier.notify('success', 'Success.');
|
||||
}
|
||||
else {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
}
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -389,7 +389,7 @@
|
||||
|
||||
<!-- start personal type questions -->
|
||||
<ng-container *ngSwitchCase="3">
|
||||
<app-personal-info [pdid]="startPD"></app-personal-info>
|
||||
<app-personal-info [pdid]="startPD" [pd_all_details]="pdFullDetails"></app-personal-info>
|
||||
</ng-container>
|
||||
<!-- end personal type questions -->
|
||||
</ng-container>
|
||||
|
||||
@ -29,6 +29,7 @@ selectedQuestionIndex:number;
|
||||
getQuestionsLength:number;
|
||||
answerList:any=[];
|
||||
ansPDList:any=[];
|
||||
pdFullDetails:any=[];
|
||||
|
||||
// category static form buttons
|
||||
categoryFormButtons : any=[
|
||||
@ -107,6 +108,8 @@ loadTemplates(startID:string){
|
||||
this.actualQuestions = data.records.counts.overall_question_count;
|
||||
this.answeredQuestions = data.records.counts.overall_answered_count;
|
||||
|
||||
this.pdFullDetails = data.records
|
||||
|
||||
}
|
||||
else{
|
||||
this.pdMasterList="";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user