general form changes
This commit is contained in:
parent
50c5e77761
commit
c6ea021dca
@ -11,9 +11,21 @@
|
||||
<mat-dialog-content formArrayName="applicant_list">
|
||||
<mat-card *ngFor="let applicant of _OtherForm.controls.applicant_list['controls']; let r = index;" [formGroupName]="r">
|
||||
<mat-card-content>
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-form-field style="width: 75%">
|
||||
<input matInput placeholder="Name" formControlName="applicant_name" type="text">
|
||||
</mat-form-field>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeApplicant(r)" *ngIf="r>0"
|
||||
matTooltip="Remove Individuals" matTooltipPosition="right">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
<div fxLayout="row wrap" class="example-section">
|
||||
<div fxFlex="100%">
|
||||
<mat-checkbox class="example-margin" color="primary" formControlName="is_person_met">Is Person Met</mat-checkbox>
|
||||
</div>
|
||||
<div fxFlex="100%">
|
||||
<mat-checkbox class="example-margin" color="primary" formControlName="is_applicant">Is Applicant</mat-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@ -4,4 +4,11 @@
|
||||
}
|
||||
mat-form-field {
|
||||
margin: 0 2%;
|
||||
}
|
||||
.example-section {
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.example-margin {
|
||||
margin: 0 10px;
|
||||
}
|
||||
@ -8,9 +8,9 @@ import { MatDialog, MatDialogRef, MAT_DIALOG_DATA , DialogPosition} from '@angul
|
||||
styleUrls: ['./other-applicant-details.component.scss']
|
||||
})
|
||||
export class OtherApplicantDetailsComponent implements OnInit {
|
||||
pageTitle: string ="Add Other Applicant Details";
|
||||
pageTitle: string ="Add Individuals Details";
|
||||
public _OtherForm: FormGroup;
|
||||
applicantInfo:any={'pd_co_applicant_id':"0",'applicant_name':'','company_name':''};
|
||||
applicantInfo:any={'pd_co_applicant_id':"0",'applicant_name':'','is_applicant':false,'is_person_met':false};
|
||||
|
||||
constructor(private _fb: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: any, private dialogRef: MatDialogRef<OtherApplicantDetailsComponent>) { }
|
||||
|
||||
@ -30,7 +30,8 @@ createApplicant(elementValue:any){
|
||||
return this._fb.group({
|
||||
pd_co_applicant_id: [elementValue.pd_co_applicant_id],
|
||||
applicant_name: [elementValue.applicant_name, Validators.required],
|
||||
//company_name:[elementValue.company_name]
|
||||
is_applicant:[false],
|
||||
is_person_met:[false],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -9,47 +9,96 @@
|
||||
</div>
|
||||
</h2>
|
||||
<mat-dialog-content>
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
<mat-card-title>Name of Person Met</mat-card-title>
|
||||
</mat-card-header>
|
||||
<!-- individuals details start-->
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
<mat-card-title>Individuals</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div fxLayout="row wrap" class="example-section" formArrayName="applicant_list">
|
||||
<div fxFlex.xs="100" fxFlex.sm="50" fxFlex.md="25" fxFlex.lg="25" fxFlex.xl="25" *ngFor="let applicant of _generalForm.controls.applicant_list['controls']; let c = index;" [formGroupName]="c">
|
||||
<mat-checkbox class="example-margin" color="primary" formControlName="exist_status" (change)="checkboxChange($event, c, applicant.controls)">{{applicant.controls.applicant_name.value}}</mat-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<mat-table [dataSource]="individualsSource" *ngIf="_generalForm.controls.individuals['controls'].length>0" formArrayName="individuals">
|
||||
<ng-container matColumnDef="applicant_name">
|
||||
<mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
|
||||
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
|
||||
{{details.value.applicant_name | titlecase}}
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="is_person_met">
|
||||
<mat-header-cell *matHeaderCellDef> Is Person Met </mat-header-cell>
|
||||
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
|
||||
<mat-checkbox class="table-checkbox" color="primary" formControlName="is_person_met"></mat-checkbox>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="is_applicant">
|
||||
<mat-header-cell *matHeaderCellDef> Is Applicant </mat-header-cell>
|
||||
<mat-cell *matCellDef="let details;let i = index;" [formGroupName]="i">
|
||||
<mat-checkbox class="table-checkbox" color="primary" formControlName="is_applicant"></mat-checkbox>
|
||||
<!-- <button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeIndividuals(i)"
|
||||
matTooltip="Remove Individuals" matTooltipPosition="below">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button> -->
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;">
|
||||
</mat-row>
|
||||
</mat-table>
|
||||
|
||||
</mat-card-content>
|
||||
<mat-card-actions align="end">
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add Other Applicant" matTooltipPosition="above" color="primary" (click)="addOtherApplicant()"><mat-icon>add</mat-icon></button>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="addMoreIndividuals()"
|
||||
matTooltip="Add More Individuals" matTooltipPosition="left" color="primary">
|
||||
<mat-icon>add</mat-icon>
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
<!-- end -->
|
||||
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
<mat-card-title>Applicant Details</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content formArrayName="applicant_relation">
|
||||
<div fxLayout="row wrap">
|
||||
<!-- companies start -->
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
<mat-card-title>Companies</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div fxLayout="row wrap" formArrayName="companies">
|
||||
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100" *ngFor="let com of _generalForm.controls.companies['controls']; let c = index;" [formGroupName]="c">
|
||||
<mat-form-field style="width: 60%">
|
||||
<input matInput placeholder="Company/Firm" formControlName="company_name" type="text">
|
||||
</mat-form-field>
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add More Company/Firm" matTooltipPosition="above" color="primary" (click)="addMoreCompanies()" *ngIf="c==0"><mat-icon>add</mat-icon></button>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeCompanies(c)" *ngIf="c>0"
|
||||
matTooltip="Remove Company/Firm" matTooltipPosition="above">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<!-- companies end -->
|
||||
|
||||
<div fxLayout="row wrap" formArrayName="applicant_relation">
|
||||
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="100" fxFlex.lg="100" fxFlex.xl="100" *ngFor="let relation of _generalForm.controls.applicant_relation['controls']; let r = index;" [formGroupName]="r">
|
||||
<mat-card >
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{relation.controls.applicant_name.value | titlecase}}</mat-card-title>
|
||||
<mat-card-title class="p-text">{{relation.controls.applicant_name.value | titlecase}}</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<p>With Personel Relationships</p>
|
||||
<div formArrayName="multiple_relation">
|
||||
<div *ngFor="let mulRel of relation.get('multiple_relation').controls; let m = index" [formGroupName]="m">
|
||||
<div fxLayout="row nowrap">
|
||||
<mat-form-field style="width: 45%">
|
||||
<mat-form-field style="width: 40%">
|
||||
<mat-select placeholder="Relation to" formControlName="applicant_relation_to">
|
||||
<mat-option>Select</mat-option>
|
||||
<mat-option *ngFor="let rel of fetch_related_details" [value]="rel">
|
||||
<mat-option *ngFor="let rel of individualsList" [value]="rel.individuals_order_id">
|
||||
<!-- [disabled]="relation.controls.applicant_name.value == rel" -->
|
||||
{{rel | titlecase}}
|
||||
{{rel.applicant_name | titlecase}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 40%">
|
||||
<mat-form-field style="width: 30%">
|
||||
<mat-select placeholder="Relation" formControlName="relationship">
|
||||
<mat-option>Select</mat-option>
|
||||
<mat-option *ngFor="let relShip of relationShipList" [value]="relShip.relationship_id">
|
||||
@ -63,44 +112,40 @@
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div formArrayName="multiple_company_relation">
|
||||
<div fxLayout="row nowrap" *ngFor="let comRel of mulRel.get('multiple_company_relation').controls; let c = index" [formGroupName]="c">
|
||||
<mat-form-field style="width: 40%">
|
||||
<input matInput placeholder="Company / Firm" formControlName="company_name" type="text">
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 30%">
|
||||
<mat-select placeholder="Relation" formControlName="company_relationship">
|
||||
<mat-option>Select</mat-option>
|
||||
<mat-option *ngFor="let comrelShip of companyRelationShipList" [value]="comrelShip.company_relationship_id">
|
||||
{{comrelShip.name | titlecase}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add More Company" matTooltipPosition="above" color="primary" (click)="addMoreCompanyRelation(r,m,c)" *ngIf="c==0"><mat-icon>add</mat-icon></button>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeCompanyRelation(r,m,c)" *ngIf="c>0"
|
||||
matTooltip="Remove Company" matTooltipPosition="above">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>With Company Relationships</p>
|
||||
<div formArrayName="multiple_company_relation">
|
||||
<div fxLayout="row nowrap" *ngFor="let comRel of relation.get('multiple_company_relation').controls; let c = index" [formGroupName]="c">
|
||||
<mat-form-field style="width: 40%">
|
||||
<mat-select placeholder="Company / Firm" formControlName="company_name">
|
||||
<mat-option>Select</mat-option>
|
||||
<mat-option *ngFor="let comp of companyList" [value]="comp.company_order_id">
|
||||
{{comp.company_name | titlecase}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 30%">
|
||||
<mat-select placeholder="Relation" formControlName="company_relationship">
|
||||
<mat-option>Select</mat-option>
|
||||
<mat-option *ngFor="let comrelShip of companyRelationShipList" [value]="comrelShip.company_relationship_id">
|
||||
{{comrelShip.name | titlecase}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Add More Company" matTooltipPosition="above" color="primary" (click)="addMoreCompanyRelation(r,c)" *ngIf="c==0"><mat-icon>add</mat-icon></button>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeCompanyRelation(r,c)" *ngIf="c>0"
|
||||
matTooltip="Remove Company" matTooltipPosition="above">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
<mat-card-actions align="end" *ngIf="relation.controls.pd_co_applicant_id.value==0">
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeOthers(r,relation.value)"
|
||||
matTooltip="Delete" matTooltipPosition="above">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
</mat-card>
|
||||
|
||||
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions>
|
||||
<div fxFlex="60" class="pb-0 text-sm-left" align="left">
|
||||
|
||||
@ -11,4 +11,16 @@
|
||||
}
|
||||
mat-form-field {
|
||||
margin: 0 2%;
|
||||
}
|
||||
}
|
||||
|
||||
mat-header-cell mat-cell {
|
||||
display:flex;
|
||||
justify-content:flex-end;
|
||||
}
|
||||
.table-checkbox {
|
||||
margin-left: 15% !important;
|
||||
}
|
||||
.p-text {
|
||||
color:#e00201 !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component, OnInit, Input, Output, Inject } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms';
|
||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA , DialogPosition} from '@angular/material';
|
||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA , MatTableDataSource} from '@angular/material';
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { PdTrigerService } from './../../../../../pd-service/pd-triger.service';
|
||||
import {OtherApplicantDetailsComponent} from './../dialogue/other-applicant-details/other-applicant-details.component';
|
||||
@ -15,11 +15,15 @@ export class GeneralInfoComponent implements OnInit {
|
||||
form_id:number;
|
||||
private notifier: NotifierService;
|
||||
public _generalForm: FormGroup;
|
||||
displayedColumns = ['applicant_name','is_person_met','is_applicant'];
|
||||
public individualsSource= new MatTableDataSource();
|
||||
public pd_applicants_details: any;
|
||||
relationShipList:any=[];
|
||||
companyRelationShipList:any=[];
|
||||
errorMessage:any;
|
||||
fetch_related_details:any=[];
|
||||
individualsList: any=[];
|
||||
companyList: any=[];
|
||||
|
||||
|
||||
constructor(notifier: NotifierService,private _fb: FormBuilder,private _pd: PdTrigerService , private dialog: MatDialog, @Inject(MAT_DIALOG_DATA) public pd_all_details: any,) {
|
||||
this.pdid = this.pd_all_details.pdmaster_details.pd_id;
|
||||
@ -34,6 +38,17 @@ export class GeneralInfoComponent implements OnInit {
|
||||
this.initFormDetails();
|
||||
this.getMasterDetails('RELATIONSHIPS',1);
|
||||
this.getMasterDetails('COMPANYRELATIONSHIPS',2);
|
||||
// update data source table when change the individuals details
|
||||
this._generalForm.controls['individuals'].valueChanges.subscribe(val=>{
|
||||
let control = <FormArray>this._generalForm.controls['individuals'];
|
||||
this.individualsSource.data =control.controls;
|
||||
this.individualsList = control.value.filter(element =>element.is_applicant===true);
|
||||
});
|
||||
// update company details
|
||||
this._generalForm.controls['companies'].valueChanges.subscribe(val=>{
|
||||
let control = <FormArray>this._generalForm.controls['companies'];
|
||||
this.companyList = control.value.filter(element =>element.company_name);
|
||||
});
|
||||
}
|
||||
|
||||
// init form
|
||||
@ -41,8 +56,9 @@ export class GeneralInfoComponent implements OnInit {
|
||||
this._generalForm = this._fb.group({
|
||||
pdid:this.pdid,
|
||||
formid:this.form_id,
|
||||
applicant_list: this._fb.array([]),
|
||||
applicant_relation: this._fb.array([]),
|
||||
individuals: this._fb.array([]),
|
||||
companies: this._fb.array([]),
|
||||
general_remark:''
|
||||
});
|
||||
this.loadFormData();
|
||||
@ -68,96 +84,122 @@ export class GeneralInfoComponent implements OnInit {
|
||||
let params: any = {};
|
||||
params.pd_id = this.pdid;
|
||||
params.pd_form_id = '18';
|
||||
let applicantControl = <FormArray>this._generalForm.controls['applicant_list'];
|
||||
let individualsControl = <FormArray>this._generalForm.controls['individuals'];
|
||||
let companyControl = this._generalForm.get('companies') as FormArray;
|
||||
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
|
||||
applicantControl.controls = [];
|
||||
individualsControl.controls = [];
|
||||
relationControl.controls = [];
|
||||
let exist_data:any;
|
||||
let exist_applicant_relation:any;
|
||||
companyControl.controls = [];
|
||||
let exist_individuals:any;
|
||||
let exist_companies:any;
|
||||
let exist_relation:any;
|
||||
this._pd.retriveForm(params).subscribe(data => {
|
||||
if(data.dataStatus) {
|
||||
this._generalForm.controls['general_remark'].setValue(data.records.general_remark ? data.records.general_remark : '');
|
||||
|
||||
// create individuals
|
||||
exist_individuals=Object.keys(data.records.individuals).map(function(key) {
|
||||
return data.records.individuals[key];
|
||||
});
|
||||
|
||||
exist_data=Object.keys(data.records.selected_applicant).map(function(key) {
|
||||
return data.records.selected_applicant[key].pd_co_applicant_id;
|
||||
});
|
||||
exist_applicant_relation = Object.keys(data.records.applicant_relation).map(function(key) {
|
||||
return data.records.applicant_relation[key];
|
||||
if(exist_individuals.length>0){
|
||||
exist_individuals.forEach(element => {
|
||||
individualsControl.push(this.createIndividulas(element))
|
||||
});
|
||||
}
|
||||
// create companies
|
||||
exist_companies = Object.keys(data.records.companies).map(function(key) {
|
||||
return data.records.companies[key];
|
||||
});
|
||||
if(exist_companies.length>0){
|
||||
exist_companies.forEach(element => {
|
||||
companyControl.push(this.createCompanies(element))
|
||||
});
|
||||
}
|
||||
|
||||
// create relations
|
||||
exist_relation = Object.keys(data.records.applicant_relation).map(function(key) {
|
||||
return data.records.applicant_relation[key];
|
||||
});
|
||||
if(exist_relation.length>0){
|
||||
exist_relation.forEach((element,index) => {
|
||||
relationControl.push(this.createApplicantRelation(element));
|
||||
let innerrelControl:any = relationControl.controls[index].get('multiple_relation') as FormArray;
|
||||
element.multiple_relation.forEach((innereElement) => {
|
||||
innerrelControl.push(this.createMultipleRelation(innereElement));
|
||||
});
|
||||
let innercomrelControl:any = relationControl.controls[index].get('multiple_company_relation') as FormArray;
|
||||
element.multiple_company_relation.forEach((innerecomElement) => {
|
||||
innercomrelControl.push(this.createMultipleCompanyRelation(innerecomElement));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
exist_data=[];
|
||||
exist_applicant_relation=[];
|
||||
}
|
||||
//find exist and non-exist applicant details
|
||||
let actual_applicant = this.pd_applicants_details.map(item => item.pd_co_applicant_id);
|
||||
let checkApplicantExist =actual_applicant.map((id, index) => {
|
||||
if (exist_data.indexOf(id) < 0) {
|
||||
this.pd_applicants_details[index].exist_status=0;
|
||||
return this.pd_applicants_details[index];
|
||||
}
|
||||
else{
|
||||
this.pd_applicants_details[index].exist_status=1;
|
||||
this.pd_applicants_details[index].applicant_relation_to='';
|
||||
this.pd_applicants_details[index].relation='';
|
||||
return this.pd_applicants_details[index];
|
||||
}
|
||||
}).filter(item => item != undefined);
|
||||
this.pd_applicants_details.forEach((element,key) => {
|
||||
element.is_applicant=true;
|
||||
element.is_person_met=false;
|
||||
element.individuals_order_id = key+1
|
||||
individualsControl.push(this.createIndividulas(element));
|
||||
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
|
||||
let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name, 'individula_order_id':relationControl.controls.length+1};
|
||||
relationControl.push(this.createApplicantRelation(applicant_details));
|
||||
let mulRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
|
||||
mulRelationControl.push(this.createMultipleRelation(applicant_details))
|
||||
let mulCmyRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
|
||||
mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details))
|
||||
|
||||
// create companies
|
||||
if(element.company_name!='' && element.company_name!=null){
|
||||
let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:element.company_name}
|
||||
companyControl.push(this.createCompanies(setCompanyValues))
|
||||
}
|
||||
});
|
||||
// check company if null update one row
|
||||
if(companyControl.controls.length ==0){
|
||||
let setCompanyValues: any = {company_order_id :companyControl.controls.length+1,company_name:''}
|
||||
companyControl.push(this.createCompanies(setCompanyValues))
|
||||
|
||||
if(checkApplicantExist.length > 0)
|
||||
{
|
||||
checkApplicantExist.forEach(val => {
|
||||
applicantControl.push(this.createApplicant(val));
|
||||
});
|
||||
|
||||
}
|
||||
if(exist_applicant_relation.length > 0){
|
||||
exist_applicant_relation.forEach((val,key) => {
|
||||
let control: any = this._generalForm.get('applicant_relation') as FormArray;
|
||||
control.push(this.createApplicantRelation(val));
|
||||
control = control.controls[key].get('multiple_relation') as FormArray;
|
||||
val.multiple_relation.forEach((firstInnerelement,firstInnerKey) => {
|
||||
control.push(this.createMultipleRelation(firstInnerelement));
|
||||
let innerControl = this._generalForm.get('applicant_relation') as FormArray;
|
||||
innerControl = innerControl.controls[key].get('multiple_relation') as FormArray;
|
||||
innerControl = innerControl.controls[firstInnerKey].get('multiple_company_relation') as FormArray;
|
||||
firstInnerelement.multiple_company_relation.forEach((secondInnerValue,secondInnerKey) => {
|
||||
innerControl.push(this.createMultipleCompanyRelation(secondInnerValue))
|
||||
});
|
||||
|
||||
});
|
||||
//push related to details
|
||||
this.fetch_related_details.push(val.applicant_name);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, error => this.errorMessage = <any> error);
|
||||
|
||||
}
|
||||
// create individuals
|
||||
createIndividulas(elementValue:any) {
|
||||
return this._fb.group({
|
||||
pd_co_applicant_id: [elementValue.pd_co_applicant_id],
|
||||
applicant_name: [elementValue.applicant_name],
|
||||
is_applicant:[elementValue.is_applicant],
|
||||
is_person_met:[elementValue.is_person_met],
|
||||
individuals_order_id: [elementValue.individuals_order_id],
|
||||
});
|
||||
}
|
||||
// create companies
|
||||
createCompanies(elementValue:any) {
|
||||
return this._fb.group({
|
||||
company_order_id: [elementValue.company_order_id],
|
||||
company_name: [elementValue.company_name,Validators.required],
|
||||
});
|
||||
}
|
||||
|
||||
// check and uncheck function
|
||||
checkboxChange(event, index, item) {
|
||||
if(item.exist_status.value){
|
||||
let relationControl: any = <FormArray>this._generalForm.controls['applicant_relation'];
|
||||
let applicant_details: any= {'pd_co_applicant_id':item.pd_co_applicant_id.value,'applicant_name':item.applicant_name.value,'applicant_relation_to':'','relation':'','company_name':item.company_name.value,'company_relation':''};
|
||||
relationControl.push(this.createApplicantRelation(applicant_details));
|
||||
relationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
|
||||
relationControl.push(this.createMultipleRelation(applicant_details))
|
||||
relationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
|
||||
relationControl.push(this.createMultipleCompanyRelation(applicant_details))
|
||||
// to push selected persons names
|
||||
this.fetch_related_details.push(item.applicant_name.value);
|
||||
// add more companies
|
||||
addMoreCompanies() {
|
||||
let control: any = this._generalForm.get('companies') as FormArray;
|
||||
let setValues: any = {company_order_id :control.controls.length+1,company_name:''}
|
||||
control.push(this.createCompanies(setValues))
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
if(item.pd_co_applicant_id.value!=0){
|
||||
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
|
||||
let pos_id = relationControl.value.map(e=> e.pd_co_applicant_id).indexOf(item.pd_co_applicant_id.value);
|
||||
relationControl.removeAt(pos_id);
|
||||
// remove related to details
|
||||
let pos_name=this.fetch_related_details.indexOf(item.applicant_name.value);
|
||||
this.fetch_related_details.splice(pos_name, 1);
|
||||
}
|
||||
}
|
||||
// remove companies
|
||||
removeCompanies(indexValues) {
|
||||
let control: any = this._generalForm.get('companies') as FormArray;
|
||||
control.removeAt(indexValues);
|
||||
}
|
||||
|
||||
// create applicant form array
|
||||
@ -176,14 +218,15 @@ export class GeneralInfoComponent implements OnInit {
|
||||
pd_co_applicant_id: [elementValue.pd_co_applicant_id],
|
||||
applicant_name: [elementValue.applicant_name],
|
||||
multiple_relation: this._fb.array([]),
|
||||
multiple_company_relation : this._fb.array([]),
|
||||
individuals_order_id:[elementValue.individuals_order_id]
|
||||
});
|
||||
}
|
||||
// create multiple relation details
|
||||
createMultipleRelation(elementValue: any) {
|
||||
return this._fb.group({
|
||||
applicant_relation_to: [elementValue.applicant_relation_to, Validators.required],
|
||||
applicant_relation_to: [elementValue.applicant_relation_to],
|
||||
relationship: [elementValue.relationship],
|
||||
multiple_company_relation : this._fb.array([]),
|
||||
});
|
||||
}
|
||||
|
||||
@ -193,9 +236,6 @@ export class GeneralInfoComponent implements OnInit {
|
||||
control = control.controls[rindex].get('multiple_relation') as FormArray;
|
||||
let setValues: any = {applicant_relation_to :'',relationship:''}
|
||||
control.push(this.createMultipleRelation(setValues))
|
||||
let setCompanyValue = {company_name :'',company_relationship:''};
|
||||
control = <FormArray> control.controls[control.controls.length-1].get('multiple_company_relation');
|
||||
control.push(this.createMultipleCompanyRelation(setCompanyValue))
|
||||
}
|
||||
|
||||
// remove relation
|
||||
@ -208,29 +248,27 @@ export class GeneralInfoComponent implements OnInit {
|
||||
// create multiple company relation
|
||||
createMultipleCompanyRelation(elementValue: any) {
|
||||
return this._fb.group({
|
||||
company_name: [elementValue.company_name,elementValue.company_name ? Validators.required : Validators.nullValidator],
|
||||
company_name: [elementValue.company_name,Validators.required],
|
||||
company_relationship: [elementValue.company_relationship],
|
||||
});
|
||||
}
|
||||
// add more company relation
|
||||
addMoreCompanyRelation(rindex,mindex,cindex) {
|
||||
addMoreCompanyRelation(rindex,cindex) {
|
||||
let control: any = this._generalForm.get('applicant_relation') as FormArray;
|
||||
control = control.controls[rindex].get('multiple_relation') as FormArray;
|
||||
control = control.controls[mindex].get('multiple_company_relation') as FormArray;
|
||||
control = control.controls[rindex].get('multiple_company_relation') as FormArray;
|
||||
let setValues: any = {company_name :'',company_relationship:''}
|
||||
control.push(this.createMultipleCompanyRelation(setValues))
|
||||
}
|
||||
|
||||
// remove company relation
|
||||
removeCompanyRelation(rindex,mindex,cindex) {
|
||||
removeCompanyRelation(rindex,cindex) {
|
||||
let control: any = this._generalForm.get('applicant_relation') as FormArray;
|
||||
control = control.controls[rindex].get('multiple_relation') as FormArray;
|
||||
control = control.controls[mindex].get('multiple_company_relation') as FormArray;
|
||||
control = control.controls[rindex].get('multiple_company_relation') as FormArray;
|
||||
control.removeAt(cindex);
|
||||
}
|
||||
|
||||
// add more applicant details
|
||||
addOtherApplicant() {
|
||||
// add more individuals details
|
||||
addMoreIndividuals() {
|
||||
const dialogRef = this.dialog.open(OtherApplicantDetailsComponent, {
|
||||
data: '',
|
||||
width:'40%',
|
||||
@ -240,15 +278,16 @@ export class GeneralInfoComponent implements OnInit {
|
||||
.subscribe(dataresult => {
|
||||
if(dataresult.data.length>0){
|
||||
dataresult.data.forEach(element => {
|
||||
let individualsControl = <FormArray>this._generalForm.controls['individuals'];
|
||||
element.individuals_order_id = individualsControl.controls.length+1;
|
||||
individualsControl.push(this.createIndividulas(element));
|
||||
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
|
||||
let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name,'applicant_relation_to':'','relation':'','company_name':element.company_name,'company_relation':''};
|
||||
let applicant_details: any= {'pd_co_applicant_id':element.pd_co_applicant_id,'applicant_name':element.applicant_name,'applicant_relation_to':'','relation':'','company_name':'','company_relation':'','individuals_order_id':element.individuals_order_id};
|
||||
relationControl.push(this.createApplicantRelation(applicant_details));
|
||||
relationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
|
||||
relationControl.push(this.createMultipleRelation(applicant_details))
|
||||
relationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
|
||||
relationControl.push(this.createMultipleCompanyRelation(applicant_details))
|
||||
// push related to details
|
||||
this.fetch_related_details.push(element.applicant_name);
|
||||
let mulRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_relation');
|
||||
mulRelationControl.push(this.createMultipleRelation(applicant_details))
|
||||
let mulCmyRelationControl = <FormArray> relationControl.controls[relationControl.controls.length-1].get('multiple_company_relation');
|
||||
mulCmyRelationControl.push(this.createMultipleCompanyRelation(applicant_details))
|
||||
});
|
||||
|
||||
}
|
||||
@ -256,17 +295,11 @@ export class GeneralInfoComponent implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// remove other details
|
||||
removeOthers(index, item: any){
|
||||
if(item.pd_co_applicant_id==0){
|
||||
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
|
||||
relationControl.removeAt(index);
|
||||
// remove related to details
|
||||
let pos_name=this.fetch_related_details.indexOf(item.applicant_name);
|
||||
this.fetch_related_details.splice(pos_name, 1);
|
||||
}
|
||||
}
|
||||
// remove individuals
|
||||
removeIndividuals(findex,order_id){
|
||||
let control = <FormArray>this._generalForm.controls['individuals'];
|
||||
control.removeAt(findex);
|
||||
}
|
||||
|
||||
// submit form details
|
||||
submitGeneralForm(formData:any) {
|
||||
@ -280,34 +313,12 @@ export class GeneralInfoComponent implements OnInit {
|
||||
}
|
||||
else{
|
||||
let saveRecords:any = {}
|
||||
let applicantList:any=[];
|
||||
let applicantRelationList:any=[];
|
||||
// this for applicant list for selected
|
||||
formData.applicant_list.forEach((element,key) => {
|
||||
if(element.exist_status==1){
|
||||
applicantList.push({
|
||||
"pd_co_applicant_id":element.pd_co_applicant_id,
|
||||
"applicant_name":element.applicant_name,
|
||||
})
|
||||
}
|
||||
});
|
||||
// this is for selected applicant relation
|
||||
// formData.applicant_relation.forEach((element,key) => {
|
||||
// applicantRelationList.push({
|
||||
// "pd_co_applicant_id":element.pd_co_applicant_id,
|
||||
// "applicant_name":element.applicant_name,
|
||||
// "company_name":element.company_name,
|
||||
// "company_relationship":element.company_relationship,
|
||||
// "applicant_relation_to":element.applicant_relation_to,
|
||||
// "relationship":element.relationship,
|
||||
// })
|
||||
// });
|
||||
|
||||
saveRecords.pdid=formData.pdid;
|
||||
saveRecords.formid=formData.formid;
|
||||
saveRecords.general_remark=formData.general_remark;
|
||||
saveRecords.selected_applicant=applicantList;
|
||||
saveRecords.individuals=formData.individuals;
|
||||
saveRecords.companies=formData.companies;
|
||||
saveRecords.applicant_relation=formData.applicant_relation;
|
||||
saveRecords.general_remark=formData.general_remark;
|
||||
this._pd.savePDFormDetailsWithID(saveRecords).subscribe(
|
||||
dataresult => {
|
||||
if (dataresult.status == 200) {
|
||||
@ -324,6 +335,7 @@ export class GeneralInfoComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// validate all form group and form array fields
|
||||
validateAllFormFields(formGroup: any) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user