feat: add recurring deposits actions (undo-approval) (#1006)
Fixes: #1003
This commit is contained in:
@@ -437,24 +437,24 @@
|
||||
<ng-container matColumnDef="Actions">
|
||||
<th mat-header-cell *matHeaderCellDef> Actions </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<button *ngIf="element.status.active" class="account-action-button" mat-raised-button color="primary">
|
||||
<i class="fa fa-arrow-up"></i>
|
||||
</button>
|
||||
<button *ngIf="element.status.active" class="account-action-button" mat-raised-button color="primary">
|
||||
<i class="fa fa-arrow-down"></i>
|
||||
</button>
|
||||
<button *ngIf="element.status.submittedAndPendingApproval" class="account-action-button" mat-raised-button
|
||||
color="primary">
|
||||
<i class="fa fa-check"></i>
|
||||
</button>
|
||||
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
|
||||
class="account-action-button" mat-raised-button color="primary">
|
||||
<i class="fa fa-undo"></i>
|
||||
</button>
|
||||
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
|
||||
class="account-action-button" mat-raised-button color="primary">
|
||||
<i class="fa fa-check-circle"></i>
|
||||
</button>
|
||||
<ng-container *ngIf="element.status.submittedAndPendingApproval">
|
||||
<button class="account-action-button" mat-raised-button *mifosxHasPermission="'APPROVE_SAVINGSACCOUNT'" color="primary">
|
||||
<i class="fa fa-check"></i>
|
||||
</button>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="!element.status.submittedAndPendingApproval && !element.status.active">
|
||||
<button
|
||||
class="account-action-button" mat-raised-button color="primary" (click)="routeEdit($event)"
|
||||
*mifosxHasPermission="'APPROVALUNDO_SAVINGSACCOUNT'"
|
||||
[routerLink]="['../','recurring-deposits-accounts', element.id, 'actions', 'Undo Approval']">
|
||||
<i class="fa fa-undo"></i>
|
||||
</button>
|
||||
<button class="account-action-button" mat-raised-button color="primary" (click)="routeEdit($event)"
|
||||
*mifosxHasPermission="'ACTIVATE_SAVINGSACCOUNT'"
|
||||
[routerLink]="['../','recurring-deposits-accounts', element.id, 'actions', 'Activate']">
|
||||
<i class="fa fa-check-circle"></i>
|
||||
</button>
|
||||
</ng-container>
|
||||
</td>
|
||||
|
||||
</ng-container>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
|
||||
import { ClientsRoutingModule } from './clients-routing.module';
|
||||
import { SharedModule } from 'app/shared/shared.module';
|
||||
import { PipesModule } from '../pipes/pipes.module';
|
||||
import { DirectivesModule } from '../directives/directives.module';
|
||||
|
||||
/** Custom Components */
|
||||
import { ClientsComponent } from './clients.component';
|
||||
@@ -35,7 +36,8 @@ import { ChargesOverviewComponent } from './clients-view/charges-overview/charge
|
||||
imports: [
|
||||
SharedModule,
|
||||
ClientsRoutingModule,
|
||||
PipesModule
|
||||
PipesModule,
|
||||
DirectivesModule
|
||||
],
|
||||
declarations: [
|
||||
ClientsComponent,
|
||||
|
||||
+1
@@ -1 +1,2 @@
|
||||
<mifosx-activate-recurring-deposits-account *ngIf="actions['Activate']"></mifosx-activate-recurring-deposits-account>
|
||||
<mifosx-undo-approval-recurring-deposits-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-recurring-deposits-account>
|
||||
|
||||
+2
@@ -11,8 +11,10 @@ export class RecurringDepositsAccountActionsComponent {
|
||||
/** Flag object to store possible actions and render appropriate UI to the user */
|
||||
actions: {
|
||||
'Activate': boolean
|
||||
'Undo Approval': boolean
|
||||
} = {
|
||||
'Activate': false,
|
||||
'Undo Approval': false
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="undoApprovalRecurringDepositsAccountForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Note</mat-label>
|
||||
<textarea matInput formControlName="note"></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
|
||||
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
|
||||
<button mat-raised-button color="warn" [disabled]="!undoApprovalRecurringDepositsAccountForm.valid">Confirm</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UndoApprovalRecurringDepositsAccountComponent } from './undo-approval-recurring-deposits-account.component';
|
||||
|
||||
describe('UndoApprovalRecurringDepositsAccountComponent', () => {
|
||||
let component: UndoApprovalRecurringDepositsAccountComponent;
|
||||
let fixture: ComponentFixture<UndoApprovalRecurringDepositsAccountComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ UndoApprovalRecurringDepositsAccountComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UndoApprovalRecurringDepositsAccountComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
/** Custom Services */
|
||||
import { RecurringDepositsService } from '../../recurring-deposits.service';
|
||||
|
||||
/**
|
||||
* Undo Approval Recurring Deposits Account Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-undo-approval-recurring-deposits-account',
|
||||
templateUrl: './undo-approval-recurring-deposits-account.component.html',
|
||||
styleUrls: ['./undo-approval-recurring-deposits-account.component.scss']
|
||||
})
|
||||
export class UndoApprovalRecurringDepositsAccountComponent implements OnInit {
|
||||
|
||||
/** Undo Approval Recurring Deposits Account form. */
|
||||
undoApprovalRecurringDepositsAccountForm: FormGroup;
|
||||
/** Recurring Deposits Account Id */
|
||||
accountId: any;
|
||||
|
||||
/**
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {SavingsService} recurringDepositsService Recurring Deposits Service
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private recurringDepositsService: RecurringDepositsService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.accountId = this.route.parent.snapshot.params['recurringDepositAccountId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the undo-approval recurring deposits form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createUndoApprovalRecurringDepositsAccountForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the undo-approval recurring deposits account form.
|
||||
*/
|
||||
createUndoApprovalRecurringDepositsAccountForm() {
|
||||
this.undoApprovalRecurringDepositsAccountForm = this.formBuilder.group({
|
||||
'note': ['']
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the form and undo the approval of recurring deposits account,
|
||||
* if successful redirects to the recurring deposits account.
|
||||
*/
|
||||
submit() {
|
||||
const data = {
|
||||
...this.undoApprovalRecurringDepositsAccountForm.value,
|
||||
};
|
||||
this.recurringDepositsService.executeRecurringDepositsAccountCommand(this.accountId, 'undoapproval', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -78,6 +78,7 @@ export class RecurringDepositsAccountViewComponent implements OnInit {
|
||||
doAction(name: string) {
|
||||
switch (name) {
|
||||
case 'Activate':
|
||||
case 'Undo Approval':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import { RecurringDepositsAccountChargesStepComponent } from './recurring-deposi
|
||||
import { RecurringDepositsAccountPreviewStepComponent } from './recurring-deposits-account-stepper/recurring-deposits-account-preview-step/recurring-deposits-account-preview-step.component';
|
||||
import { RecurringDepositsAccountActionsComponent } from './recurring-deposits-account-actions/recurring-deposits-account-actions.component';
|
||||
import { ActivateRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/activate-recurring-deposits-account/activate-recurring-deposits-account.component';
|
||||
import { UndoApprovalRecurringDepositsAccountComponent } from './recurring-deposits-account-actions/undo-approval-recurring-deposits-account/undo-approval-recurring-deposits-account.component';
|
||||
|
||||
/**
|
||||
* RecurringDeposits Module
|
||||
@@ -58,7 +59,8 @@ import { ActivateRecurringDepositsAccountComponent } from './recurring-deposits-
|
||||
RecurringDepositsAccountChargesStepComponent,
|
||||
RecurringDepositsAccountPreviewStepComponent,
|
||||
RecurringDepositsAccountActionsComponent,
|
||||
ActivateRecurringDepositsAccountComponent
|
||||
ActivateRecurringDepositsAccountComponent,
|
||||
UndoApprovalRecurringDepositsAccountComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user