From 27a066b6e883ce6a8fefe41aa12063d38c031d3f Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Sat, 17 Nov 2018 16:29:53 +0530 Subject: [PATCH] client-info, other-income form changes : kdk --- .../client-info/client-info.component.html | 2 +- .../current-loan/current-loan.component.ts | 2 +- .../other-income/other-income.component.html | 2 +- .../other-income/other-income.component.ts | 26 ++++++++++++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) 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 8a7c5933b..c7e265ff5 100644 --- 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 @@ -50,7 +50,7 @@
- {{ feq.name }} + {{ feq.name }}
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.ts index 0ba8ef7fe..99521e2a6 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/current-loan/current-loan.component.ts @@ -63,7 +63,7 @@ export class CurrentLoanComponent implements OnInit { }); this.currentLoanForm.controls['loan_details'].setValue(result); } else { - control.push(this.createLoanDetail()); + // control.push(this.createLoanDetail()); } } } else { diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.html index 67ff552a5..b11c1e4ea 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.html @@ -21,7 +21,7 @@

Other Income Details

- Yes No diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts index fc5435bf7..f21f60196 100644 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts @@ -50,18 +50,22 @@ export class OtherIncomeComponent implements OnInit { console.log('value', value); const control = this.otherIncomeForm.controls['income_details']; if (value.status == 200) { + + this.otherIncomeForm.controls['other_income'].setValue(value.records.other_income); + this.otherIncomeForm.controls['otherincome_remarks'].setValue(value.records.otherincome_remarks); + if (value.records.other_income == 'Yes') { + var result = Object.keys(value.records.income_details).map(function(key) { return value.records.income_details[key]; }); - this.otherIncomeForm.controls['other_income'].setValue(value.records.other_income); - this.otherIncomeForm.controls['otherincome_remarks'].setValue(value.records.otherincome_remarks); if (result.length > 0) { result.forEach(val => { control.push(this.createDetail()); }); this.otherIncomeForm.controls['income_details'].setValue(result); } else { - control.push(this.createDetail()); + // control.push(this.createDetail()); + } } } else { control.push(this.createDetail()); @@ -75,6 +79,16 @@ export class OtherIncomeComponent implements OnInit { income_details: this.fb.array([]) }); } + + selectedLoanChanges(e): void { + if (e.value == 'Yes') { + const control = this.otherIncomeForm.controls['income_details']; + control.push(this.createDetail()); + } else if (e.value == 'No') { + const arr = this.otherIncomeForm.controls.income_details; + arr.removeAt(0); + } + } createDetail() { return this.fb.group({ source: ['', Validators.compose([Validators.required])], @@ -111,7 +125,11 @@ export class OtherIncomeComponent implements OnInit { records.fk_createdby = this.pdid; records.other_income = this.otherIncomeForm.controls['other_income'].value; records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value; - records.income_details = this.otherIncomeForm.controls['income_details'].value; + + if (this.otherIncomeForm.controls['other_income'].value == 'Yes') { + records.income_details = this.otherIncomeForm.controls['income_details'].value; + } + console.log('data', records); this._pd.saveForm(records).subscribe(data => { console.log('data', data);