From 77376c582209f38c7c7d5f38f7fd97150e4046a0 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Tue, 16 Apr 2019 20:12:48 +0530 Subject: [PATCH] Other Validation : ps --- .../assets-info/assets-info.component.html | 20 ++- .../assets-info/assets-info.component.ts | 130 +++++++++++------- .../banking-details.component.html | 7 +- .../banking-details.component.ts | 66 ++++++--- .../business-assets-info.component.html | 29 ++-- .../business-assets-info.component.ts | 94 +++++++------ .../business-banking-details.component.html | 7 +- .../business-banking-details.component.ts | 61 ++++++-- .../client-info/client-info.component.html | 3 + .../client-info/client-info.component.ts | 26 +++- .../current-loan/current-loan.component.html | 4 + .../current-loan/current-loan.component.ts | 47 +++---- .../employment-info.component.html | 13 ++ .../employment-info.component.ts | 14 ++ .../final-remarks.component.html | 6 + .../neighbour-hood.component.html | 2 + .../other-income/other-income.component.html | 3 + .../other-income/other-income.component.ts | 45 +++++- .../start-pd/forms/stock/stock.component.html | 16 ++- .../start-pd/forms/stock/stock.component.ts | 49 +++++-- .../supplier-info.component.html | 2 + .../supplier-info/supplier-info.component.ts | 8 +- 22 files changed, 462 insertions(+), 190 deletions(-) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.html index a313c0cdc..9e8ca1f90 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/assets-info/assets-info.component.html @@ -48,7 +48,7 @@
+ (selectionChange)="setRequired($event.value,i,s,1)"> Select {{ prop.name }} @@ -57,6 +57,7 @@ + Property Type Required
@@ -76,7 +77,7 @@ + (selectionChange)="setRequired($event.value,i,s,6)"> Select {{ uom.name }} @@ -85,6 +86,7 @@ + Unit of Measurement Required
@@ -97,7 +99,9 @@
+ (selectionChange)="setRequired($event.value,i,s,5)"> + + Select {{ vehicle.vehicle_type_name }} @@ -106,6 +110,7 @@ + Vehicle Required + [compareWith]="compareObjects" (selectionChange)="setOtherOwner($event.value,i)"> {{val.name}} @@ -326,6 +333,7 @@ + Owner Name Required @@ -66,15 +68,15 @@ Yes No - + Business Activity + Required - + Remarks + Required
@@ -88,6 +90,8 @@ Owned Rented + Ownership Type + Required @@ -107,19 +111,20 @@ + [compareWith]="compareObjects" (selectionChange)="setOtherOwnerOfAddress($event.value,i)"> {{val.name}} - Asset Owned by Required + Asset Owned by Required + Asset Owned by Required @@ -202,10 +207,12 @@ + Property Type Required + Address of the Property Required @@ -230,6 +237,7 @@ + Vehicle Required @@ -289,7 +297,7 @@ {{"₹"}} {{sup.get('business_monthly_rented_amt').value | numberToWords}} Only - Monthly Rent Amount Required + Monthly Rent Amount Required @@ -302,19 +310,20 @@ + [compareWith]="compareObjects" (selectionChange)="setOtherOwnerOfAsset($event.value,i)"> {{val.name}} - Asset Owned by Required + Asset Owned by is Required + Asset Owned by is Required diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.ts index 0d1bc6b48..4e711b7d8 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.ts @@ -89,7 +89,7 @@ export class BusinessAssetsInfoComponent implements OnInit { /** init Function */ ngOnInit() { -console.clear(); + console.clear(); // this.pdTrigerService.getTypeofActivityForSuppliedInfoForm(this.pdid,'').subscribe(data => { // this.businessProfessionName = (data.status == 200) ? data.records.profession_name : '' ; // }); @@ -219,20 +219,15 @@ console.clear(); this.addressLabel[inx] = ''; this.pdTrigerService.getStateWiseCities(dataValue.state).subscribe(data => { if (data.status == 200) { - // console.log(data.records); + this.cityArr = data.records.cities; this.pinArr = data.records.pincode; - // console.log('cityArr',this.cityArr); - // console.log('pinArr',this.pinArr); - // console.log('flag',flag); + let selectedAddressType = this.m_address_type.filter(element => element.address_type_id == dataValue.address_type)[0]; let selectedState = this.m_state_for_address.filter(element => element.state_id == dataValue.state)[0]; let selectedCity = this.cityArr.filter(element => element.city_id == dataValue.city)[0]; let selectedPincode = this.pinArr.filter(element => element.pincode_id == dataValue.pincode)[0]; - // console.log(selectedCity); - // console.log(selectedPincode); - // console.log(selectedCity[0].city_name); - // console.log(selectedPincode[0].pincode); + let addressType = dataValue.address_type != 1 ? selectedAddressType.address_type : dataValue.address_type_others; let address = dataValue.address + ' , ' + selectedCity.city_name + ','+selectedState.name +'-' + (dataValue.pincode == 1 ? dataValue.pincode_others : selectedPincode.pincode); @@ -601,8 +596,6 @@ console.clear(); result.forEach((val, index) => { var splitted_label = val.address_label.split("/", 2); - // console.log(splitted_label) - // console.log(splitted_label[0],splitted_label[1]); let addressType = splitted_label[1] != '' ? splitted_label[1] : 'Address Type'; this.placeholderName[index] = 'Was any business activity seen at the ' + addressType + ' during PD visit?'; let vals = { @@ -789,6 +782,7 @@ console.clear(); this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); return; } else { + return; var answerFormValues = this._businessAssetsQuesFrom.value; let dataOwner_name = []; @@ -870,23 +864,34 @@ console.clear(); this.yearErrorMessage[i] = ''; } } - setRequiredValidation2(value, ParInx, ChdInx, flag) { - if (flag == 4) { - let ParCtrls = this._businessAssetsQuesFrom.controls.assets_details; - let ChdCtrls: any = ParCtrls.controls[ParInx]; + setOtherOwnerOfAsset(value, ParInx) { + + let ParCtrls = this._businessAssetsQuesFrom.controls.business_assets_details; + let ChdCtrls: any = ParCtrls.controls[ParInx]; + let Avaliablity = 1; - value.forEach(option => { - if (option.id == 0 && option.group_id == 2) { - Avaliablity = option.id; - } - }); - if (Avaliablity == 0) { + if (value.length > 0) { + + value.forEach(option => { + if (option.id == 0 && option.group_id == 2) { + Avaliablity = option.id; + } + }); + } + + + if (Avaliablity == 0) { + ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]); this.isOtherOwner[ParInx] = true; - } else { - + + + + + } else if (Avaliablity == 1) { + ChdCtrls.controls.business_name_of_the_other_owner.setValue(''); ChdCtrls.controls.business_name_of_the_other_owner.clearValidators(); this.isOtherOwner[ParInx] = false; @@ -894,33 +899,44 @@ console.clear(); ChdCtrls.controls.business_name_of_the_other_owner.updateValueAndValidity(); - } - if (flag == 8) { - let ParCtrls = this._businessAssetsQuesFrom.controls.business_assets_for_address; - let ChdCtrls: any = ParCtrls.controls[ParInx]; - let Avaliablity = 1; - value.forEach(option => { - if (option.id == 0 && option.group_id == 2) { - Avaliablity = option.id; - } - }); + } + setOtherOwnerOfAddress(value, ParInx) { + + let ParCtrls = this._businessAssetsQuesFrom.controls.business_assets_for_address; + + let ChdCtrls: any = ParCtrls.controls[ParInx]; + + let Avaliablity = 1; + + if (value.length > 0) { + + value.forEach(option => { + if (option.id == 0 && option.group_id == 2) { + Avaliablity = option.id; + } + }); + + } + if (Avaliablity == 0) { - + ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]); - this.isOtherOwnerForAddress[ParInx] = true; - } else { - + this.isOtherOwnerForAddress[ParInx] = true; + + } else if (Avaliablity == 1) { + ChdCtrls.controls.business_name_of_the_other_owner.setValue(''); ChdCtrls.controls.business_name_of_the_other_owner.clearValidators(); this.isOtherOwnerForAddress[ParInx] = false; - } + } + ChdCtrls.controls.business_name_of_the_other_owner.updateValueAndValidity(); - } } + setRequiredValidation(value, item, flag) { if (flag == 1) { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.html index fa7cce6a8..7d98bcf20 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.html @@ -32,7 +32,7 @@ + [compareWith]="compareObjects"> {{val.name}} @@ -44,11 +44,11 @@ style="width:45%"> + Applicant Name Required - + Select {{ btLen.lender_name }} @@ -57,6 +57,7 @@ + Bank Name Required diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts index 17c01f945..f0d9288f7 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-banking-details/business-banking-details.component.ts @@ -232,6 +232,48 @@ export class BusinessBankingDetailsComponent implements OnInit { } bankSubmit() { + + const control = this.bankingForm.controls.itemRows; + let CtrlLength = control.controls.length; + + if (CtrlLength > 0) { + let cnt = 0; + while(cnt < CtrlLength){ + + let ChildCtrl : any = control.controls[cnt]; + + let Avaliablity = ChildCtrl.controls.applicant_name.value != '' + ? ChildCtrl.controls.applicant_name.value.id == 0 && ChildCtrl.controls.applicant_name.value.group_id == 2 + ? ChildCtrl.controls.applicant_name.value.id : 1 + : 1 ; + + if (Avaliablity == 0) { + + ChildCtrl.controls.other_applicant.setValidators([Validators.required]); + } else if (Avaliablity == 1) { + + ChildCtrl.controls.other_applicant.setValue(''); + ChildCtrl.controls.other_applicant.clearValidators(); + } + + ChildCtrl.controls.other_applicant.updateValueAndValidity(); + + + if(ChildCtrl.controls.bank_name.value == 1){ + ChildCtrl.controls.other_bank.setValidators([Validators.required]);} + else{ ChildCtrl.controls.other_bank.clearValidators(); + ChildCtrl.controls.other_bank.setValue(''); + } + ChildCtrl.controls.other_bank.updateValueAndValidity(); + cnt++; + } + } + + if (!this.bankingForm.valid) { + this.validateAllFormFields(this.bankingForm); + this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); + return; + } let records: any = {}; records.parent_pdid = this.parent_pdid; records.pdid = this.pdid; @@ -256,13 +298,15 @@ export class BusinessBankingDetailsComponent implements OnInit { }); } - validateAllFormFields(formGroup: FormGroup) { + 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); } }); } @@ -360,15 +404,16 @@ export class BusinessBankingDetailsComponent implements OnInit { setRequiredValidation(value, item, flag) { if (flag == 1) { - value == 0 - ? item.controls.other_applicant.setValidators([Validators.required]) - : item.controls.other_applicant.clearValidators(); - item.controls.other_applicant.updateValueAndValidity(); + if(value == 0){ + item.controls.other_applicant.setValidators([Validators.required]); } + else{ item.controls.other_applicant.clearValidators(); + item.controls.other_applicant.setValue(''); } + item.controls.other_applicant.updateValueAndValidity(); } if (flag == 2) { - value == 1 - ? item.controls.other_bank.setValidators([Validators.required]) - : item.controls.other_bank.clearValidators(); + if(value == 1){ + item.controls.other_bank.setValidators([Validators.required]);} + else{ item.controls.other_bank.clearValidators(); item.controls.other_bank.setValue('') } item.controls.other_bank.updateValueAndValidity(); } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.html index 09101b0c8..bc684f16c 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.html @@ -63,6 +63,7 @@ + Person Designatione Required
@@ -195,6 +196,7 @@ + Person Designation Required
@@ -330,6 +332,7 @@ + Person Designation Required
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.ts index 7eb8e8122..9a8296e9d 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/client-info/client-info.component.ts @@ -9,6 +9,7 @@ import { import { FormBuilder, FormGroup, + FormControl, Validators, FormArray, } from '@angular/forms'; @@ -684,18 +685,18 @@ export class ClientInfoComponent implements OnInit { selectedPersonDesignation(items, e, flag) { if (flag == 1) { - e == 1 ? items.controls['other_person_designation'].setValidators([Validators.required]) - : items.controls['other_person_designation'].clearValidators(), items.controls['other_person_designation'].setValue(''); + if(e == 1){ items.controls['other_person_designation'].setValidators([Validators.required]); } + else{ items.controls['other_person_designation'].clearValidators(); items.controls['other_person_designation'].setValue('');} items.controls['other_person_designation'].updateValueAndValidity(); } else if (flag == 2) { - e == 1 ? items.controls['other_person_designation'].setValidators([Validators.required]) - : items.controls['other_person_designation'].clearValidators(), items.controls['other_person_designation'].setValue(''); + if(e == 1){ items.controls['other_person_designation'].setValidators([Validators.required]);} + else{ items.controls['other_person_designation'].clearValidators(); items.controls['other_person_designation'].setValue('');} items.controls['other_person_designation'].updateValueAndValidity(); } else if (flag == 3) { - e == 1 ? items.controls['other_person_designation'].setValidators([Validators.required]) - : items.controls['other_person_designation'].clearValidators(), items.controls['other_person_designation'].setValue(''); + if(e == 1){ items.controls['other_person_designation'].setValidators([Validators.required]); } + else{ items.controls['other_person_designation'].clearValidators(), items.controls['other_person_designation'].setValue('');} items.controls['other_person_designation'].updateValueAndValidity(); } } @@ -748,5 +749,16 @@ export class ClientInfoComponent implements OnInit { // } // ] // } - + 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); + } + }); +} } diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html index 64f45ff74..825a3c6d2 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.html @@ -59,6 +59,7 @@ + Loan Type Required + Lender Required @@ -230,6 +241,7 @@ {{"₹"}} {{employmentForm.controls['bonus_incentive'].value | numberToWords}} Only + Bonus or Incentive Required @@ -252,6 +264,7 @@ + Bonus Type Others Required
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts index 6c4950b7f..f1091d8b2 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/employment-info/employment-info.component.ts @@ -427,6 +427,7 @@ export class EmploymentInfoComponent implements OnInit { if (!this.employmentForm.valid) { + this.validateAllFormFields(this.employmentForm); this.notifier.notify('warning', 'Please Fill/Correct All Mandatory Fields.!'); return; } @@ -511,6 +512,19 @@ export class EmploymentInfoComponent implements OnInit { // } // } + validateAllFormFields(formGroup: any) { + console.log('validateAllFormFields'); + 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); + } + }); + } + + checkWorkingExperiences(){ // this.workExperienceErrorFlag = (+this.employmentForm.controls.total_business_experience.value ) <= (+this.employmentForm.controls.how_long_year.value) ? true : false; // this.workExperienceFlag = (+this.employmentForm.controls.total_business_experience.value ) < (+this.employmentForm.controls.how_long_year.value) ? false : true; diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.html index 1007ed80f..459ce95b2 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/final-remarks/final-remarks.component.html @@ -22,6 +22,7 @@
+ Customer Behaviour Required @@ -35,6 +36,7 @@ Not Suited
+ Service Provided Required
@@ -48,6 +50,7 @@
+ PD Officers Recommendation Required @@ -57,6 +60,7 @@ + Reasons Required