From cb62fefbfa8729936858393713102266ec24e339 Mon Sep 17 00:00:00 2001 From: Muskan Khedia <36980003+muskankhedia@users.noreply.github.com> Date: Thu, 23 Jul 2020 17:22:28 +0530 Subject: [PATCH] feat: add list view standing instructions (#1152) Fixes: #267 --- .../account-transfers-routing.module.ts | 11 +- .../account-transfers.module.ts | 4 +- .../account-transfers.service.ts | 25 ++++ .../list-standing-instructions.component.html | 109 +++++++++++++++ .../list-standing-instructions.component.scss | 16 +++ ...st-standing-instructions.component.spec.ts | 25 ++++ .../list-standing-instructions.component.ts | 129 ++++++++++++++++++ src/app/clients/clients-routing.module.ts | 2 +- .../clients-view/clients-view.component.html | 3 +- .../clients-view/clients-view.component.ts | 8 +- .../standing-instructions-tab.component.html | 2 +- .../standing-instructions-tab.component.ts | 22 ++- .../standing-instructions-tab.component.html | 2 +- .../standing-instructions-tab.component.ts | 22 ++- .../standing-instructions-tab.component.html | 2 +- .../standing-instructions-tab.component.ts | 22 ++- .../standing-instructions-tab.component.html | 2 +- .../standing-instructions-tab.component.ts | 22 ++- 18 files changed, 410 insertions(+), 18 deletions(-) create mode 100644 src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.html create mode 100644 src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.scss create mode 100644 src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.spec.ts create mode 100644 src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.ts diff --git a/src/app/account-transfers/account-transfers-routing.module.ts b/src/app/account-transfers/account-transfers-routing.module.ts index e1438f1ab..703475e7c 100644 --- a/src/app/account-transfers/account-transfers-routing.module.ts +++ b/src/app/account-transfers/account-transfers-routing.module.ts @@ -16,6 +16,7 @@ import { StandingInstructionsDataAndTemplateResolver } from './common-resolvers/ import { StandingInstructionsTemplateResolver } from './common-resolvers/standing-instructions-template.resolver'; import { MakeAccountTransersComponent } from './make-account-transers/make-account-transers.component'; import { MakeAccountTransferTemplateResolver } from './common-resolvers/make-account-transfer-template.resolver'; +import { ListStandingInstructionsComponent } from './list-standing-instructions/list-standing-instructions.component'; /** Loans Route. */ const routes: Routes = [ @@ -38,6 +39,14 @@ const routes: Routes = [ accountTransferTemplate: MakeAccountTransferTemplateResolver } }, + { + path: 'list-standing-instructions', + data: { title: extract('List Standing Instructions'), breadcrumb: 'List Standing Instructions', routeParamBreadcrumb: 'List Standing Instructions' }, + component: ListStandingInstructionsComponent, + resolve: { + standingIntructionsTemplate: StandingInstructionsTemplateResolver + } + }, { path: ':standingInstructionsId', data: { title: extract('Standing Instructions'), routeParamBreadcrumb: 'standingInstructionsId' }, @@ -59,7 +68,7 @@ const routes: Routes = [ }, } ] - } + }, ] }, ]; diff --git a/src/app/account-transfers/account-transfers.module.ts b/src/app/account-transfers/account-transfers.module.ts index d22be1481..389a60b4c 100644 --- a/src/app/account-transfers/account-transfers.module.ts +++ b/src/app/account-transfers/account-transfers.module.ts @@ -13,6 +13,7 @@ import { ViewStandingInstructionsComponent } from './view-standing-instructions/ import { EditStandingInstructionsComponent } from './edit-standing-instructions/edit-standing-instructions.component'; import { CreateStandingInstructionsComponent } from './create-standing-instructions/create-standing-instructions.component'; import { MakeAccountTransersComponent } from './make-account-transers/make-account-transers.component'; +import { ListStandingInstructionsComponent } from './list-standing-instructions/list-standing-instructions.component'; /** * Account Transfers Module @@ -25,7 +26,8 @@ import { MakeAccountTransersComponent } from './make-account-transers/make-accou ViewStandingInstructionsComponent, EditStandingInstructionsComponent, CreateStandingInstructionsComponent, - MakeAccountTransersComponent + MakeAccountTransersComponent, + ListStandingInstructionsComponent ], providers: [DatePipe] }) diff --git a/src/app/account-transfers/account-transfers.service.ts b/src/app/account-transfers/account-transfers.service.ts index 58b644eba..0ecc730ca 100644 --- a/src/app/account-transfers/account-transfers.service.ts +++ b/src/app/account-transfers/account-transfers.service.ts @@ -69,4 +69,29 @@ export class AccountTransfersService { return this.http.post(`/accounttransfers`, data); } + /** + * @param clientId Client Id + * @param clientName Client Name + * @param fromAccountId Account Id + * @param locale Locale + * @param dateFormat Date Format + * @returns {Observable} Standing Instructions + */ + getStandingInstructions(searchData: any): Observable { + let httpParams = new HttpParams(); + const propNames = Object.getOwnPropertyNames(searchData); + for (let i = 0; i < propNames.length; i++) { + const propName = propNames[i]; + if (!(searchData[propName] === '' || searchData[propName] === undefined || searchData[propName] === null)) { + httpParams = httpParams.set(propName, searchData[propName]); + } + } + return this.http.get(`/standinginstructions`, { params: httpParams }); + } + + deleteStandingInstrucions(id: any) { + const httpParams = new HttpParams().set('command', 'delete'); + return this.http.delete(`/standinginstructions/${id}`, { params: httpParams }); + } + } diff --git a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.html b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.html new file mode 100644 index 000000000..127e0f3c4 --- /dev/null +++ b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.html @@ -0,0 +1,109 @@ + + +
+ +
+ +

Client Name

+
+ +

{{ clientName }}

+
+
+ +
+ + + + + + +
+ + + Type + + + {{ transferTypeData.value }} + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Client {{instruction.fromClient.displayName}}-{{instruction.fromClient.id}} + From Account {{instruction.fromAccount.accountNo}} + ({{instruction.fromAccountType.value}}) Beneficiary {{instruction.toClient.displayName}} To Account {{instruction.toAccount.accountNo}} + ({{instruction.toAccountType.value}}) Amount {{instruction.instructionType.value}}/{{instruction.amount}} Validity {{instruction.validFrom | date}} to {{instruction.validTill | date}} + Actions + + + + + + + +
+ + + +
diff --git a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.scss b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.scss new file mode 100644 index 000000000..518d702d3 --- /dev/null +++ b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.scss @@ -0,0 +1,16 @@ +.container { + .filter-button{ + height: 2.5rem; + margin-top: 1rem; + } +} + +table { + width: 100%; + .account-action-button{ + min-width: 26px; + padding: 0 6px; + margin: 4px; + line-height: 25px; + } +} diff --git a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.spec.ts b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.spec.ts new file mode 100644 index 000000000..e25d1e592 --- /dev/null +++ b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ListStandingInstructionsComponent } from './list-standing-instructions.component'; + +describe('ListStandingInstructionsComponent', () => { + let component: ListStandingInstructionsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListStandingInstructionsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListStandingInstructionsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.ts b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.ts new file mode 100644 index 000000000..d85d38ba2 --- /dev/null +++ b/src/app/account-transfers/list-standing-instructions/list-standing-instructions.component.ts @@ -0,0 +1,129 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatTableDataSource, MatTable, MatPaginator, MatDialog } from '@angular/material'; +import { ActivatedRoute } from '@angular/router'; +import { FormControl } from '@angular/forms'; + +/** Custom Services */ +import { AccountTransfersService } from '../account-transfers.service'; + +/** Dialog Components */ +import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; + +/** + * Recurring Deposits Standing Instructions Tab + */ +@Component({ + selector: 'mifosx-list-standing-instructions', + templateUrl: './list-standing-instructions.component.html', + styleUrls: ['./list-standing-instructions.component.scss'] +}) +export class ListStandingInstructionsComponent implements OnInit { + + /** Recurring Deposits Data */ + standingIntructionsTemplateData: any; + /** Instructions Data */ + instructionsData: any[]; + /** Name form control. */ + transferType = new FormControl(); + /** ExternalId form control. */ + fromAccountId = new FormControl(); + /** Name form control. */ + clientNameControl = new FormControl(); + /** ExternalId form control. */ + fromClientId = new FormControl(); + /** Client Name */ + clientName: any; + /** Transfer Type Options Data */ + transferTypeDatas: any; + /** Data source for instructions table. */ + dataSource = new MatTableDataSource(); + /** Columns to be displayed in instructions table. */ + displayedColumns: string[] = ['client', 'fromAccount', 'beneficiary', 'toAccount', 'amount', 'validity', 'actions']; + + /** Instruction Table Reference */ + @ViewChild('instructionsTable') instructionTableRef: MatTable; + /** Paginator for centers table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + accountType: any; + accountTypeId: string; + id: any; + isFromClient: Boolean; + + /** + * Retrieves Recurring Deposits Account Data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute, + private accountTransfersService: AccountTransfersService, + private dialog: MatDialog) { + this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => { + this.standingIntructionsTemplateData = data.standingIntructionsTemplate; + if (data.standingIntructionsTemplate.fromClient) { + this.clientName = this.standingIntructionsTemplateData.fromClient.displayName; + console.log('here'); + this.getStandingInstructions(); + } + this.setParams(); + this.transferTypeDatas = this.standingIntructionsTemplateData.transferTypeOptions; + }); + } + + ngOnInit() { + } + + setParams() { + this.accountType = this.route.snapshot.queryParams['accountType']; + switch (this.accountType) { + case 'fromloans': + this.accountTypeId = '1'; + break; + case 'fromsavings': + this.accountTypeId = '2'; + break; + default: + this.accountTypeId = '0'; + } + this.isFromClient = this.route.parent.parent.snapshot.params['clientId'] ? true : false; + } + + filterStandingInstructions() { + this.getStandingInstructions(); + } + + /** + * Retrieves standing instructions and initializes instructions table. + */ + getStandingInstructions() { + const searchData = { + clientId : this.standingIntructionsTemplateData.fromClient.id || this.fromClientId.value, + clientName: this.standingIntructionsTemplateData.fromClient.displayName || this.clientNameControl.value, + locale : 'en', + dateFormat : 'dd MMMM yyyy', + limit: 14, + offset: 0, + fromAccountType: this.accountTypeId, + fromAccountId: this.fromAccountId.value, + fromTransferType: this.transferType.value + }; + this.accountTransfersService.getStandingInstructions(searchData).subscribe((response: any) => { + this.instructionsData = response.pageItems; + this.dataSource.data = this.instructionsData; + this.instructionTableRef.renderRows(); + }); + } + + deleteStandingInstruction(instructionId: any) { + const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `standing instruction id: ${instructionId}` } + }); + deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.accountTransfersService.deleteStandingInstrucions(instructionId) + .subscribe(() => {}); + } + }); + } + +} + diff --git a/src/app/clients/clients-routing.module.ts b/src/app/clients/clients-routing.module.ts index 3623b83e7..0b3656dbc 100644 --- a/src/app/clients/clients-routing.module.ts +++ b/src/app/clients/clients-routing.module.ts @@ -242,7 +242,7 @@ const routes: Routes = [ { path: 'standing-instructions', loadChildren: '../account-transfers/account-transfers.module#AccountTransfersModule' - }, + } ] } ] diff --git a/src/app/clients/clients-view/clients-view.component.html b/src/app/clients/clients-view/clients-view.component.html index c919ea4f2..bbab10d8c 100644 --- a/src/app/clients/clients-view/clients-view.component.html +++ b/src/app/clients/clients-view/clients-view.component.html @@ -37,7 +37,8 @@ - + + diff --git a/src/app/clients/clients-view/clients-view.component.ts b/src/app/clients/clients-view/clients-view.component.ts index ccfd79b69..d96da8d68 100644 --- a/src/app/clients/clients-view/clients-view.component.ts +++ b/src/app/clients/clients-view/clients-view.component.ts @@ -96,8 +96,12 @@ export class ClientsViewComponent implements OnInit { this.deleteProfileImage(); break; case 'Create Standing Instructions': - const queryParams: any = { officeId: this.clientViewData.officeId, accountType: 'fromsavings' }; - this.router.navigate(['standing-instructions/create-standing-instructions'], { relativeTo: this.route, queryParams: queryParams }); + const createStandingInstructionsQueryParams: any = { officeId: this.clientViewData.officeId, accountType: 'fromsavings' }; + this.router.navigate(['standing-instructions/create-standing-instructions'], { relativeTo: this.route, queryParams: createStandingInstructionsQueryParams }); + break; + case 'View Standing Instructions': + const viewStandingInstructionsQueryParams: any = { officeId: this.clientViewData.officeId, accountType: 'fromsavings' }; + this.router.navigate(['standing-instructions/list-standing-instructions'], { relativeTo: this.route, queryParams: viewStandingInstructionsQueryParams }); break; } } diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component.html index 709466062..77eef83e5 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component.html @@ -49,7 +49,7 @@ diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component.ts index c9250bd45..439a6871e 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component.ts @@ -1,10 +1,14 @@ /** Angular Imports */ import { Component, OnInit, ViewChild } from '@angular/core'; -import { MatTableDataSource, MatTable } from '@angular/material'; +import { MatTableDataSource, MatTable, MatDialog } from '@angular/material'; import { ActivatedRoute } from '@angular/router'; /** Custom Services */ import { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service'; +import { AccountTransfersService } from 'app/account-transfers/account-transfers.service'; + +/** Dialog Components */ +import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; /** * Fixed Deposits Standing Instructions Tab @@ -41,7 +45,9 @@ export class StandingInstructionsTabComponent implements OnInit { * @param {ActivatedRoute} route Activated Route. */ constructor(private route: ActivatedRoute, - private fixedDepositsService: FixedDepositsService) { + private fixedDepositsService: FixedDepositsService, + private dialog: MatDialog, + private accountTransfersService: AccountTransfersService) { this.route.parent.data.subscribe((data: { fixedDepositsAccountData: any }) => { this.fixedDepositsData = data.fixedDepositsAccountData; }); @@ -67,4 +73,16 @@ export class StandingInstructionsTabComponent implements OnInit { }); } + deleteStandingInstruction(instructionId: any) { + const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `standing instruction id: ${instructionId}` } + }); + deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.accountTransfersService.deleteStandingInstrucions(instructionId) + .subscribe(() => { }); + } + }); + } + } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.html index 19814011a..49e2bbbbf 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.html +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.html @@ -54,7 +54,7 @@ diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.ts index c7393565d..4de3e0e81 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/standing-instructions-tab/standing-instructions-tab.component.ts @@ -1,10 +1,14 @@ /** Angular Imports */ import { Component, OnInit, ViewChild } from '@angular/core'; -import { MatTableDataSource, MatTable } from '@angular/material'; +import { MatTableDataSource, MatTable, MatDialog } from '@angular/material'; import { ActivatedRoute } from '@angular/router'; /** Custom Services */ import { RecurringDepositsService } from 'app/deposits/recurring-deposits/recurring-deposits.service'; +import { AccountTransfersService } from 'app/account-transfers/account-transfers.service'; + +/** Dialog Components */ +import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; /** * Recurring Deposits Standing Instructions Tab @@ -33,7 +37,9 @@ export class StandingInstructionsTabComponent implements OnInit { * @param {ActivatedRoute} route Activated Route. */ constructor(private route: ActivatedRoute, - private recurringDepositsService: RecurringDepositsService) { + private recurringDepositsService: RecurringDepositsService, + private dialog: MatDialog, + private accountTransfersService: AccountTransfersService) { this.route.parent.data.subscribe((data: { recurringDepositsAccountData: any }) => { this.recurringDepositsData = data.recurringDepositsAccountData; }); @@ -59,4 +65,16 @@ export class StandingInstructionsTabComponent implements OnInit { }); } + deleteStandingInstruction(instructionId: any) { + const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `standing instruction id: ${instructionId}` } + }); + deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.accountTransfersService.deleteStandingInstrucions(instructionId) + .subscribe(() => { }); + } + }); + } + } diff --git a/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.html b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.html index a3d1d73b4..2afb0b365 100644 --- a/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.html +++ b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.html @@ -56,7 +56,7 @@ diff --git a/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.ts b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.ts index ef723af43..fe947a5e1 100644 --- a/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.ts +++ b/src/app/loans/loans-view/standing-instructions-tab/standing-instructions-tab.component.ts @@ -1,10 +1,14 @@ /** Angular Imports */ import { Component, OnInit, ViewChild } from '@angular/core'; -import { MatTableDataSource, MatTable } from '@angular/material'; +import { MatTableDataSource, MatTable, MatDialog } from '@angular/material'; import { ActivatedRoute } from '@angular/router'; /** Custom Services */ import { LoansService } from 'app/loans/loans.service'; +import { AccountTransfersService } from 'app/account-transfers/account-transfers.service'; + +/** Dialog Components */ +import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; /** * Loans Standing Instructions Tab @@ -33,7 +37,9 @@ export class StandingInstructionsTabComponent implements OnInit { * @param {ActivatedRoute} route Activated Route. */ constructor(private route: ActivatedRoute, - private loansService: LoansService) { + private loansService: LoansService, + private dialog: MatDialog, + private accountTransfersService: AccountTransfersService) { this.route.parent.data.subscribe((data: { loanDetailsData: any }) => { this.loanDetailsData = data.loanDetailsData; }); @@ -59,4 +65,16 @@ export class StandingInstructionsTabComponent implements OnInit { }); } + deleteStandingInstruction(instructionId: any) { + const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `standing instruction id: ${instructionId}` } + }); + deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.accountTransfersService.deleteStandingInstrucions(instructionId) + .subscribe(() => { }); + } + }); + } + } diff --git a/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.html b/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.html index 709466062..77eef83e5 100644 --- a/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.html +++ b/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.html @@ -49,7 +49,7 @@ diff --git a/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.ts b/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.ts index 5d6421466..71f7257e4 100644 --- a/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.ts +++ b/src/app/savings/savings-account-view/standing-instructions-tab/standing-instructions-tab.component.ts @@ -1,10 +1,14 @@ /** Angular Imports */ import { Component, OnInit, ViewChild } from '@angular/core'; -import { MatTableDataSource, MatTable } from '@angular/material'; +import { MatTableDataSource, MatTable, MatDialog } from '@angular/material'; import { ActivatedRoute } from '@angular/router'; /** Custom Services */ import { SavingsService } from 'app/savings/savings.service'; +import { AccountTransfersService } from 'app/account-transfers/account-transfers.service'; + +/** Dialog Components */ +import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; /** * Savings Standing Instructions Tab @@ -41,7 +45,9 @@ export class StandingInstructionsTabComponent implements OnInit { * @param {ActivatedRoute} route Activated Route. */ constructor(private route: ActivatedRoute, - private savingsService: SavingsService) { + private savingsService: SavingsService, + private dialog: MatDialog, + private accountTransfersService: AccountTransfersService) { this.route.parent.data.subscribe((data: { savingsAccountData: any }) => { this.savingsData = data.savingsAccountData; }); @@ -67,4 +73,16 @@ export class StandingInstructionsTabComponent implements OnInit { }); } + deleteStandingInstruction(instructionId: any) { + const deleteStandingInstructionDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `standing instruction id: ${instructionId}` } + }); + deleteStandingInstructionDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.accountTransfersService.deleteStandingInstrucions(instructionId) + .subscribe(() => { }); + } + }); + } + }