From c8a2b1840a5fa7bae8111dd80ad550bb3c87d4d7 Mon Sep 17 00:00:00 2001 From: Akisha Date: Fri, 23 Nov 2018 16:43:41 +0530 Subject: [PATCH] RENTAL FORM ADDED --- ng6-seed/package-lock.json | 28 ++- .../forms/address/address.component.html | 4 +- .../rental-info/rental-info.component.html | 190 ++++++++++++++++++ .../rental-info/rental-info.component.scss | 27 +++ .../rental-info/rental-info.component.ts | 167 +++++++++++++++ .../list-pd/start-pd/start-pd.component.html | 12 +- .../list-pd/start-pd/start-pd.component.ts | 3 + .../manage-pd/manage-pd.module.ts | 8 +- 8 files changed, 424 insertions(+), 15 deletions(-) create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.html create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.scss create mode 100644 ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts diff --git a/ng6-seed/package-lock.json b/ng6-seed/package-lock.json index 0b81ab213..ed7e8f852 100644 --- a/ng6-seed/package-lock.json +++ b/ng6-seed/package-lock.json @@ -4294,12 +4294,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4314,17 +4316,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4441,7 +4446,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4453,6 +4459,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4467,6 +4474,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4474,12 +4482,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4498,6 +4508,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4578,7 +4589,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4590,6 +4602,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4711,6 +4724,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html index 78cda05de..c92d835ae 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.html @@ -54,7 +54,7 @@

Neighbourhood

-
+
{{m_neighbourStatus}} - + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.html new file mode 100644 index 000000000..c2aecc047 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.html @@ -0,0 +1,190 @@ + + +

Rental Information Form

+
+ + + + + + + Applicant + co-applicant + Parental + + + + + Residential/commercial + other + + + + +
+ + + + +
{{i+1}} Rental Home Details
+
+ + +
+ + + Complete address of the property + + + + + + + + + + + + + + + Yes + No + + +
+ + + + + + + + + + + + + + + + + Yes + No + + +
+ + +

How is rent received? (Is it in bank or cash, how much in which mode)

+
+ + + + + + + + +
+ + + + + + + + + + + + +

