lender representative forms changes

This commit is contained in:
gandhimathi 2018-11-19 16:01:59 +05:30
parent f99edf725b
commit 013e32a095
7 changed files with 197 additions and 4 deletions

View File

@ -0,0 +1,43 @@
<mat-card style="min-height: 550px;">
<mat-card-content>
<p>Lender Representative Details</p>
<form [formGroup]="representativeForm" class="address">
<mat-form-field>
<mat-select (selectionChange)="selectedLoanChanges($event)" placeholder="Did The Lender Representative Accompany The PD Officer For PD?"
formControlName="lender_representative_accompany">
<mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option>
</mat-select>
</mat-form-field>
<div *ngIf="representativeForm.controls.lender_representative_accompany.value == 'Yes'">
<div formArrayName="lender_representative_details">
<div *ngFor="let details of representativeForm.get('lender_representative_details').controls; let i=index"
[formGroupName]="i">
<mat-form-field>
<input matInput placeholder="What Is The Name of Lender Representative Who Accompanies The PD Officer, If Any?" formControlName="lender_representative_who_accompanies" required>
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Did The Lender Representative Carry The Loan File During PD?" formControlName="lender_representative_carry_loan_files" required>
</mat-form-field>
</div>
</div>
</div>
<div fxLayout="row">
<div fxFlex="60" class="pb-0 text-sm-left">
<mat-form-field appearance="outline" style="width: 100%">
<mat-label>Remarks</mat-label>
<textarea matInput placeholder="Remarks" formControlName="representative_remarks"></textarea>
</mat-form-field>
</div>
</div>
<div style="text-align: right;">
<button type="submit" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button matTooltip="Submit" matTooltipPosition="above" type="button" (click)="submitLRForm()"><mat-icon>save</mat-icon>
</button>
</div>
</form>
</mat-card-content>
</mat-card>

View File

@ -0,0 +1,11 @@
.mat-form-field {
width: 100%;
}
// .address > * {
// width: 100%;
// }
// .matcard mat-form-field {
// margin: 0 2%;
// width:100%;
// }

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LenderRepresentativeComponent } from './lender-representative.component';
describe('LenderRepresentativeComponent', () => {
let component: LenderRepresentativeComponent;
let fixture: ComponentFixture<LenderRepresentativeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LenderRepresentativeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LenderRepresentativeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,109 @@
import {Component,OnInit,Inject,Input } from '@angular/core';
import {FormBuilder,FormGroup,Validators,FormArray, FormControl,} from '@angular/forms';
import { NotifierService } from 'angular-notifier';
/** Service */
import { PdTrigerService } from '../../../../../pd-service/pd-triger.service';
import { ActivatedRoute, Router } from "@angular/router";
@Component({
selector: 'app-lender-representative',
templateUrl: './lender-representative.component.html',
styleUrls: ['./lender-representative.component.scss']
})
export class LenderRepresentativeComponent implements OnInit {
public representativeForm: FormGroup;
private notifier: NotifierService;
@Input() pdid: number;
@Input() form_id: number;
constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute,
private router: Router,
private _pd: PdTrigerService) {
this.notifier = notifier;
}
ngOnInit() {
this.initRepresentative();
let params: any = {};
params.pd_id = this.pdid;
params.pd_form_id = this.form_id;
this._pd.retriveForm(params).subscribe(value => {
const control = <FormArray>this.representativeForm.controls['lender_representative_details'];
if (value.status == 200) {
this.representativeForm.controls['lender_representative_accompany'].setValue(value.records.lender_representative_accompany);
this.representativeForm.controls['representative_remarks'].setValue(value.records.representative_remarks);
if (value.records.lender_representative_accompany == 'Yes') {
var result = Object.keys(value.records.lender_representative_details).map(function (key) {
return value.records.lender_representative_details[key];
});
if (result.length > 0) {
result.forEach(val => {
control.push(this.createLRDetail());
});
this.representativeForm.controls['lender_representative_details'].setValue(result);
}
}
}
// else {
// control.push(this.createLRDetail());
// }
})
}
public initRepresentative(): void {
this.representativeForm = this.fb.group({
lender_representative_accompany: ['', Validators.compose([Validators.required])],
representative_remarks: ['', Validators.compose([Validators.required])],
lender_representative_details: this.fb.array([]),
});
}
selectedLoanChanges(e): void {
if (e.value == 'Yes') {
const control = <FormArray>this.representativeForm.controls['lender_representative_details'];
control.push(this.createLRDetail());
} else if (e.value == 'No') {
const arr = <FormArray>this.representativeForm.controls.lender_representative_details;
arr.removeAt(0);
}
}
createLRDetail() {
return this.fb.group({
lender_representative_who_accompanies : ['', Validators.compose([Validators.required])],
lender_representative_carry_loan_files: ['', Validators.compose([Validators.required])],
});
}
submitLRForm() {
if (!this.representativeForm.valid) {
this.validateAllFormFields(this.representativeForm);
return;
}
let records: any = {};
records.pdid = this.pdid;
records.formid = this.form_id;
records.fk_createdby = this.pdid;
records.lender_representative_accompany = this.representativeForm.controls['lender_representative_accompany'].value;
records.representative_remarks = this.representativeForm.controls['representative_remarks'].value;
if (records.lender_representative_accompany == 'Yes') {
records.lender_representative_details = this.representativeForm.controls['lender_representative_details'].value;
}
this._pd.saveForm(records).subscribe(data => {
this.notifier.notify('success', 'Saved Successfully.');
}, error => {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
})
}
validateAllFormFields(formGroup: FormGroup) {
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);
}
});
}
}

