From c210529695648f76b4eb5ce0e3a539682aad5131 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Fri, 21 Jun 2019 18:34:06 +0530 Subject: [PATCH] address related hanges : ps --- .../forms/address/address.component.html | 35 +- .../forms/address/address.component.ts | 47 ++- .../business-assets-info.component.html | 319 ++++++++------ .../business-assets-info.component.ts | 394 +++++++++++------- 4 files changed, 493 insertions(+), 302 deletions(-) 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 dbeb3d242..12e70eb7b 100755 --- 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 @@ -65,7 +65,7 @@ - + Select {{PL.pincode}} @@ -77,9 +77,9 @@ - + Pincode Required @@ -146,7 +146,7 @@ + formControlName="alternative_pincode" (selectionChange)="setOthers($event.value,a,2)"> Select - + Pincode Required @@ -298,15 +298,30 @@ - + UOM Required + + diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts index 43ba314a1..95369ac7e 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/address/address.component.ts @@ -130,15 +130,16 @@ export class AddressComponent implements OnInit { 'state': datas.fk_state, 'city': datas.fk_city, 'pincode': datas.pincode_id, - 'pincode_others': datas.pincode_id == 1 ? datas.other_pincode :'', + // 'pincode_others': datas.pincode_id == 1 ? datas.other_pincode :'', } this.getCityAndPincodeDetails(datas.fk_state, index, 1); control.push(this.createAddresses(obj)); - // if(datas.pincode == 1) { - // let ChildCtrl: any = control.controls[index]; - // ChildCtrl.controls['pincode_others'].setValue(datas.pincode_others); - // ChildCtrl.controls['pincode_others'].updateValueAndValidity(); - // } + this.setOthers(+datas.pincode_id, index, 1); + if(datas.pincode == 1) { + let ChildCtrl: any = control.controls[index]; + ChildCtrl.controls['pincode_others'].setValue(datas.other_pincode); + ChildCtrl.controls['pincode_others'].updateValueAndValidity(); + } this.addressForm.controls.pd_location.setValue(datas.pd_location ? datas.pd_location : ''); @@ -179,6 +180,7 @@ export class AddressComponent implements OnInit { } let initiated_address_check =data.records.hasOwnProperty('is_pd_done_on_initiated_address') ? data.records.is_pd_done_on_initiated_address : true ; this.addressForm.controls.is_pd_done_on_initiated_address.setValue(initiated_address_check); + // this.addressForm.controls.was_the_company_name_board_sighted.setValue(''); this.addressForm.controls.address_form_remark.setValue(''); // else{ // control.push(this.createAddresses(null)); @@ -203,6 +205,7 @@ export class AddressComponent implements OnInit { comment_locality: ['', Validators.compose([Validators.required])], estimated_area: [''], uom: [''], + // was_the_company_name_board_sighted:['', Validators.compose([Validators.required])], address_form_remark: [''] }); } @@ -236,7 +239,6 @@ export class AddressComponent implements OnInit { /** FOR Form Field For Alternative Address Array */ createAlternativeAddresses(AddressDetails): FormGroup { if (AddressDetails != null) { - console.log('not null'); return this.fb.group({ alternative_address: [this.transformName(AddressDetails.alternative_address), Validators.compose([Validators.required])], alternative_state: [AddressDetails.alternative_state], @@ -333,6 +335,7 @@ export class AddressComponent implements OnInit { // Add and Remove The SpecifyOthers Field setOthers(e, i, flag) { + console.log(e,i,flag); switch (flag) { case 1: const control = this.addressForm.controls['addresses']; @@ -484,9 +487,6 @@ export class AddressComponent implements OnInit { records.is_pd_done_on_initiated_address = this.addressForm.controls.is_pd_done_on_initiated_address.value if (this.addressForm.controls.is_pd_done_on_initiated_address.value == true) { - if(records.addresses[0].pincode != 1){ - delete records.addresses[0].pincode_others - } records.addresses[0].address_type = this.addressForm.controls.address_type.value; if (this.addressForm.controls.address_type.value == 1) { records.addresses[0].address_type_others = this.addressForm.controls.address_type_others.value; @@ -510,9 +510,6 @@ export class AddressComponent implements OnInit { else if (this.addressForm.controls.is_pd_done_on_initiated_address.value == false) { records.alternative_addresses = this.addressForm.controls.alternative_addresses.value; records.alternative_addresses[0].address_type = this.addressForm.controls.address_type.value; - if(records.addresses[0].alternative_pincode != 1){ - delete records.addresses[0].alternative_pincode_others - } if (this.addressForm.controls.address_type.value == 1) { records.alternative_addresses[0].address_type_others = this.addressForm.controls.address_type_others.value; } @@ -532,6 +529,7 @@ export class AddressComponent implements OnInit { records.alternative_addresses[0].uom_others = this.addressForm.controls.uom_others.value; } } + // records.was_the_company_name_board_sighted = this.addressForm.controls.was_the_company_name_board_sighted.value; records.address_form_remark = this.addressForm.controls.address_form_remark.value; records.pdid = this.pdid; records.parent_pdid = this.parent_pdid; @@ -630,10 +628,16 @@ export class AddressComponent implements OnInit { 'state': datas.state, 'city': datas.city, 'pincode': datas.pincode, - 'pincode_others': datas.pincode ? datas.pincode_others : '' + // 'pincode_others': datas.pincode ? datas.pincode_others : '' } this.getCityAndPincodeDetails(datas.state, index, 1); control.push(this.createAddresses(obj)); + this.setOthers(+datas.pincode, index, 1); + if(datas.pincode == 1) { + let Ctrl: any = control.controls[index]; + Ctrl.controls['pincode_others'].setValue(datas.pincode_others); + Ctrl.controls['pincode_others'].updateValueAndValidity(); + } if (datas.address_type_others == "" || datas.address_type_others == null){ delete datas.address_type_others; @@ -686,7 +690,7 @@ export class AddressComponent implements OnInit { this.addressForm.controls.uom.setValue(datas.uom); this.setOthers(datas.uom, '', 5); - if (data.records.uom == 1) { + if (datas.uom == 1) { this.addressForm.controls.uom_others.setValue(datas.uom_others); } } @@ -716,12 +720,18 @@ export class AddressComponent implements OnInit { 'alternative_state': datas.alternative_state, 'alternative_city': datas.alternative_city, 'alternative_pincode': datas.alternative_pincode, - 'alternative_pincode_others': datas.alternative_pincode == 1 ? datas.alternative_pincode_others : '', + // 'alternative_pincode_others': datas.alternative_pincode == 1 ? datas.alternative_pincode_others : '', 'reason_for_alternative_address': datas.reason_for_alternative_address, } this.getCityAndPincodeDetails(datas.alternative_state, index, 2); alternative_address_control.push(this.createAlternativeAddresses(obj)); - + this.setOthers(+datas.alternative_pincode, index, 2); + if(datas.alternative_pincode == 1) { + let AltCtrl: any = alternative_address_control.controls[index]; + AltCtrl.controls['alternative_pincode_others'].setValue(datas.alternative_pincode_others); + AltCtrl.controls['alternative_pincode_others'].updateValueAndValidity(); + } + this.addressForm.controls.pd_location.setValue(datas.pd_location); this.addressForm.controls.address_type.setValue(datas.address_type); @@ -747,13 +757,14 @@ export class AddressComponent implements OnInit { this.addressForm.controls.estimated_area.setValue(datas.estimated_area); this.addressForm.controls.uom.setValue(datas.uom); this.setOthers(datas.uom, '', 5); - if (data.records.uom == 1) { + if (datas.uom == 1) { this.addressForm.controls.uom_others.setValue(datas.uom_others); } }); } } + // this.addressForm.controls.was_the_company_name_board_sighted.setValue(data.records.hasOwnProperty('was_the_company_name_board_sighted') ? data.records.was_the_company_name_board_sighted : ''); this.addressForm.controls.address_form_remark.setValue(data.records.address_form_remark); } else { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.html index c57b700f0..83dee25eb 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/business-assets-info/business-assets-info.component.html @@ -19,7 +19,8 @@
-
+
@@ -28,35 +29,40 @@ -
- Select Yes No - Business address Required + + Business address Required
-
+
- Year - Year + {{yearErrorMessage[i]}} - Year Required + Year Required + - Month - + Month + {{monthErrorMessage[i]}} @@ -65,20 +71,23 @@ - Yes No - Business Activity - Required + Business + Activity + Required - + Remarks - Required + Required
@@ -92,54 +101,73 @@ Owned Rented - Ownership Type Required + Ownership + Type Required - - - {{"₹"}} {{itemrow.get('business_monthly_rented_amt').value | numberToWords}} Only - Monthly Rent Amount Required + + + {{"₹"}} + {{itemrow.get('business_monthly_rented_amt').value | numberToWords}} Only + Monthly Rent Amount Required -
+
- - {{"₹"}} {{itemrow.get('business_approximate_market_value').value | numberToWords}} Only - Approximate Market Value Required + + {{"₹"}} + {{itemrow.get('business_approximate_market_value').value | numberToWords}} Only + + Approximate Market Value Required - + {{val.group_id != 2 ? val.name : val.name | titlecase}} - Asset Owned by Required + Asset + Owned by Required - - Asset Owned by Required + + Asset + Owned by Required Age of Asset in Years + minlength="1" maxlength="2" OnlyNumber type="text" + (keyup)="calculateVintagePurchase($event.target.value,i,3)"> Purchase Year - +
@@ -147,8 +175,10 @@
- - + + Select Yes No @@ -174,16 +204,19 @@
-
+
- + Select - {{ + {{ asset.name | titlecase }} @@ -193,7 +226,8 @@
-
+
@@ -201,20 +235,31 @@ Select - + {{m_address_type.address_type}} - - - Property Type Required + + + Property + Type Required - - - Address of the Property Required + + + + + {{address.value}} + +
@@ -223,7 +268,8 @@
-
+
@@ -231,15 +277,17 @@ Select - {{ + {{ vehicle.vehicle_type_name }} - - Vehicle Required + + + Vehicle Required @@ -253,12 +301,14 @@
-
+
- +
@@ -268,13 +318,15 @@
-
+
- - Asset's Description Required + + + Asset's Description Required
@@ -292,60 +344,80 @@ Owned Rented - Ownership Type Required + + Ownership Type Required - - - {{"₹"}} {{sup.get('business_monthly_rented_amt').value | numberToWords}} Only - Monthly Rent Amount Required + + + {{"₹"}} + {{sup.get('business_monthly_rented_amt').value | numberToWords}} Only + + Monthly Rent Amount Required
-
+
- - {{"₹"}} {{sup.get('business_approximate_market_value').value | numberToWords}} Only - Approximate Market Value Required + + {{"₹"}} + {{sup.get('business_approximate_market_value').value | numberToWords}} Only + + + Approximate Market Value Required - + - {{val.group_id != 2 ? val.name : val.name | titlecase}} + {{val.group_id != 2 ? val.name : val.name | titlecase}} - Asset Owned by is Required + + Asset Owned by is Required - - Asset Owned by is Required + + Asset + Owned by is Required Age of Asset in Years - + Purchase Year - +
- +
-
-
@@ -385,42 +458,45 @@ - -
-
-
-
-
-
-
{{doc.document_name}} -
-
-
-
+ +
+
+
+
+
+
+
{{doc.document_name}} +
+
-
-
-
-
-
- - picture_as_pdf - {{doc.document_title}} - -
-
-
+
+
+
+
+
+
+
+ + picture_as_pdf + {{doc.document_title}} +
+
+
- - -

No Files

-
-
+
+ + +

No Files

+
+ @@ -429,12 +505,13 @@
Remarks - +
-
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 404f65282..0d605734c 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 @@ -44,12 +44,12 @@ export class BusinessAssetsInfoComponent implements OnInit { yearErrorMessage: any = []; monthErrorMessage: any = []; currentYear: any = new Date().getFullYear(); - addressLabel: any = []; + // addressLabel: any = []; + addressList: any = []; /**Declaration of Dropdown And Array */ public applicants: any; - public m_any_asset_loan_type = [{ 'value': "yes", 'viewValue': "Yes" }, - { 'value': "no", 'viewValue': "No" }] + public m_any_asset_loan_type = [{ 'value': "yes", 'viewValue': "Yes" }, { 'value': "no", 'viewValue': "No" }] public m_assets_type = []; public m_propertyType = []; public m_address_type = []; @@ -63,7 +63,7 @@ export class BusinessAssetsInfoComponent implements OnInit { existCompanyList: any = []; mergeCompanyApplicant: any = []; endUserList = []; - address_type : any ; + address_type: any; /**Constructor of the class */ constructor( notifier: NotifierService, @@ -89,7 +89,8 @@ export class BusinessAssetsInfoComponent implements OnInit { documentsAndFilesList: any = []; /** init Function */ ngOnInit() { - console.clear(); + + console.clear(); // this.pdTrigerService.getTypeofActivityForSuppliedInfoForm(this.pdid,'').subscribe(data => { // this.businessProfessionName = (data.status == 200) ? data.records.profession_name : '' ; // }); @@ -114,7 +115,8 @@ export class BusinessAssetsInfoComponent implements OnInit { this.mergeCompanyApplicant.push({ groupName: 'APPLICANTS', groupValues: modifyApplicantList }) } - }) + }); + this.getM_State_For_Address(); this.getPdSupplierFormDetails(); this.getM_Assets_Type(); @@ -122,29 +124,32 @@ export class BusinessAssetsInfoComponent implements OnInit { this.getM_Address_Type(); this.getM_Vehicle_Type(); this.getM_Address_Type(); - this.pdTrigerService.retriveFile(this.pdid,'22',this.company_id).subscribe(data => { - if (data.status == 200) { - if(data.records.length>0){ - data.records.forEach((val, index) => { - let splitted = val.pd_document_name.split("."); - let DocumentsAndFiles = { - 'document_name': val.pd_document_name, - 'document_title': val.pd_document_title, - 'document': val.doc_url, - 'document_type' : splitted[1] == 'pdf'?'pdf':'image' - } - this.documentsAndFilesList.push(DocumentsAndFiles); - }); - } - } - else{ - this.documentsAndFilesList = []; - } - }); - - } - getM_State_For_Address(){ + this.pdTrigerService.retriveFile(this.pdid, '22', this.company_id).subscribe(data => { + if (data.status == 200) { + if (data.records.length > 0) { + data.records.forEach((val, index) => { + let splitted = val.pd_document_name.split("."); + let DocumentsAndFiles = { + 'document_name': val.pd_document_name, + 'document_title': val.pd_document_title, + 'document': val.doc_url, + 'document_type': splitted[1] == 'pdf' ? 'pdf' : 'image' + } + this.documentsAndFilesList.push(DocumentsAndFiles); + }); + } + } + else { + this.documentsAndFilesList = []; + } + }); + + } + /** init Function Ends Here */ + + /** State Master For Addresses */ + getM_State_For_Address() { this.pdTrigerService.getAllMasterDatas('STATE').subscribe( data => { this.m_state_for_address = data.records.filter(data => data.isactive == 1); @@ -192,9 +197,10 @@ export class BusinessAssetsInfoComponent implements OnInit { this.m_vehicle_type = data.records.filter(data => data.is_active == 1); }) } - + //Get Data Based on PDID and FORMID apiLoadFinish: boolean = false; + getPdSupplierFormDetails() { let reqparams: any = {}; reqparams.parent_pdid = this.parent_pdid; @@ -214,10 +220,10 @@ export class BusinessAssetsInfoComponent implements OnInit { } else { // this.noRecordFound = true; } - } - ); + }); } - loadaddresses() { + + loadaddresses(flag) { let params: any = {}; params.parent_pdid = this.parent_pdid; @@ -227,71 +233,118 @@ export class BusinessAssetsInfoComponent implements OnInit { this.pdTrigerService.retriveForm(params).subscribe(data => { if (data.status == 200) { + if(flag == 1){ + let initiated_address_check = data.records.hasOwnProperty('is_pd_done_on_initiated_address') ? data.records.is_pd_done_on_initiated_address : true; + this.addressList.push({ key_name: 'initiate_address', value: data.records.addresses[0].address, description: 'Initiated Address' }); + if (initiated_address_check == false ) { + this.addressList.push({ key_name: 'alternative_addresses', value: data.records.alternative_addresses[0].alternative_address, description: 'Alternative Address' }); + } + } + else if(flag == 2){ let dataOfAddress = data.records.addresses.filter(item => item.isactive == 1); - + this.addressList.push({ key_name: 'initiate_address', value: data.records.addresses[0].address, description: 'Initiated Address' }); + let initiated_address_check = data.records.hasOwnProperty('is_pd_done_on_initiated_address') ? data.records.is_pd_done_on_initiated_address : true; // // const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; - - if (data.records.addresses.length > 0) { + if (initiated_address_check == true && data.records.addresses.length > 0) { data.records.addresses.forEach((dataValue, inx) => { - - this.addressLabel[inx] = ''; this.pdTrigerService.getStateWiseCities(dataValue.state).subscribe(data => { if (data.status == 200) { - - this.cityArr = data.records.cities; - this.pinArr = data.records.pincode; - - 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]; - - let addressType = dataValue.address_type != 1 ? selectedAddressType.address_type : dataValue.address_type_others; - this.address_type = addressType; - let address = dataValue.address + ' , ' + selectedCity.city_name + ','+selectedState.name +'-' + (dataValue.pincode == 1 ? dataValue.pincode_others : selectedPincode.pincode); - - this.placeholderName[inx] = 'Was any business activity seen at the ' + addressType + ' during PD visit?'; - let addressLabel = address + ' / ' + addressType; - let vals = { - address_label: addressLabel, - business_years: '', - business_month: '', - business_address_availability: '', - business_is_pd_visited: '', - business_pd_visited_remark: '', - business_approximate_market_value: '', - business_ownership_type: '', - business_monthly_rented_amt: '', - business_name_of_the_owner: '', - business_name_of_the_other_owner: '', - business_vintage: '', - business_purchase_year: '', - business_emi: '' - } - const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; - control.push(this.initBusinessAddressDetailsWithdata(vals)); + + this.cityArr = data.records.cities; + this.pinArr = data.records.pincode; + + 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]; + + let addressType = dataValue.address_type != 1 ? selectedAddressType.address_type : dataValue.address_type_others; + this.address_type = addressType; + let address = dataValue.address + ' , ' + selectedCity.city_name + ',' + selectedState.name + '-' + (dataValue.pincode == 1 ? dataValue.pincode_others : selectedPincode.pincode); + + this.placeholderName[inx] = 'Was any business activity seen at the ' + addressType + ' during PD visit?'; + let addressLabel = address + ' / ' + addressType; + let vals = { + address_label: addressLabel, + business_years: '', + business_month: '', + business_address_availability: '', + business_is_pd_visited: '', + business_pd_visited_remark: '', + business_approximate_market_value: '', + business_ownership_type: '', + business_monthly_rented_amt: '', + business_name_of_the_owner: '', + business_name_of_the_other_owner: '', + business_vintage: '', + business_purchase_year: '', + business_emi: '' + } + const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; + control.push(this.initBusinessAddressDetailsWithdata(vals)); } }); }); - } - else { + + } else if (initiated_address_check == false && data.records.alternative_addresses.length > 0) { + this.addressList.push({ key_name: 'alternative_addresses', value: data.records.alternative_addresses[0].alternative_address, description: 'Alternative Address' }); + data.records.alternative_addresses.forEach((dataValue, inx) => { + this.pdTrigerService.getStateWiseCities(dataValue.alternative_state).subscribe(data => { + if (data.status == 200) { + + this.cityArr = data.records.cities; + this.pinArr = data.records.pincode; + + 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.alternative_state)[0]; + let selectedCity = this.cityArr.filter(element => element.city_id == dataValue.alternative_city)[0]; + let selectedPincode = this.pinArr.filter(element => element.pincode_id == dataValue.alternative_pincode)[0]; + + let addressType = dataValue.address_type != 1 ? selectedAddressType.address_type : dataValue.address_type_others; + this.address_type = addressType; + let address = dataValue.alternative_address + ' , ' + selectedCity.city_name + ',' + selectedState.name + '-' + (dataValue.alternative_pincode == 1 ? dataValue.alternative_pincode_others : selectedPincode.pincode); + + this.placeholderName[inx] = 'Was any business activity seen at the ' + addressType + ' during PD visit?'; + let addressLabel = address + ' / ' + addressType; + let vals = { + address_label: addressLabel, + business_years: '', + business_month: '', + business_address_availability: '', + business_is_pd_visited: '', + business_pd_visited_remark: '', + business_approximate_market_value: '', + business_ownership_type: '', + business_monthly_rented_amt: '', + business_name_of_the_owner: '', + business_name_of_the_other_owner: '', + business_vintage: '', + business_purchase_year: '', + business_emi: '' + } + const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; + control.push(this.initBusinessAddressDetailsWithdata(vals)); + } + }); + }); + } else { const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; control.push(this.initBusinessAddressDetails()); } - } + }} else { const control = this._businessAssetsQuesFrom.controls['business_assets_for_address']; control.push(this.initBusinessAddressDetails()); } }); } + // business_years: [value.business_years], // business_month: [value.business_month], // business_address_availability: [value.business_address_availability], // business_is_pd_visited: [value.business_is_pd_visited], // business_pd_visited_remark: [value.business_pd_visited_remark], // business_assets_for_address: this._formBuilder.array([]), - // business_years: [''], // business_month: [''], // business_address_availability: [''], @@ -303,6 +356,7 @@ export class BusinessAssetsInfoComponent implements OnInit { formLoadData(val) { if (val !== null) { let value = val; + this.loadaddresses(1); this._businessAssetsQuesFrom = this._formBuilder.group({ parent_pdid: [this.parent_pdid], pdid: [this.pdid], @@ -333,7 +387,7 @@ export class BusinessAssetsInfoComponent implements OnInit { business_assets_details: this._formBuilder.array([this.initBusinessDetails()]), business_assets_form_remark: [''] }); - this.loadaddresses(); + this.loadaddresses(2); } this.loadDetails = true; } @@ -364,7 +418,7 @@ export class BusinessAssetsInfoComponent implements OnInit { address_label: [''], business_years: [''], business_month: [''], - business_address_availability: ['',Validators.compose([Validators.required])], + business_address_availability: ['', Validators.compose([Validators.required])], business_is_pd_visited: [''], business_pd_visited_remark: [''], // this.createBusinessAssetsForAddress() @@ -438,6 +492,7 @@ export class BusinessAssetsInfoComponent implements OnInit { break; } } + this.removeOptionOnAutoComplete(i); } loadEquipmentManufacturingDescription() { @@ -459,17 +514,15 @@ export class BusinessAssetsInfoComponent implements OnInit { manufacturer_model_vehicle: [''], vehicle_type: [''], other_vehicle_type: [''] - }); } otherBusinessAssetsDescription() { return this._formBuilder.group({ - any_other_assets: ['',Validators.compose([Validators.required])], + any_other_assets: ['', Validators.compose([Validators.required])], }); } - loadPropertyWithData(data) { return this._formBuilder.group({ property_type: [data.property_type], @@ -486,7 +539,7 @@ export class BusinessAssetsInfoComponent implements OnInit { otherBusinessAssetsDescriptionWithData(data) { return this._formBuilder.group({ - any_other_assets: [data.any_other_assets,Validators.compose([Validators.required])], + any_other_assets: [data.any_other_assets, Validators.compose([Validators.required])], }); } @@ -595,29 +648,31 @@ export class BusinessAssetsInfoComponent implements OnInit { var result = Object.keys(data).map(function (key) { return data[key]; }); + if (result.length > 0) { result.forEach((datas, index) => { - + let Avaliablity = 1; if (datas.business_name_of_the_owner !== null) { - if (datas.business_name_of_the_owner.length > 0) { - datas.business_name_of_the_owner.forEach(option => { - if (option.id == 0 && option.group_id == 2) { - Avaliablity = option.id; - } - }); - }} + if (datas.business_name_of_the_owner.length > 0) { + datas.business_name_of_the_owner.forEach(option => { + if (option.id == 0 && option.group_id == 2) { + Avaliablity = option.id; + } + }); + } + } this.isOtherOwnerForAddress[index] = Avaliablity == 0 ? true : false; }); // for (let val of result) { result.forEach((val, index) => { - - var splitted_label = val.address_label.split("/", 2); + + var splitted_label = val.address_label.split("/", 2); let addressType = splitted_label[1] != '' ? splitted_label[1] : 'Address Type'; - this.placeholderName[index] = 'Was any business activity seen at the ' + addressType + ' during PD visit?'; - this.address_type = addressType; + this.placeholderName[index] = 'Was any business activity seen at the ' + addressType + ' during PD visit?'; + this.address_type = addressType; let vals = { address_label: val.address_label, business_years: val.business_years, @@ -652,18 +707,17 @@ export class BusinessAssetsInfoComponent implements OnInit { if (result.length > 0) { result.forEach((datas, index) => { - let Avaliablity = 1; -if(datas.business_name_of_the_owner !== null){ - if (datas.business_name_of_the_owner.length > 0) { - datas.business_name_of_the_owner.forEach(option => { - if (option.id == 0 && option.group_id == 2) { - Avaliablity = option.id; - } - }); - }} + if (datas.business_name_of_the_owner !== null) { + if (datas.business_name_of_the_owner.length > 0) { + datas.business_name_of_the_owner.forEach(option => { + if (option.id == 0 && option.group_id == 2) { + Avaliablity = option.id; + } + }); + } + } this.isOtherOwner[index] = Avaliablity == 0 ? true : false; - }); for (let val of result) { @@ -688,7 +742,6 @@ if(datas.business_name_of_the_owner !== null){ } setBusinessAssetsDetailsWithData(assets_details_mode: any, datas: any, i: any): void { - let val = i; let data = datas; @@ -709,6 +762,7 @@ if(datas.business_name_of_the_owner !== null){ let business_property_datas: any; data.forEach((datas, i) => { business_property_datas = { 'property_type': datas.property_type, 'other_property_type': datas.other_property_type, 'address_of_the_property': datas.address_of_the_property }; + this.addOptionOnAutoComplete(datas.property_type, datas.address_of_the_property, val); }); const control = (this._businessAssetsQuesFrom.controls['business_assets_details']).at(val).get('business_details') as FormArray; control.push(this.loadPropertyWithData(business_property_datas)); @@ -738,6 +792,39 @@ if(datas.business_name_of_the_owner !== null){ } } + addOptionOnAutoComplete(property_id, event, i) { + if(event != ''){ + let getList = this.addressList.map(dval => dval.value.replace(/\s/g, "").toLowerCase()); + let getkeyname = this.addressList.map(dval => dval.key_name); + let findName = this.m_address_type.find(x => x.address_type_id == property_id); + // console.log(getkeyname.indexOf(i)); + let evt = event.replace(/\s/g, "").toLowerCase(); + + let keyexist = this.addressList.find(ob => ob['key_name'] === i); + + if (keyexist === undefined || keyexist === null && !getList.includes(evt)) { + console.log('push on this'); + this.addressList.push({ key_name: i, value: event, description: findName.address_type + ' At Index ' + i }); + } + else { + let Index = getkeyname.indexOf(i); + this.addressList[Index] = { key_name: i, value: event, description: findName.address_type + ' At Index ' + i } + console.log('update on this => Index', Index); + } + + console.log('at Final add or update ', this.addressList); + } + } + + removeOptionOnAutoComplete(i) { + let getkeyname = this.addressList.map(dval => dval.key_name); + let Index = getkeyname.indexOf(i); + if (Index !== -1) { + this.addressList.splice(Index, 1); + } + console.log('at Final remove', this.addressList); + } + /** Add More Asset using Flag Both "Other Asset" And "Business Asset" */ addAssetDetails(e) { @@ -890,9 +977,9 @@ if(datas.business_name_of_the_owner !== null){ let ParCtrls = this._businessAssetsQuesFrom.controls.business_assets_details; let ChdCtrls: any = ParCtrls.controls[ParInx]; - - let Avaliablity = 1; - if (value !== null ) { + + let Avaliablity = 1; + if (value !== null) { if (value.length > 0) { value.forEach(option => { @@ -902,23 +989,23 @@ if(datas.business_name_of_the_owner !== null){ }); } } - - if (Avaliablity == 0) { - - ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]); - this.isOtherOwner[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.isOtherOwner[ParInx] = false; - } - ChdCtrls.controls.business_name_of_the_other_owner.updateValueAndValidity(); + if (Avaliablity == 0) { + + ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]); + this.isOtherOwner[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.isOtherOwner[ParInx] = false; + } + + ChdCtrls.controls.business_name_of_the_other_owner.updateValueAndValidity(); } @@ -926,12 +1013,12 @@ if(datas.business_name_of_the_owner !== null){ setOtherOwnerOfAddress(value, ParInx) { let ParCtrls = this._businessAssetsQuesFrom.controls.business_assets_for_address; - + let ChdCtrls: any = ParCtrls.controls[ParInx]; - + let Avaliablity = 1; - - if (value !== null ) { + + if (value !== null) { if (value.length > 0) { value.forEach(option => { @@ -939,23 +1026,23 @@ if(datas.business_name_of_the_owner !== null){ Avaliablity = option.id; } }); - - } - } - if (Avaliablity == 0) { - - ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]); - 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(); + } + if (Avaliablity == 0) { + + ChdCtrls.controls.business_name_of_the_other_owner.setValidators([Validators.required]); + 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(); } @@ -969,13 +1056,13 @@ if(datas.business_name_of_the_owner !== null){ item.controls.business_ownership_type.setValidators([Validators.required]); } else { - + item.controls.business_years.setValue(''); item.controls.business_month.setValue(''); item.controls.business_is_pd_visited.setValue(''); - item.controls.business_pd_visited_remark.setValue(''); + item.controls.business_pd_visited_remark.setValue(''); item.controls.business_ownership_type.setValue(''); - + item.controls.business_years.clearValidators(); item.controls.business_is_pd_visited.clearValidators(); item.controls.business_pd_visited_remark.clearValidators(); @@ -1006,12 +1093,14 @@ if(datas.business_name_of_the_owner !== null){ item.controls.business_ownership_type.updateValueAndValidity(); } - if(flag == 2){ - if(value != ''){ - item.controls.business_ownership_type.setValidators([Validators.required]);} - else{ - item.controls.business_ownership_type.setValue(''); - item.controls.business_ownership_type.clearValidators();} + if (flag == 2) { + if (value != '') { + item.controls.business_ownership_type.setValidators([Validators.required]); + } + else { + item.controls.business_ownership_type.setValue(''); + item.controls.business_ownership_type.clearValidators(); + } item.controls.business_ownership_type.updateValueAndValidity(); } if (flag == 3) { @@ -1072,10 +1161,9 @@ if(datas.business_name_of_the_owner !== null){ selectedAddressType(e: any) { this.placeholderName = 'Was any business activity seen at the ' + e + ' during PD visit?'; } - pdf(fileURL){ + pdf(fileURL) { window.open(fileURL); -} - + } /** For Docs Tab */ public viewerOptions: any = { navbar: false,