Details of the tenants (eg Name and Mobile No and other details)

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + Yes + No + + + + + +
+ +
+
+
+ +
+
+
+
+ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.scss new file mode 100644 index 000000000..79de302fd --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.scss @@ -0,0 +1,27 @@ +.address { + display: flex; + padding: 0 2%; + flex-direction: column; +} + +.address > * { + width: 100%; +} +.matcard mat-form-field { + margin: 0 2%; + width:40%; +} +.address .button { + float: right; + width: 10px; + background: #62B013; + color: white; +} +mat-form-field { + width: 27%; + margin: 0 2%; +} +.fields mat-form-field { + width: 45%; + margin: 0 2%; +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts new file mode 100644 index 000000000..3b5741e70 --- /dev/null +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/rental-info/rental-info.component.ts @@ -0,0 +1,167 @@ +import {Component, OnInit, Input, Output} from '@angular/core'; +import {FormBuilder, FormGroup, Validators, FormControl, FormArray} from '@angular/forms'; +import {NotifierService} from 'angular-notifier'; +import {PdTrigerService} from './../../../../../pd-service/pd-triger.service'; +import {Key} from 'protractor'; + +@Component({ + selector: 'app-rental-info', + templateUrl: './rental-info.component.html', + styleUrls: ['./rental-info.component.scss'] +}) +export class RentalInfoComponent implements OnInit { + + // @Input() pdid: string; + // @Input() pd_all_details: any; + // form_id: number; + @Input() pdid: number; + @Input() form_id: number; + step: number; + + public rentalForm: FormGroup; + tenantsList: FormArray; + propertyList: FormGroup; + private notifier: NotifierService; + + constructor(notifier: NotifierService, private _fb: FormBuilder, private _pd: PdTrigerService) { + this.notifier = notifier; + // this.form_id = 3; + } + + ngOnInit() { + this.step = 0; + this.inintRentalForm(); + this.createpropertyArray(); + let params: any = {}; + params.pd_id = this.pdid; + params.pd_form_id = this.form_id; + this._pd.retriveForm(params).subscribe(value => { + let subArray: any; + const control = this.rentalForm.controls['rental_home']; + if (value.status == 200) { + let rentalinfo = value.records; + var result = Object.keys(value.records.rental_home).map(function (key) { + return value.records.rental_home[key]; + }); + if (result.length == 0) { + const control = this.rentalForm.controls['rental_home']; + control.push(this.createpropertyArray()); + } else { + result.forEach((datas, index) => { + control.push(this.createpropertyArray()); + const parentControl = this.rentalForm.controls['rental_home']['controls'][index]; + const sub = parentControl.controls['details_tenants']; + console.log('control', parentControl); + subArray = Object.keys(datas.details_tenants).map(function (key) { + return datas.details_tenants[key]; + }); + if (subArray.length > 0) { + subArray.forEach((val) => { + console.log('val', val); + sub.push(this.createTenatsArray()); + }) + sub.removeAt(0); + } + datas.details_tenants = subArray; + }); + } + rentalinfo.rental_home = result; + rentalinfo.pdid = this.pdid; + rentalinfo.formid = this.form_id; + rentalinfo.fk_createdby = this.pdid; + this.rentalForm.setValue(rentalinfo); + } else { + control.push(this.createpropertyArray()); + } + }); + } + + inintRentalForm() { + this.rentalForm = this._fb.group({ + pdid: this.pdid, + formid: this.form_id, + fk_createdby: this.pdid, + person_met: ['', Validators.compose([Validators.required])], + property_own: ['', Validators.compose([Validators.required])], + nature_property: ['', Validators.compose([Validators.required])], + rental_home: this._fb.array([]) + }); + } + + createpropertyArray() { + this.propertyList = this._fb.group({ + complete_add: ['', Validators.compose([Validators.required])], + area_of_property: ['', Validators.compose([Validators.required])], + structure_property: ['', Validators.compose([Validators.required])], + total_room: ['', Validators.compose([Validators.required])], + is_rent: ['', Validators.compose([Validators.required])], + date_agreement: [''], + date_validity: [''], + rent_agreement: [''], + actual_rent: [''], + photo_areegment: [''], + bank: ['', Validators.compose([Validators.required])], + cash: ['', Validators.compose([Validators.required])], + rent_each_floor: ['', Validators.compose([Validators.required])], + total_rent: ['', Validators.compose([Validators.required])], + related_doc_owner: ['', Validators.compose([Validators.required])], + property_photographs: ['', Validators.compose([Validators.required])], + third_party_check: ['', Validators.compose([Validators.required])], + details_tenants: this._fb.array([this.createTenatsArray()]), + }); + return this.propertyList; + } + + createTenatsArray() { + return this._fb.group({ + name: ['', Validators.compose([Validators.required])], + mobile_no: ['', Validators.compose([Validators.required])], + tenants_seen: ['', Validators.compose([Validators.required])], + tenants_con_owner: ['', Validators.compose([Validators.required])], + staying_since: ['', Validators.compose([Validators.required])], + rent_paid: ['', Validators.compose([Validators.required])], + }); + } + + addProperty(event) { + event.stopPropagation(); + + const control = this.rentalForm.controls['rental_home']; + control.push(this.createpropertyArray()); + let length = control.length; + this.step = length - 1; + } + + deleteProperty(index) { + const control = this.rentalForm.controls['rental_home']; + control.removeAt(index); + } + + addTenant(parentIndex:number) { + const parentControl = this.rentalForm.controls['rental_home']['controls'][parentIndex]; + const control = parentControl.controls['details_tenants']; + console.log(parentControl); + console.log(control); + control.push(this.createTenatsArray()); + } + + deleteTenant(idx, parentIndex) { + const parentControl = this.rentalForm.controls['rental_home']['controls'][parentIndex]; + const control = parentControl.controls['details_tenants']; + control.removeAt(idx); + } + + rentalSubmit() { + if (!this.rentalForm.valid) { + return; + } + console.log('form', this.rentalForm.value); + let records = this.rentalForm.value; + this._pd.saveForm(records).subscribe(data => { + console.log('data', data); + this.notifier.notify('success', 'Saved Successfully.'); + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + }) + } +} \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html index c7af108fe..b426f5d57 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.html @@ -31,9 +31,12 @@ {{ (formButton.form_name.length>17)? (formButton.form_name | slice:0:17)+'..':(formButton.form_name) }} - - + + + + + @@ -433,9 +436,12 @@ - + + +
+ diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts index 627291c50..34c87317c 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/start-pd.component.ts @@ -29,6 +29,7 @@ export class StartPdComponent implements OnInit, OnDestroy { answerList: any = []; ansPDList: any = []; relationDetails: any = [1]; + rentalDetail: any = { form_id: "16", form_name: "Rental Information", isAnswered: true} // errorMessage:any; // selectedCategory:any=[]; // categoryList: any=[]; @@ -294,6 +295,7 @@ pdFullDetails:any=[]; this.pdMasterList=data.records.pdmaster_details; this.categoryList=data.records.question_answers; this.categoryFormButtons = data.records.template_forms; + console.log('formButtons', this.categoryFormButtons); let filterApplicantName= data.records.pdapplicants_detials.filter(item => item.applicant_type == 1); this.mainApplicantName = filterApplicantName[0].applicant_name; this.currentPDStatus = data.records.pdmaster_details.pd_status; @@ -625,6 +627,7 @@ pdFullDetails:any=[]; OnSelectDirectForms(details: any) { this.formsCategoryEnable = true; this.selectedFormsCategory = details; + console.log('select..', this.selectedFormsCategory); } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts index bc35c864e..40124a274 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.module.ts @@ -9,7 +9,7 @@ import { MatProgressBarModule, MatDialogModule, MatSortModule, MatToolbarModule, MatSelectModule, MatListModule, MatGridListModule, MatTabsModule, MatCheckboxModule, MatBadgeModule, MatExpansionModule, MatStepperModule, MatSidenavModule, MatMenuModule, MatButtonToggleModule, - MatAutocompleteModule + MatAutocompleteModule, MatDatepickerModule } from '@angular/material'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; @@ -62,6 +62,7 @@ import {FinancialInfoComponent} from "./list-pd/start-pd/forms/financial-info/fi 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 {RentalInfoComponent} from "./list-pd/start-pd/forms/rental-info/rental-info.component"; /** * Custom angular notifier options @@ -135,7 +136,7 @@ const pdCustomNotifierOptions: NotifierOptions = { // AgmCoreModule.forRoot({apiKey: 'AIzaSyBtdO5k6CRntAMJCF-H5uZjTCoSGX95cdk'}), OwlDateTimeModule, // 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, LenderRepresentativeComponent], + 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], // exports: [PdAllocationComponent, SmartPdAllocationComponent, SchedulePdComponent, EditPdApplicantComponent, EditPdMasterComponent, StartPdComponent, CompletedPdComponent, QcCompletedPdComponent], // providers: [PdTrigerService, GetGeometricLocationService], @@ -160,7 +161,8 @@ const pdCustomNotifierOptions: NotifierOptions = { ReactiveFormsModule, FileUploadModule, TreeModule, - MatDialogModule,MatSortModule, + MatDatepickerModule, + MatDialogModule,MatSortModule, NgxMatSelectSearchModule,MatTooltipModule, MatExpansionModule, AgmCoreModule.forRoot({apiKey: 'AIzaSyBtdO5k6CRntAMJCF-H5uZjTCoSGX95cdk'}),OwlDateTimeModule, OwlNativeDateTimeModule,