@@ -42,7 +42,8 @@ export class StatusLookupPipe implements PipeTransform {
|
||||
'groupingStatusType.approved': 'status-approved',
|
||||
'smsCampaignStatus.active': 'status-active',
|
||||
'smsCampaignStatus.pending': 'status-pending',
|
||||
'smsCampaignStatus.closed': 'status-closed'
|
||||
'smsCampaignStatus.closed': 'status-closed',
|
||||
'purchasedSharesStatusType.applied': 'status-pending'
|
||||
};
|
||||
return cssClassNameLookup[status];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
@@ -17,6 +17,9 @@ import { SharesService } from 'app/shares/shares.service';
|
||||
})
|
||||
export class ApplySharesComponent implements OnInit {
|
||||
|
||||
/** Shares account data. */
|
||||
@Input() sharesAccountData: any;
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
@@ -48,9 +51,7 @@ export class ApplySharesComponent implements OnInit {
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createApplySharesAccountForm();
|
||||
this.sharesService.getSharesAccountData(this.accountId, false).subscribe((response: any) => {
|
||||
this.applySharesForm.get('unitPrice').patchValue(response.currentMarketPrice || '');
|
||||
});
|
||||
this.applySharesForm.get('unitPrice').patchValue(this.sharesAccountData.currentMarketPrice || '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<h1 mat-dialog-title>Approve Share</h1>
|
||||
<div mat-dialog-content>
|
||||
<p>Are you sure you want to approve share with id: {{ data.shareId }} ?</p>
|
||||
</div>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-raised-button mat-dialog-close>Cancel</button>
|
||||
<button mat-raised-button color="accent" [mat-dialog-close]="{ approve: true }">Confirm</button>
|
||||
</mat-dialog-actions>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ApproveShareDialogComponent } from './approve-share-dialog.component';
|
||||
|
||||
describe('ApproveShareDialogComponent', () => {
|
||||
let component: ApproveShareDialogComponent;
|
||||
let fixture: ComponentFixture<ApproveShareDialogComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ApproveShareDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ApproveShareDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/** Angular Imports */
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||
|
||||
/**
|
||||
* Approve share dialog component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-approve-share-dialog',
|
||||
templateUrl: './approve-share-dialog.component.html',
|
||||
styleUrls: ['./approve-share-dialog.component.scss']
|
||||
})
|
||||
export class ApproveShareDialogComponent {
|
||||
|
||||
/**
|
||||
* @param {MatDialogRef} dialogRef Component reference to dialog.
|
||||
* @param {any} data Provides a deleteContext.
|
||||
*/
|
||||
constructor(public dialogRef: MatDialogRef<ApproveShareDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any) { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<div class="container">
|
||||
|
||||
<div class="mat-elevation-z8">
|
||||
|
||||
<table #sharesTable mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
<ng-container matColumnDef="transactionDate">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Transaction Date </th>
|
||||
<td mat-cell *matCellDef="let share"> {{ share.purchasedDate | date }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="totalShares">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Total Shares </th>
|
||||
<td mat-cell *matCellDef="let share"> {{ share.numberOfShares }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="redeemedPrice">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Purchased/Redeemed Price </th>
|
||||
<td mat-cell *matCellDef="let share"> {{ share.purchasedPrice }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="status">
|
||||
<th mat-header-cell *matHeaderCellDef> Status </th>
|
||||
<td mat-cell *matCellDef="let share">
|
||||
<i class="fa fa-stop" [ngClass]="share.status.code|statusLookup" [matTooltip]="share.status.value"></i>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="approve">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Confirm Approve </th>
|
||||
<td mat-cell *matCellDef="let share">
|
||||
<button class="share-action-button" mat-raised-button color="accent" matTooltip="Approve Share"
|
||||
(click)="approve(share.id)">
|
||||
<i class="fa fa-check"></i>
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
table {
|
||||
width: 100%;
|
||||
i:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
.share-action-button{
|
||||
min-width: 26px;
|
||||
padding: 0 6px;
|
||||
margin: 4px;
|
||||
line-height: 25px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ApproveSharesComponent } from './approve-shares.component';
|
||||
|
||||
describe('ApproveSharesComponent', () => {
|
||||
let component: ApproveSharesComponent;
|
||||
let fixture: ComponentFixture<ApproveSharesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ApproveSharesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ApproveSharesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,97 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild, Input } from '@angular/core';
|
||||
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { MatDialog, MatTable } from '@angular/material';
|
||||
|
||||
/** Custom Dialogs */
|
||||
import { ApproveShareDialogComponent } from './approve-share-dialog/approve-share-dialog.component';
|
||||
|
||||
/** Custom Serices */
|
||||
import { SharesService } from 'app/shares/shares.service';
|
||||
|
||||
/**
|
||||
* Approve shares component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-approve-shares',
|
||||
templateUrl: './approve-shares.component.html',
|
||||
styleUrls: ['./approve-shares.component.scss']
|
||||
})
|
||||
export class ApproveSharesComponent implements OnInit {
|
||||
|
||||
/** Shares account data. */
|
||||
@Input() sharesAccountData: any;
|
||||
|
||||
/** Shares account Id */
|
||||
accountId: any;
|
||||
/** Shares account data. */
|
||||
sharesData: any[];
|
||||
/** Columns to be displayed in shares table. */
|
||||
displayedColumns: string[] = ['transactionDate', 'totalShares', 'redeemedPrice', 'status', 'approve'];
|
||||
/** Data source for shares table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for shares table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for shares table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
/** Shares table reference */
|
||||
@ViewChild('sharesTable') sharesTableRef: MatTable<Element>;
|
||||
|
||||
/**
|
||||
* @param {SharesService} sharesService Shares Service
|
||||
*/
|
||||
constructor(private sharesService: SharesService,
|
||||
private route: ActivatedRoute,
|
||||
public dialog: MatDialog) {
|
||||
this.accountId = this.route.parent.snapshot.params['shareAccountId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the shares table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.sharesData = this.sharesAccountData.purchasedShares
|
||||
.filter((share: any) => share.status.value === 'Pending Approval');
|
||||
this.setShares();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for shares table.
|
||||
*/
|
||||
setShares() {
|
||||
this.dataSource = new MatTableDataSource(this.sharesData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Approves a share
|
||||
* @param {any} id Share Id
|
||||
*/
|
||||
approve(id: any) {
|
||||
const approveSharesDialogRef = this.dialog.open(ApproveShareDialogComponent, {
|
||||
data: { shareId: id }
|
||||
});
|
||||
approveSharesDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.approve) {
|
||||
const locale = 'en';
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const data = {
|
||||
requestedShares: [{id}],
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.sharesService.executeSharesAccountCommand(this.accountId, 'approveadditionalshares', data).subscribe(() => {
|
||||
const share = this.sharesData.find(element => element.id === id);
|
||||
const index = this.sharesData.indexOf(share);
|
||||
this.sharesData.splice(index, 1);
|
||||
this.dataSource.data = this.sharesData;
|
||||
this.sharesTableRef.renderRows();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
@@ -17,6 +17,9 @@ import { SharesService } from 'app/shares/shares.service';
|
||||
})
|
||||
export class RedeemSharesComponent implements OnInit {
|
||||
|
||||
/** Shares account data. */
|
||||
@Input() sharesAccountData: any;
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
@@ -48,9 +51,7 @@ export class RedeemSharesComponent implements OnInit {
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createRedeemSharesAccountForm();
|
||||
this.sharesService.getSharesAccountData(this.accountId, false).subscribe((response: any) => {
|
||||
this.redeemSharesForm.get('unitPrice').patchValue(response.currentMarketPrice || '');
|
||||
});
|
||||
this.redeemSharesForm.get('unitPrice').patchValue(this.sharesAccountData.currentMarketPrice || '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
<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>
|
||||
<mifosx-apply-shares *ngIf="actions['Apply Additional Shares']"></mifosx-apply-shares>
|
||||
<mifosx-redeem-shares *ngIf="actions['Redeem Shares']"></mifosx-redeem-shares>
|
||||
<mifosx-apply-shares [sharesAccountData]="sharesAccountData" *ngIf="actions['Apply Additional Shares']"></mifosx-apply-shares>
|
||||
<mifosx-redeem-shares [sharesAccountData]="sharesAccountData" *ngIf="actions['Redeem Shares']"></mifosx-redeem-shares>
|
||||
<mifosx-approve-shares [sharesAccountData]="sharesAccountData" *ngIf="actions['Approve Additional Shares']"></mifosx-approve-shares>
|
||||
@@ -2,6 +2,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
/** Custom Services */
|
||||
import { SharesService } from '../shares.service';
|
||||
|
||||
/**
|
||||
* Shares Account Actions Component
|
||||
*/
|
||||
@@ -36,9 +39,14 @@ export class SharesAccountActionsComponent {
|
||||
/**
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private sharesService: SharesService) {
|
||||
const name = this.route.snapshot.params['name'];
|
||||
this.actions[name] = true;
|
||||
const accountId = this.route.parent.snapshot.params['shareAccountId'];
|
||||
this.sharesService.getSharesAccountData(accountId, false).subscribe((response: any) => {
|
||||
this.sharesAccountData = response;
|
||||
this.actions[name] = true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ export class SharesAccountViewComponent implements OnInit {
|
||||
case 'Undo Approval':
|
||||
case 'Apply Additional Shares':
|
||||
case 'Redeem Shares':
|
||||
case 'Approve Additional Shares':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Modify Application':
|
||||
@@ -104,10 +105,10 @@ export class SharesAccountViewComponent implements OnInit {
|
||||
* Deletes Shares Account.
|
||||
*/
|
||||
private deleteSharesAccount() {
|
||||
const deleteCurrencyDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
const deleteSharesAccountDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `shares account with id: ${this.sharesAccountData.id}` }
|
||||
});
|
||||
deleteCurrencyDialogRef.afterClosed().subscribe((response: any) => {
|
||||
deleteSharesAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.sharesService.deleteSharesAccount(this.sharesAccountData.id).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
|
||||
@@ -25,6 +25,8 @@ import { ActivateSharesAccountComponent } from './shares-account-actions/activat
|
||||
import { UndoApprovalSharesAccountComponent } from './shares-account-actions/undo-approval-shares-account/undo-approval-shares-account.component';
|
||||
import { ApplySharesComponent } from './shares-account-actions/apply-shares/apply-shares.component';
|
||||
import { RedeemSharesComponent } from './shares-account-actions/redeem-shares/redeem-shares.component';
|
||||
import { ApproveSharesComponent } from './shares-account-actions/approve-shares/approve-shares.component';
|
||||
import { ApproveShareDialogComponent } from './shares-account-actions/approve-shares/approve-share-dialog/approve-share-dialog.component';
|
||||
|
||||
/**
|
||||
* Shares Module
|
||||
@@ -56,8 +58,13 @@ import { RedeemSharesComponent } from './shares-account-actions/redeem-shares/re
|
||||
ActivateSharesAccountComponent,
|
||||
UndoApprovalSharesAccountComponent,
|
||||
ApplySharesComponent,
|
||||
RedeemSharesComponent
|
||||
RedeemSharesComponent,
|
||||
ApproveSharesComponent,
|
||||
ApproveShareDialogComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
providers: [DatePipe],
|
||||
entryComponents: [
|
||||
ApproveShareDialogComponent
|
||||
]
|
||||
})
|
||||
export class SharesModule { }
|
||||
|
||||
Reference in New Issue
Block a user