refactor: existing savings account actions (#941)

Fixes: #940
This commit is contained in:
Karan Takalkar
2020-06-28 17:13:05 +05:30
committed by GitHub
parent af5f9995f0
commit 35a25e018f
31 changed files with 294 additions and 275 deletions
@@ -79,16 +79,16 @@
</span>
<span *ngIf="savingsAccountData.status.value === 'Active' && charge.amountOutstanding !== 0">
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Pay Charge"
*mifosxHasPermission="'PAY_SAVINGSACCOUNTCHARGE'" (click)="payCharge(charge.id)">
*mifosxHasPermission="'PAY_SAVINGSACCOUNTCHARGE'" (click)="routeEdit($event); payCharge(charge.id)">
<i class="fa fa-dollar"></i>
</button>
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Waive Charge"
*mifosxHasPermission="'WAIVE_SAVINGSACCOUNTCHARGE'" (click)="waiveCharge(charge.id)">
*mifosxHasPermission="'WAIVE_SAVINGSACCOUNTCHARGE'" (click)="routeEdit($event); waiveCharge(charge.id)">
<i class="fa fa-flag"></i>
</button>
<ng-container *ngIf="isRecurringCharge(charge)">
<button class="account-action-button" mat-raised-button color="primary" matTooltip="Inactivate Charge"
*mifosxHasPermission="'INACTIVATE_SAVINGSACCOUNTCHARGE'" (click)="inactivateCharge(charge.id)">
*mifosxHasPermission="'INACTIVATE_SAVINGSACCOUNTCHARGE'" (click)="routeEdit($event); inactivateCharge(charge.id)">
<i class="fa fa-ban"></i>
</button>
</ng-container>
@@ -132,7 +132,7 @@ export class ChargesTabComponent implements OnInit {
};
this.savingsService.executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'paycharge', dataObject, chargeId)
.subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
this.reload();
});
}
});
@@ -148,7 +148,7 @@ export class ChargesTabComponent implements OnInit {
if (response.confirm) {
this.savingsService.executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'waive', {}, chargeId)
.subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
this.reload();
});
}
});
@@ -164,7 +164,7 @@ export class ChargesTabComponent implements OnInit {
if (response.confirm) {
this.savingsService.executeSavingsAccountChargesCommand(this.savingsAccountData.id, 'inactivate', {}, chargeId)
.subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
this.reload();
});
}
});
@@ -178,4 +178,23 @@ export class ChargesTabComponent implements OnInit {
return charge.chargeTimeType.value === 'Monthly Fee' || charge.chargeTimeType.value === 'Annual Fee' || charge.chargeTimeType.value === 'Weekly Fee';
}
/**
* Stops the propagation to view charge page.
* @param $event Mouse Event
*/
routeEdit($event: MouseEvent) {
$event.stopPropagation();
}
/**
* Refetches data fot the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing.
*/
private reload() {
const clientId = this.savingsAccountData.clientId;
const url: string = this.router.url;
this.router.navigateByUrl(`/clients/${clientId}/savingsaccounts`, {skipLocationChange: true})
.then(() => this.router.navigate([url]));
}
}
@@ -106,14 +106,19 @@ export class SavingsAccountViewComponent implements OnInit {
switch (name) {
case 'Approve':
case 'Reject':
case 'Withdraw':
case 'Deposit':
case 'Activate':
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;
case 'Withdraw':
this.router.navigate([`actions/Withdrawal`], { relativeTo: this.route });
break;
case 'Modify Application':
this.router.navigate(['edit-savings-account'], { relativeTo: this.route });
break;
@@ -114,7 +114,7 @@ export class SavingsButtonsConfiguration {
taskPermissionName: 'REJECT_SAVINGSACCOUNT'
},
{
name: 'Withdraw',
name: 'Withdraw By Client',
taskPermissionName: 'WITHDRAW_SAVINGSACCOUNT'
},
{
@@ -1,7 +1,7 @@
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
<span *ngIf="savingsAccountData.status.value === 'Active' && chargeData.amountOutstanding !== 0">
<div *ngIf="savingsAccountData.status.value === 'Active' && chargeData.amountOutstanding !== 0"
fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
<button mat-raised-button color="accent" *mifosxHasPermission="'PAY_SAVINGSACCOUNTCHARGE'" (click)="payCharge()">
<fa-icon icon="dollar-sign"></fa-icon>&nbsp;&nbsp;
Pay Charge
@@ -16,7 +16,6 @@
Inactivate Charge
</button>
</span>
</span>
</div>
<div class="container">
@@ -45,8 +45,10 @@ export class ViewChargeComponent {
private datePipe: DatePipe,
private router: Router,
public dialog: MatDialog) {
this.route.data.subscribe((data: { savingsAccountCharge: any, savingsAccountData: any }) => {
this.route.data.subscribe((data: { savingsAccountCharge: any }) => {
this.chargeData = data.savingsAccountCharge;
});
this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => {
this.savingsAccountData = data.savingsAccountData;
});
}