feat: shares account actions (undo-approval) (#900)

Fixes: #899
This commit is contained in:
Karan Takalkar
2020-06-23 23:34:19 +05:30
committed by GitHub
parent 3e4f3e514c
commit 96144d4447
9 changed files with 119 additions and 14 deletions
@@ -306,7 +306,7 @@
<i class="fa fa-check"></i>
</button>
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
class="account-action-button" mat-raised-button color="primary">
class="account-action-button" mat-raised-button color="primary" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Undo Approval']">
<i class="fa fa-undo"></i>
</button>
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
@@ -1,4 +1,5 @@
<mifosx-approve-shares-account *ngIf="actions.Approve"></mifosx-approve-shares-account>
<mifosx-reject-shares-account *ngIf="actions.Reject"></mifosx-reject-shares-account>
<mifosx-close-shares-account *ngIf="actions.Close"></mifosx-close-shares-account>
<mifosx-activate-shares-account *ngIf="actions.Activate"></mifosx-activate-shares-account>
<mifosx-approve-shares-account *ngIf="actions['Approve']"></mifosx-approve-shares-account>
<mifosx-reject-shares-account *ngIf="actions['Reject']"></mifosx-reject-shares-account>
<mifosx-close-shares-account *ngIf="actions['Close']"></mifosx-close-shares-account>
<mifosx-activate-shares-account *ngIf="actions['Activate']"></mifosx-activate-shares-account>
<mifosx-undo-approval-shares-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-shares-account>
@@ -14,15 +14,17 @@ export class SharesAccountActionsComponent {
/** Flag object to store possible actions and render appropriate UI to the user */
actions: {
Approve: boolean
Reject: boolean
Close: boolean
Activate: boolean
'Approve': boolean
'Reject': boolean
'Close': boolean
'Activate': boolean
'Undo Approval': boolean
} = {
Approve: false,
Reject: false,
Close: false,
Activate: false
'Approve': false,
'Reject': false,
'Close': false,
'Activate': false,
'Undo Approval': false
};
constructor(private route: ActivatedRoute) {
@@ -0,0 +1,28 @@
<div class="container">
<mat-card>
<form (ngSubmit)="submit()">
<mat-card-content>
<div>
<p class="mat-typography confirm-text">
Are you sure you want to undo aprroval of shares account with ID: {{accountId}} ?
</p>
</div>
</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">Confirm</button>
</mat-card-actions>
</form>
</mat-card>
</div>
@@ -0,0 +1,7 @@
.container {
max-width: 37rem;
.confirm-text {
font-size: 16px;
text-align: center;
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UndoApprovalSharesAccountComponent } from './undo-approval-shares-account.component';
describe('UndoApprovalSharesAccountComponent', () => {
let component: UndoApprovalSharesAccountComponent;
let fixture: ComponentFixture<UndoApprovalSharesAccountComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UndoApprovalSharesAccountComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UndoApprovalSharesAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,37 @@
/** Angular Imports */
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { SharesService } from 'app/shares/shares.service';
/**
* Undo Approval Shares Account Component
*/
@Component({
selector: 'mifosx-undo-approval-shares-account',
templateUrl: './undo-approval-shares-account.component.html',
styleUrls: ['./undo-approval-shares-account.component.scss']
})
export class UndoApprovalSharesAccountComponent {
/** Shares Account Id */
accountId: any;
constructor(private sharesService: SharesService,
private route: ActivatedRoute,
private router: Router) {
this.accountId = this.route.parent.parent.snapshot.params['shareAccountId'];
}
/**
* Submits the form and undo the approval of share account,
* if successful redirects to the share account.
*/
submit() {
this.sharesService.executeSharesAccountCommand(this.accountId, 'undoapproval', {}).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
}
@@ -97,6 +97,9 @@ export class SharesAccountViewComponent implements OnInit {
case 'Activate':
this.router.navigate(['actions/Activate'], { relativeTo: this.route });
break;
case 'Undo Approval':
this.router.navigate(['actions/Undo Approval'], { relativeTo: this.route });
break;
case 'Delete':
this.deleteSharesAccount();
break;
+3 -1
View File
@@ -22,6 +22,7 @@ import { ApproveSharesAccountComponent } from './shares-account-actions/approve-
import { RejectSharesAccountComponent } from './shares-account-actions/reject-shares-account/reject-shares-account.component';
import { CloseSharesAccountComponent } from './shares-account-actions/close-shares-account/close-shares-account.component';
import { ActivateSharesAccountComponent } from './shares-account-actions/activate-shares-account/activate-shares-account.component';
import { UndoApprovalSharesAccountComponent } from './shares-account-actions/undo-approval-shares-account/undo-approval-shares-account.component';
/**
* Shares Module
@@ -50,7 +51,8 @@ import { ActivateSharesAccountComponent } from './shares-account-actions/activat
ApproveSharesAccountComponent,
RejectSharesAccountComponent,
CloseSharesAccountComponent,
ActivateSharesAccountComponent
ActivateSharesAccountComponent,
UndoApprovalSharesAccountComponent
],
providers: [DatePipe]
})