diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.html b/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.html new file mode 100644 index 000000000..89fb620ac --- /dev/null +++ b/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.html @@ -0,0 +1,8 @@ +

Reject Share

+
+

Are you sure you want to reject share with id: {{ data.shareId }} ?

+
+ + + + diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.scss b/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.spec.ts b/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.spec.ts new file mode 100644 index 000000000..1510d7f1a --- /dev/null +++ b/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RejectShareDialogComponent } from './reject-share-dialog.component'; + +describe('RejectSharesDialogComponent', () => { + let component: RejectShareDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ RejectShareDialogComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RejectShareDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.ts b/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.ts new file mode 100644 index 000000000..827a79925 --- /dev/null +++ b/src/app/shares/shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component.ts @@ -0,0 +1,22 @@ +/** Angular Imports */ +import { Component, Inject } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; + +/** + * Reject share dialog component. + */ +@Component({ + selector: 'mifosx-reject-share-dialog', + templateUrl: './reject-share-dialog.component.html', + styleUrls: ['./reject-share-dialog.component.scss'] +}) +export class RejectShareDialogComponent { + + /** + * @param {MatDialogRef} dialogRef Component reference to dialog. + * @param {any} data Provides a deleteContext. + */ + constructor(public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any) { } + +} diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.html b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.html new file mode 100644 index 000000000..d5650a299 --- /dev/null +++ b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.html @@ -0,0 +1,48 @@ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Transaction Date {{ share.purchasedDate | date }} Total Shares {{ share.numberOfShares }} Purchased/Redeemed Price {{ share.purchasedPrice }} Status + + Confirm Reject + +
+ + + +
+ +
diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.scss b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.scss new file mode 100644 index 000000000..573287fc3 --- /dev/null +++ b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.scss @@ -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; + } +} diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.spec.ts b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.spec.ts new file mode 100644 index 000000000..bf9b44c7d --- /dev/null +++ b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RejectSharesComponent } from './reject-shares.component'; + +describe('RejectSharesComponent', () => { + let component: RejectSharesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ RejectSharesComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RejectSharesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.ts b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.ts new file mode 100644 index 000000000..c50c79896 --- /dev/null +++ b/src/app/shares/shares-account-actions/reject-shares/reject-shares.component.ts @@ -0,0 +1,99 @@ +/** 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 { RejectShareDialogComponent } from './reject-share-dialog/reject-share-dialog.component'; + +/** Custom Serices */ +import { SharesService } from 'app/shares/shares.service'; + +/** + * Reject shares component. + */ +@Component({ + selector: 'mifosx-reject-shares', + templateUrl: './reject-shares.component.html', + styleUrls: ['./reject-shares.component.scss'] +}) +export class RejectSharesComponent 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', 'reject']; + /** Data source for shares table. */ + dataSource: MatTableDataSource; + + /** Paginator for shares table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + /** Sorter for shares table. */ + @ViewChild(MatSort) sort: MatSort; + /** Shares table reference */ + @ViewChild('sharesTable') sharesTableRef: MatTable; + + /** + * @param {SharesService} sharesService Shares Service + * @param {ActivatedRoute} route Activated Route + * @param {MatDialog} dialog Mat Dialog + */ + 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; + } + + /** + * Rejects a share + * @param {any} id Share Id + */ + reject(id: any) { + const rejectSharesDialogRef = this.dialog.open(RejectShareDialogComponent, { + data: { shareId: id } + }); + rejectSharesDialogRef.afterClosed().subscribe((response: any) => { + if (response.reject) { + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + const data = { + requestedShares: [{id}], + dateFormat, + locale + }; + this.sharesService.executeSharesAccountCommand(this.accountId, 'rejectadditionalshares', 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(); + }); + } + }); + } + +} diff --git a/src/app/shares/shares-account-actions/shares-account-actions.component.html b/src/app/shares/shares-account-actions/shares-account-actions.component.html index 6ea0ee447..0c7c1a4f0 100644 --- a/src/app/shares/shares-account-actions/shares-account-actions.component.html +++ b/src/app/shares/shares-account-actions/shares-account-actions.component.html @@ -5,4 +5,5 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/src/app/shares/shares-account-actions/shares-account-actions.component.ts b/src/app/shares/shares-account-actions/shares-account-actions.component.ts index a7166808a..0c1d440a0 100644 --- a/src/app/shares/shares-account-actions/shares-account-actions.component.ts +++ b/src/app/shares/shares-account-actions/shares-account-actions.component.ts @@ -26,6 +26,8 @@ export class SharesAccountActionsComponent { 'Undo Approval': boolean 'Apply Additional Shares': boolean 'Redeem Shares': boolean + 'Approve Additional Shares': boolean + 'Reject Additional Shares': boolean } = { 'Approve': false, 'Reject': false, @@ -33,7 +35,9 @@ export class SharesAccountActionsComponent { 'Activate': false, 'Undo Approval': false, 'Apply Additional Shares': false, - 'Redeem Shares': false + 'Redeem Shares': false, + 'Approve Additional Shares': false, + 'Reject Additional Shares': false }; /** diff --git a/src/app/shares/shares-account-view/shares-account-view.component.ts b/src/app/shares/shares-account-view/shares-account-view.component.ts index c104dac19..4423e6928 100644 --- a/src/app/shares/shares-account-view/shares-account-view.component.ts +++ b/src/app/shares/shares-account-view/shares-account-view.component.ts @@ -90,6 +90,7 @@ export class SharesAccountViewComponent implements OnInit { case 'Apply Additional Shares': case 'Redeem Shares': case 'Approve Additional Shares': + case 'Reject Additional Shares': this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; case 'Modify Application': diff --git a/src/app/shares/shares-account-view/shares-buttons.config.ts b/src/app/shares/shares-account-view/shares-buttons.config.ts index aefb127e9..5fee5def0 100644 --- a/src/app/shares/shares-account-view/shares-buttons.config.ts +++ b/src/app/shares/shares-account-view/shares-buttons.config.ts @@ -41,7 +41,7 @@ export class SharesButtonsConfiguration { }, { name: 'Reject Additional Shares', - icon: 'fa fa-arrow-right', + icon: 'fa fa-arrow-left', taskPermissionName: 'REJECTADDITIONAL_SHAREACCOUNT' }, { diff --git a/src/app/shares/shares.module.ts b/src/app/shares/shares.module.ts index 9538648eb..251365b39 100644 --- a/src/app/shares/shares.module.ts +++ b/src/app/shares/shares.module.ts @@ -27,6 +27,8 @@ import { ApplySharesComponent } from './shares-account-actions/apply-shares/appl 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'; +import { RejectSharesComponent } from './shares-account-actions/reject-shares/reject-shares.component'; +import { RejectShareDialogComponent } from './shares-account-actions/reject-shares/reject-share-dialog/reject-share-dialog.component'; /** * Shares Module @@ -60,11 +62,14 @@ import { ApproveShareDialogComponent } from './shares-account-actions/approve-sh ApplySharesComponent, RedeemSharesComponent, ApproveSharesComponent, - ApproveShareDialogComponent + ApproveShareDialogComponent, + RejectSharesComponent, + RejectShareDialogComponent ], providers: [DatePipe], entryComponents: [ - ApproveShareDialogComponent + ApproveShareDialogComponent, + RejectShareDialogComponent ] }) export class SharesModule { }