From 5c0941b9a9de7f5752fd3b7f2f5e37ae5147f301 Mon Sep 17 00:00:00 2001 From: Karan Takalkar Date: Fri, 3 Jul 2020 14:39:32 +0530 Subject: [PATCH] feat: fixed deposit account actions (delete) (#967) Fixes: #966 --- .../fixed-deposit-account-view.component.ts | 22 ++++++++++++++++--- ...ixed-deposits-account-actions.component.ts | 8 ------- .../fixed-deposits/fixed-deposits.service.ts | 8 +++++++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts index 3e9181db4..59d9586bb 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts @@ -3,6 +3,9 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { MatDialog } from '@angular/material'; +/** Custom Dialogs */ +import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; + /** Custom Button Config. */ import { FixedDepositsButtonsConfiguration } from './fixed-deposits-buttons.config'; @@ -76,9 +79,7 @@ export class FixedDepositAccountViewComponent implements OnInit { case 'Close': case 'Undo Approval': case 'Post Interest As On': - case 'Assign Staff': case 'Add Charge': - case 'Unassign Staff': case 'Withdraw By Client': this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; @@ -89,7 +90,7 @@ export class FixedDepositAccountViewComponent implements OnInit { this.router.navigate(['edit-savings-account'], { relativeTo: this.route }); break; case 'Delete': - + this.deleteFixedDepositsAccount(); break; case 'Calculate Interest': @@ -106,5 +107,20 @@ export class FixedDepositAccountViewComponent implements OnInit { } } + /** + * Deletes Fixed Deposits Account. + */ + private deleteFixedDepositsAccount() { + const deleteFixedDepositsAccountDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `fixed deposit account with id: ${this.fixedDepositsAccountData.id}` } + }); + deleteFixedDepositsAccountDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.fixedDepositsService.deleteFixedDepositsAccount(this.fixedDepositsAccountData.id).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + }); + } } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.ts index 01f79a4b5..0048ad4d9 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/fixed-deposits-account-actions.component.ts @@ -16,28 +16,20 @@ export class FixedDepositsAccountActionsComponent { actions: { 'Approve': boolean 'Reject': boolean - 'Withdrawal': boolean - 'Deposit': boolean 'Activate': boolean 'Close': boolean 'Undo Approval': boolean 'Post Interest As On': boolean - 'Assign Staff': boolean 'Add Charge': boolean - 'Unassign Staff': boolean 'Withdraw By Client': boolean } = { 'Approve': false, 'Reject': false, - 'Withdrawal': false, - 'Deposit': false, 'Activate': false, 'Close': false, 'Undo Approval': false, 'Post Interest As On': false, - 'Assign Staff': false, 'Add Charge': false, - 'Unassign Staff': false, 'Withdraw By Client': false }; diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts index d26785373..469b5b55d 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts @@ -24,6 +24,14 @@ export class FixedDepositsService { return this.http.get(`/fixeddepositaccounts/${accountId}`, { params: httpParams }); } + /** + * @param {string} accountId fixed deposits account Id + * @returns {Observable} + */ + deleteFixedDepositsAccount(accountId: string): Observable { + return this.http.delete(`/fixeddepositaccounts/${accountId}`); + } + /** * @param {string} accountId Savings Account Id * @param {string} command Command