View File

@ -430,9 +430,10 @@
<ng-container *ngSwitchCase="14"> <ng-container *ngSwitchCase="14">
<app-financial-info [pdid]="startPD" [form_id]="selectedFormsCategory.form_id"></app-financial-info> <app-financial-info [pdid]="startPD" [form_id]="selectedFormsCategory.form_id"></app-financial-info>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="15">
<app-lender-representative [pdid]="startPD" [form_id]="selectedFormsCategory.form_id"></app-lender-representative>
</ng-container>
<!-- end personal type questions
-->
</ng-container> </ng-container>
</div> </div>
<!-- end form based questions --> <!-- end form based questions -->

View File

@ -59,6 +59,7 @@ import {StockComponent} from "./list-pd/start-pd/forms/stock/stock.component";
import {EmploymentInfoComponent} from "./list-pd/start-pd/forms/employment-info/employment-info.component"; import {EmploymentInfoComponent} from "./list-pd/start-pd/forms/employment-info/employment-info.component";
import {BusinessInfoComponent} from "./list-pd/start-pd/forms/business-info/business-info.component"; import {BusinessInfoComponent} from "./list-pd/start-pd/forms/business-info/business-info.component";
import {FinancialInfoComponent} from "./list-pd/start-pd/forms/financial-info/financial-info.component"; import {FinancialInfoComponent} from "./list-pd/start-pd/forms/financial-info/financial-info.component";
import { LenderRepresentativeComponent } from './list-pd/start-pd/forms/lender-representative/lender-representative.component';
import { TelePdAllocationComponent } from './list-pd/tele-pd-allocation/tele-pd-allocation.component'; import { TelePdAllocationComponent } from './list-pd/tele-pd-allocation/tele-pd-allocation.component';
@ -134,7 +135,7 @@ const pdCustomNotifierOptions: NotifierOptions = {
// AgmCoreModule.forRoot({apiKey: 'AIzaSyBtdO5k6CRntAMJCF-H5uZjTCoSGX95cdk'}), OwlDateTimeModule, // AgmCoreModule.forRoot({apiKey: 'AIzaSyBtdO5k6CRntAMJCF-H5uZjTCoSGX95cdk'}), OwlDateTimeModule,
// OwlNativeDateTimeModule, // OwlNativeDateTimeModule,
// ], // ],
declarations: [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], declarations: [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],
// exports: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent], // exports: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent],
// providers: [PdTrigerService, GetGeometricLocationService], // providers: [PdTrigerService, GetGeometricLocationService],
@ -165,7 +166,7 @@ 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], 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],
providers: [PdTrigerService, GetGeometricLocationService], providers: [PdTrigerService, GetGeometricLocationService],
entryComponents: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, TelePdAllocationComponent] entryComponents: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, TelePdAllocationComponent]
}) })

View File

@ -426,6 +426,9 @@
<ng-container *ngSwitchCase="14"> <ng-container *ngSwitchCase="14">
<app-financial-info [pdid]="startPD" [form_id]="selectedFormsCategory.form_id"></app-financial-info> <app-financial-info [pdid]="startPD" [form_id]="selectedFormsCategory.form_id"></app-financial-info>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="15">
<app-lender-representative [pdid]="startPD" [form_id]="selectedFormsCategory.form_id"></app-lender-representative>
</ng-container>
<!-- end personal type questions <!-- end personal type questions
--> -->