general form changes
This commit is contained in:
parent
6fe58aa23c
commit
0bb311fed5
@ -1,3 +1,91 @@
|
|||||||
<p>
|
<form [formGroup]="_generalForm" novalidate>
|
||||||
general-info works!
|
|
||||||
</p>
|
<h2 mat-dialog-title class="paragraph_change">
|
||||||
|
<div fxFlex="70" align="left">
|
||||||
|
{{pageTitle}}
|
||||||
|
</div>
|
||||||
|
<div fxFlex="30" align="end">
|
||||||
|
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Close" matTooltipPosition="right" mat-dialog-close><mat-icon>close</mat-icon></button>
|
||||||
|
</div>
|
||||||
|
</h2>
|
||||||
|
<mat-dialog-content>
|
||||||
|
<mat-card>
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>Name of Person Met</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="100" 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-card-content>
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<div fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="50" fxFlex.lg="50" fxFlex.xl="50" *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-header>
|
||||||
|
<mat-card-content>
|
||||||
|
<mat-form-field style="width: 50%" *ngIf="relation.controls.company_name.value">
|
||||||
|
<input matInput placeholder="Company / Firm" formControlName="company_name" type="text">
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 40%" *ngIf="relation.controls.company_name.value">
|
||||||
|
<mat-select placeholder="Relation" formControlName="company_relationship">
|
||||||
|
<mat-option>Select</mat-option>
|
||||||
|
<mat-option *ngFor="let comrelShip of relationShipList" [value]="comrelShip.relationship_id">
|
||||||
|
{{comrelShip.name | titlecase}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 50%">
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<!-- [disabled]="relation.controls.applicant_name.value == rel" -->
|
||||||
|
{{rel | titlecase}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
|
||||||
|
<!-- <input matInput placeholder="Relation to" formControlName="applicant_relation_to" type="text"> -->
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 40%" *ngIf="relation.controls.applicant_relation_to.value">
|
||||||
|
<mat-select placeholder="Relation" formControlName="relationship">
|
||||||
|
<mat-option>Select</mat-option>
|
||||||
|
<mat-option *ngFor="let relShip of relationShipList" [value]="relShip.relationship_id">
|
||||||
|
{{relShip.name | titlecase}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</mat-card-content>
|
||||||
|
</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">
|
||||||
|
<mat-form-field appearance="outline" style="width: 100%">
|
||||||
|
<mat-label>Remarks</mat-label>
|
||||||
|
<textarea matInput placeholder="Remarks" formControlName="general_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="button" matTooltip="Save" matTooltipPosition="above" (click)="submitGeneralForm(_generalForm.value)"><mat-icon>save</mat-icon></button>
|
||||||
|
</div>
|
||||||
|
</mat-dialog-actions>
|
||||||
|
<notifier-container></notifier-container>
|
||||||
|
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
.paragraph_change {
|
||||||
|
color: #e00201 !important;
|
||||||
|
}
|
||||||
|
.example-section {
|
||||||
|
height: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.example-margin {
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
mat-form-field {
|
||||||
|
margin: 0 2%;
|
||||||
|
}
|
||||||
@ -1,15 +1,260 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
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 { NotifierService } from 'angular-notifier';
|
||||||
|
import { PdTrigerService } from './../../../../../pd-service/pd-triger.service';
|
||||||
|
import {OtherApplicantDetailsComponent} from './../other-applicant-details/other-applicant-details.component';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-general-info',
|
selector: 'app-general-info',
|
||||||
templateUrl: './general-info.component.html',
|
templateUrl: './general-info.component.html',
|
||||||
styleUrls: ['./general-info.component.scss']
|
styleUrls: ['./general-info.component.scss'],
|
||||||
})
|
})
|
||||||
export class GeneralInfoComponent implements OnInit {
|
export class GeneralInfoComponent implements OnInit {
|
||||||
|
pageTitle: string ="General Information";
|
||||||
|
pdid : string;
|
||||||
|
form_id:number;
|
||||||
|
private notifier: NotifierService;
|
||||||
|
public _generalForm: FormGroup;
|
||||||
|
public pd_applicants_details: any;
|
||||||
|
relationShipList:any=[];
|
||||||
|
errorMessage:any;
|
||||||
|
fetch_related_details:any=[];
|
||||||
|
|
||||||
constructor() { }
|
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;
|
||||||
ngOnInit() {
|
this.notifier = notifier;
|
||||||
|
this.form_id = 18;
|
||||||
|
this.pd_applicants_details = this.pd_all_details.pdapplicants_detials;
|
||||||
|
// push Other options to applicant details
|
||||||
|
this.pd_applicants_details.push({'pd_co_applicant_id':"0",'applicant_name':'Others', });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.initFormDetails();
|
||||||
|
this.getMasterDetails('RELATIONSHIPS',1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// init form
|
||||||
|
initFormDetails() {
|
||||||
|
this._generalForm = this._fb.group({
|
||||||
|
pdid:this.pdid,
|
||||||
|
formid:this.form_id,
|
||||||
|
applicant_list: this._fb.array([]),
|
||||||
|
applicant_relation: this._fb.array([]),
|
||||||
|
general_remark:''
|
||||||
|
});
|
||||||
|
this.loadFormData();
|
||||||
}
|
}
|
||||||
|
// get all master details
|
||||||
|
getMasterDetails(table:string,type:number){
|
||||||
|
this._pd.getAllMasterDatas(table).subscribe(
|
||||||
|
data => {
|
||||||
|
if (data.status == 200) {
|
||||||
|
if(type==1){
|
||||||
|
this.relationShipList=data.records.filter(item => item.isactive == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, error => this.errorMessage = <any> error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load form data
|
||||||
|
loadFormData() {
|
||||||
|
let params: any = {};
|
||||||
|
params.pd_id = this.pdid;
|
||||||
|
params.pd_form_id = '18';
|
||||||
|
let applicantControl = <FormArray>this._generalForm.controls['applicant_list'];
|
||||||
|
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
|
||||||
|
applicantControl.controls = [];
|
||||||
|
relationControl.controls = [];
|
||||||
|
let exist_data:any;
|
||||||
|
let exist_applicant_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 : '');
|
||||||
|
|
||||||
|
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];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
|
if(checkApplicantExist.length > 0)
|
||||||
|
{
|
||||||
|
checkApplicantExist.forEach(val => {
|
||||||
|
applicantControl.push(this.createApplicant(val));
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
if(exist_applicant_relation.length > 0){
|
||||||
|
exist_applicant_relation.forEach(val => {
|
||||||
|
relationControl.push(this.createApplicantRelation(val));
|
||||||
|
//push related to details
|
||||||
|
this.fetch_related_details.push(val.applicant_name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, error => this.errorMessage = <any> error);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// create applicant form array
|
||||||
|
createApplicant(elementValue:any){
|
||||||
|
return this._fb.group({
|
||||||
|
pd_co_applicant_id: [elementValue.pd_co_applicant_id],
|
||||||
|
applicant_name: [elementValue.applicant_name],
|
||||||
|
exist_status:[elementValue.exist_status==1 && elementValue.pd_co_applicant_id > 0 ? true : false]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// create applicant relation form array
|
||||||
|
createApplicantRelation(elementValue: any) {
|
||||||
|
return this._fb.group({
|
||||||
|
pd_co_applicant_id: [elementValue.pd_co_applicant_id],
|
||||||
|
applicant_name: [elementValue.applicant_name],
|
||||||
|
company_name: [elementValue.company_name,elementValue.company_name ? Validators.required : Validators.nullValidator],
|
||||||
|
company_relationship: [elementValue.company_relationship],
|
||||||
|
applicant_relation_to: [elementValue.applicant_relation_to, Validators.required],
|
||||||
|
relationship: [elementValue.relationship],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkand un check function
|
||||||
|
checkboxChange(event, index, item) {
|
||||||
|
if(item.exist_status.value){
|
||||||
|
if(item.pd_co_applicant_id.value==0){
|
||||||
|
const dialogRef = this.dialog.open(OtherApplicantDetailsComponent, {
|
||||||
|
data: '',
|
||||||
|
width:'40%',
|
||||||
|
disableClose: true
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed()
|
||||||
|
.subscribe(dataresult => {
|
||||||
|
if(dataresult.data.length>0){
|
||||||
|
let relationControl = <FormArray>this._generalForm.controls['applicant_relation'];
|
||||||
|
dataresult.data.forEach(element => {
|
||||||
|
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':'',};
|
||||||
|
relationControl.push(this.createApplicantRelation(applicant_details));
|
||||||
|
// push related to details
|
||||||
|
this.fetch_related_details.push(element.applicant_name);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
let relationControl = <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':'','company_relation':'',};
|
||||||
|
relationControl.push(this.createApplicantRelation(applicant_details));
|
||||||
|
// push related to details
|
||||||
|
this.fetch_related_details.push(item.applicant_name.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// submit form details
|
||||||
|
submitGeneralForm(formData:any) {
|
||||||
|
if (this._generalForm.invalid) {
|
||||||
|
this.validateAllFormFields(this._generalForm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(formData.applicant_relation.length==0){
|
||||||
|
this.notifier.notify('warning', 'Please Choose Name of Person Met.!');
|
||||||
|
|
||||||
|
}
|
||||||
|
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.applicant_relation=applicantRelationList;
|
||||||
|
this._pd.savePDFormDetailsWithID(saveRecords).subscribe(
|
||||||
|
dataresult => {
|
||||||
|
if (dataresult.status == 200) {
|
||||||
|
this.notifier.notify('success', 'General Information Updated.!');
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
// this.errorMessage = "Some Thing Wents Wrong Try Again !";
|
||||||
|
}
|
||||||
|
}, error => {
|
||||||
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
// this.errorMessage = "Something Wents Wrong Try Again !";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate all form group and form array fields
|
||||||
|
validateAllFormFields(formGroup: any) {
|
||||||
|
Object.keys(formGroup.controls).forEach(field => {
|
||||||
|
const control = formGroup.get(field);
|
||||||
|
|
||||||
|
if (control instanceof FormControl) {
|
||||||
|
control.markAsTouched({ onlySelf: true });
|
||||||
|
} else if (control instanceof FormGroup) {
|
||||||
|
this.validateAllFormFields(control);
|
||||||
|
} else if (control instanceof FormArray) {
|
||||||
|
this.validateAllFormFields(control);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
<form [formGroup]="_OtherForm" novalidate>
|
||||||
|
|
||||||
|
<h2 mat-dialog-title class="paragraph_change">
|
||||||
|
<div fxFlex="70" align="left">
|
||||||
|
{{pageTitle}}
|
||||||
|
</div>
|
||||||
|
<div fxFlex="30" align="end">
|
||||||
|
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Close" matTooltipPosition="right" (click)="closeDialogue()"><mat-icon>close</mat-icon></button>
|
||||||
|
</div>
|
||||||
|
</h2>
|
||||||
|
<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%">
|
||||||
|
<input matInput placeholder="Name" formControlName="applicant_name" type="text">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</mat-dialog-content>
|
||||||
|
<mat-dialog-actions align="end">
|
||||||
|
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Save" matTooltipPosition="above" (click)="addMoreApplicant()"><mat-icon>add</mat-icon></button>
|
||||||
|
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Save" matTooltipPosition="above" (click)="saveApplicant(_OtherForm.value)"><mat-icon>save</mat-icon></button>
|
||||||
|
</mat-dialog-actions>
|
||||||
|
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
.paragraph_change {
|
||||||
|
color: #e00201 !important;
|
||||||
|
}
|
||||||
|
mat-form-field {
|
||||||
|
margin: 0 2%;
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { OtherApplicantDetailsComponent } from './other-applicant-details.component';
|
||||||
|
|
||||||
|
describe('OtherApplicantDetailsComponent', () => {
|
||||||
|
let component: OtherApplicantDetailsComponent;
|
||||||
|
let fixture: ComponentFixture<OtherApplicantDetailsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ OtherApplicantDetailsComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(OtherApplicantDetailsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-other-applicant-details',
|
||||||
|
templateUrl: './other-applicant-details.component.html',
|
||||||
|
styleUrls: ['./other-applicant-details.component.scss']
|
||||||
|
})
|
||||||
|
export class OtherApplicantDetailsComponent implements OnInit {
|
||||||
|
pageTitle: string ="Add Other Applicant Details";
|
||||||
|
public _OtherForm: FormGroup;
|
||||||
|
applicantInfo:any={'pd_co_applicant_id':"0",'applicant_name':'','company_name':''};
|
||||||
|
|
||||||
|
constructor(private _fb: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: any, private dialogRef: MatDialogRef<OtherApplicantDetailsComponent>) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.initFormDetails();
|
||||||
|
}
|
||||||
|
|
||||||
|
// init form
|
||||||
|
initFormDetails() {
|
||||||
|
this._OtherForm = this._fb.group({
|
||||||
|
applicant_list: this._fb.array([this.createApplicant(this.applicantInfo)]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// create applicant form array
|
||||||
|
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]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// add more
|
||||||
|
addMoreApplicant(){
|
||||||
|
if (this._OtherForm.invalid) {
|
||||||
|
this.validateAllFormFields(this._OtherForm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
let relationControl = <FormArray>this._OtherForm.controls['applicant_list'];
|
||||||
|
relationControl.push(this.createApplicant(this.applicantInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove
|
||||||
|
removeApplicant(intex:number){
|
||||||
|
let control = <FormArray>this._OtherForm.controls['applicant_list'];
|
||||||
|
control.removeAt(intex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// save applicant
|
||||||
|
saveApplicant(formData:any){
|
||||||
|
if (this._OtherForm.invalid) {
|
||||||
|
this.validateAllFormFields(this._OtherForm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.dialogRef.close({
|
||||||
|
data:formData.applicant_list
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// close dialogue
|
||||||
|
closeDialogue(){
|
||||||
|
this.dialogRef.close({
|
||||||
|
data:[]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate all form group and form array fields
|
||||||
|
validateAllFormFields(formGroup: any) {
|
||||||
|
Object.keys(formGroup.controls).forEach(field => {
|
||||||
|
const control = formGroup.get(field);
|
||||||
|
|
||||||
|
if (control instanceof FormControl) {
|
||||||
|
control.markAsTouched({ onlySelf: true });
|
||||||
|
} else if (control instanceof FormGroup) {
|
||||||
|
this.validateAllFormFields(control);
|
||||||
|
} else if (control instanceof FormArray) {
|
||||||
|
this.validateAllFormFields(control);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -23,6 +23,7 @@ import {BankingDetailsComponent} from './forms/banking-details/banking-details.c
|
|||||||
import {BusinessInfoComponent} from './forms/business-info/business-info.component';
|
import {BusinessInfoComponent} from './forms/business-info/business-info.component';
|
||||||
import {LenderRepresentativeComponent} from './forms/lender-representative/lender-representative.component';
|
import {LenderRepresentativeComponent} from './forms/lender-representative/lender-representative.component';
|
||||||
import {LoanDetailsComponent} from './forms/loan-details/loan-details.component';
|
import {LoanDetailsComponent} from './forms/loan-details/loan-details.component';
|
||||||
|
import {GeneralInfoComponent} from './forms/general-info/general-info.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-start-pd',
|
selector: 'app-start-pd',
|
||||||
@ -323,6 +324,13 @@ pdFullDetails:any=[];
|
|||||||
|
|
||||||
this.pdFullDetails = data.records
|
this.pdFullDetails = data.records
|
||||||
|
|
||||||
|
// manually push genral forms for test should remove code move
|
||||||
|
this.categoryFormButtons.unshift({
|
||||||
|
"form_id":18,
|
||||||
|
"form_name": 'General Information',
|
||||||
|
"isAnswered":false
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.pdMasterList = "";
|
this.pdMasterList = "";
|
||||||
@ -870,6 +878,19 @@ pdFullDetails:any=[];
|
|||||||
this.loadTemplates(this.startPD);
|
this.loadTemplates(this.startPD);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if(this.selectedFormsCategory.form_id==18){
|
||||||
|
const generaldialogRef = this.dialog.open(GeneralInfoComponent, {
|
||||||
|
data: this.pdFullDetails,
|
||||||
|
position: { right: '0'},
|
||||||
|
width:'80%',
|
||||||
|
disableClose: true
|
||||||
|
});
|
||||||
|
generaldialogRef.afterClosed()
|
||||||
|
.subscribe(dataresult => {
|
||||||
|
// this.notifier.notify('success', 'Successfully allocated.!');
|
||||||
|
this.loadTemplates(this.startPD);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,6 +72,7 @@ import {RentalInfoComponent} from "./list-pd/start-pd/forms/rental-info/rental-i
|
|||||||
import { AllocationViewMoreComponent } from './list-pd/allocation-view-more/allocation-view-more.component';
|
import { AllocationViewMoreComponent } from './list-pd/allocation-view-more/allocation-view-more.component';
|
||||||
import { PdRequirementComponent } from './list-pd/pd-requirement/pd-requirement.component';
|
import { PdRequirementComponent } from './list-pd/pd-requirement/pd-requirement.component';
|
||||||
import { GeneralInfoComponent } from './list-pd/start-pd/forms/general-info/general-info.component';
|
import { GeneralInfoComponent } from './list-pd/start-pd/forms/general-info/general-info.component';
|
||||||
|
import { OtherApplicantDetailsComponent } from './list-pd/start-pd/forms/other-applicant-details/other-applicant-details.component';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,7 +251,7 @@ const pdCustomNotifierOptions: NotifierOptions = {
|
|||||||
// AgmCoreModule.forRoot({apiKey: 'AIzaSyBtdO5k6CRntAMJCF-H5uZjTCoSGX95cdk'}), OwlDateTimeModule,
|
// AgmCoreModule.forRoot({apiKey: 'AIzaSyBtdO5k6CRntAMJCF-H5uZjTCoSGX95cdk'}), OwlDateTimeModule,
|
||||||
// OwlNativeDateTimeModule,
|
// OwlNativeDateTimeModule,
|
||||||
// ],
|
// ],
|
||||||
declarations: [RentalInfoComponent, TelePdAllocationComponent, FinancialInfoComponent, BusinessInfoComponent, EmploymentInfoComponent, StockComponent, BankingDetailsComponent, ListPdComponent, FamilyDetailsComponent, AddressComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent, PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, CurrentLoanComponent, AssetsInfoComponent, LoanDetailsComponent, OtherIncomeComponent, SupplierInfoComponent, PersonalInfoComponent, LenderRepresentativeComponent, PdReportComponent, AssessedIncomeComponent, AllocationViewMoreComponent, PdRequirementComponent, GeneralInfoComponent],
|
declarations: [RentalInfoComponent, TelePdAllocationComponent, FinancialInfoComponent, BusinessInfoComponent, EmploymentInfoComponent, StockComponent, BankingDetailsComponent, ListPdComponent, FamilyDetailsComponent, AddressComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent, PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, CurrentLoanComponent, AssetsInfoComponent, LoanDetailsComponent, OtherIncomeComponent, SupplierInfoComponent, PersonalInfoComponent, LenderRepresentativeComponent, PdReportComponent, AssessedIncomeComponent, AllocationViewMoreComponent, PdRequirementComponent, GeneralInfoComponent, OtherApplicantDetailsComponent],
|
||||||
|
|
||||||
// exports: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent],
|
// exports: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent],
|
||||||
// providers: [PdTrigerService, GetGeometricLocationService],
|
// providers: [PdTrigerService, GetGeometricLocationService],
|
||||||
@ -282,11 +283,11 @@ const pdCustomNotifierOptions: NotifierOptions = {
|
|||||||
OwlNativeDateTimeModule,
|
OwlNativeDateTimeModule,
|
||||||
],
|
],
|
||||||
// declarations: [ListPdComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent, PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, SupplierInfoComponent, PersonalInfoComponent, AssetsInfoComponent],
|
// declarations: [ListPdComponent, ManagePdComponent, MapPdViewComponent, AddPdComponent, ViewPdComponent, PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, InprogressPdComponent, AllPdComponent, ScheduledPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, SupplierInfoComponent, PersonalInfoComponent, AssetsInfoComponent],
|
||||||
exports: [PdAllocationComponent, SmartPdAllocationComponent, TelePdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, SupplierInfoComponent, PersonalInfoComponent, CurrentLoanComponent, LoanDetailsComponent, OtherIncomeComponent, AssetsInfoComponent, AddressComponent, FamilyDetailsComponent, BankingDetailsComponent, StockComponent, EmploymentInfoComponent, BusinessInfoComponent, FinancialInfoComponent, LenderRepresentativeComponent,RentalInfoComponent, AssessedIncomeComponent, AllocationViewMoreComponent, GeneralInfoComponent, PdRequirementComponent],
|
exports: [PdAllocationComponent, SmartPdAllocationComponent, TelePdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent, ClientInfoComponent, SupplierInfoComponent, PersonalInfoComponent, CurrentLoanComponent, LoanDetailsComponent, OtherIncomeComponent, AssetsInfoComponent, AddressComponent, FamilyDetailsComponent, BankingDetailsComponent, StockComponent, EmploymentInfoComponent, BusinessInfoComponent, FinancialInfoComponent, LenderRepresentativeComponent,RentalInfoComponent, AssessedIncomeComponent, AllocationViewMoreComponent, GeneralInfoComponent, PdRequirementComponent, OtherApplicantDetailsComponent],
|
||||||
providers: [PdTrigerService, GetGeometricLocationService],
|
providers: [PdTrigerService, GetGeometricLocationService],
|
||||||
|
|
||||||
entryComponents: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, TelePdAllocationComponent, AllocationViewMoreComponent, PersonalInfoComponent,
|
entryComponents: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, TelePdAllocationComponent, AllocationViewMoreComponent, PersonalInfoComponent,
|
||||||
ClientInfoComponent, SupplierInfoComponent, CurrentLoanComponent, LoanDetailsComponent, OtherIncomeComponent, AssetsInfoComponent, AddressComponent, FamilyDetailsComponent, BankingDetailsComponent, StockComponent, EmploymentInfoComponent, BusinessInfoComponent, FinancialInfoComponent, LenderRepresentativeComponent,RentalInfoComponent, AssessedIncomeComponent, GeneralInfoComponent, PdRequirementComponent],
|
ClientInfoComponent, SupplierInfoComponent, CurrentLoanComponent, LoanDetailsComponent, OtherIncomeComponent, AssetsInfoComponent, AddressComponent, FamilyDetailsComponent, BankingDetailsComponent, StockComponent, EmploymentInfoComponent, BusinessInfoComponent, FinancialInfoComponent, LenderRepresentativeComponent,RentalInfoComponent, AssessedIncomeComponent, GeneralInfoComponent, PdRequirementComponent, OtherApplicantDetailsComponent],
|
||||||
|
|
||||||
})
|
})
|
||||||
export class ManagePdModule {
|
export class ManagePdModule {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user