Delete this Loan Allow Delete
diff --git a/src/app/loan-edit/loan-edit.component.ts b/src/app/loan-edit/loan-edit.component.ts
index cd647aa..c8c0f63 100644
--- a/src/app/loan-edit/loan-edit.component.ts
+++ b/src/app/loan-edit/loan-edit.component.ts
@@ -4,7 +4,7 @@ import {StepperComponent} from '@progress/kendo-angular-layout';
import {LoanSingleService} from '../service/loan.single.service';
import {LoanModel} from '../models/loan.model';
import {BasicinfoComponent} from './basicinfo/basicinfo.component';
-import {ActivatedRoute} from '@angular/router';
+import {ActivatedRoute, Router} from '@angular/router';
import {AuthService} from '../service/auth.service';
@@ -25,6 +25,7 @@ export class LoanEditComponent implements OnInit {
public curStepSuccess = false;
public showDelete = false;
+ public navigateTo = '';
public steps = [
{ label: 'Basic Info', isValid: true , errMsg: 'There are some errors'},
@@ -36,7 +37,7 @@ export class LoanEditComponent implements OnInit {
public dialogOpened = false;
public errorMessage = '';
- constructor( private lss: LoanSingleService, private actRoute: ActivatedRoute, private auth: AuthService) { }
+ constructor( private lss: LoanSingleService, private actRoute: ActivatedRoute, private auth: AuthService, private router: Router) { }
// public get currentStepError(): boolean{
// const ret = false; // TODO: set the value
@@ -74,7 +75,16 @@ export class LoanEditComponent implements OnInit {
}
public del(): void {
- console.log('delete loan', this.Loan.Id);
+ this.lss.deleteLoan(this.Loan.Id).subscribe(
+ resp => {
+ console.log(resp);
+ this.showError('Loan' + resp + 'has been deleted');
+ this.navigateTo='./#list-all-loans';
+ },
+ err => {
+ this.showError('Error Occurred, cannot delete: ' + err.toString());
+ }
+ );
}
public loadLoanById(id: string): void {
@@ -96,10 +106,14 @@ export class LoanEditComponent implements OnInit {
public action(status): void {
this.dialogOpened = false;
+ if ( this.navigateTo !== '' ) {
+ this.router.navigate([this.navigateTo]);
+ }
}
public showError(msg: string): void{
this.errorMessage = msg;
this.dialogOpened = true;
}
+
}
diff --git a/src/app/loan-edit/people-reward/people-reward.component.html b/src/app/loan-edit/people-reward/people-reward.component.html
index 3d9b36e..a521361 100644
--- a/src/app/loan-edit/people-reward/people-reward.component.html
+++ b/src/app/loan-edit/people-reward/people-reward.component.html
@@ -1,9 +1,11 @@