refactor: shares module (#1200)

See: #1196
This commit is contained in:
Karan Takalkar
2020-08-13 09:56:25 +05:30
committed by GitHub
parent 6f3b6c40e7
commit a1cd561453
18 changed files with 99 additions and 33 deletions
+1 -1
View File
@@ -246,7 +246,7 @@ const routes: Routes = [
loadChildren: '../deposits/recurring-deposits/recurring-deposits.module#RecurringDepositsModule'
},
{
path: 'sharesaccounts',
path: 'shares-accounts',
loadChildren: '../shares/shares.module#SharesModule'
},
{
@@ -64,7 +64,7 @@
<mat-menu #Applications="matMenu">
<button mat-menu-item [routerLink]="['loans', 'create-loans-account']">New Loan Account</button>
<button mat-menu-item [routerLink]="['savingsaccounts', 'create-savings-account']">New Savings Account</button>
<button mat-menu-item [routerLink]="['sharesaccounts', 'create-shares-account']">New Share Account</button>
<button mat-menu-item *mifosxHasPermission="'CREATE_SHAREACCOUNT'" [routerLink]="['shares-accounts', 'create']">New Share Account</button>
<button mat-menu-item [routerLink]="['recurringdeposits', 'create-recurring-deposits-account']">New Recurring Deposit Account</button>
<button mat-menu-item [routerLink]="['fixed-deposits-accounts', 'create-fixed-deposit-account']">New Fixed Deposits Account</button>
</mat-menu>
@@ -544,15 +544,15 @@
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let element">
<button *ngIf="element.status.submittedAndPendingApproval" class="account-action-button" mat-raised-button
color="primary" (click)="routeEdit($event)" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Approve']">
color="primary" (click)="routeEdit($event)" [routerLink]="['../','shares-accounts', element.id, 'actions', 'Approve']">
<i class="fa fa-check"></i>
</button>
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
class="account-action-button" mat-raised-button color="primary" (click)="routeEdit($event)" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Undo Approval']">
class="account-action-button" mat-raised-button color="primary" (click)="routeEdit($event)" [routerLink]="['../','shares-accounts', element.id, 'actions', 'Undo Approval']">
<i class="fa fa-undo"></i>
</button>
<button *ngIf="!element.status.submittedAndPendingApproval && !element.status.active"
class="account-action-button" mat-raised-button color="primary" (click)="routeEdit($event)" [routerLink]="['../','sharesaccounts', element.id, 'actions', 'Activate']">
class="account-action-button" mat-raised-button color="primary" (click)="routeEdit($event)" [routerLink]="['../','shares-accounts', element.id, 'actions', 'Activate']">
<i class="fa fa-check-circle"></i>
</button>
</td>
@@ -561,7 +561,7 @@
<tr mat-header-row *matHeaderRowDef="openSharesColumns"></tr>
<tr mat-row *matRowDef="let row; columns: openSharesColumns;"
[routerLink]="['../', 'sharesaccounts', row.id, 'transactions']"></tr>
[routerLink]="['../', 'shares-accounts', row.id, 'transactions']"></tr>
</table>
<!-- Closed Share Accounts -->
<table *ngIf="showClosedShareAccounts" mat-table [dataSource]="shareAccounts|accountsFilter:'share':'closed'">
@@ -29,7 +29,7 @@ export class NotificationsPageComponent implements OnInit {
'group' : '/groups/',
'loan' : '/loans/',
'center' : '/centers/',
'shareAccount' : '/sharesaccounts/',
'shareAccount' : '/shares-accounts/',
'fixedDeposit' : '/fixed-deposits-accounts/',
'recurringDepositAccount': '/recurringdeposits/',
'savingsAccount' : '/savingsaccounts/',
@@ -36,7 +36,7 @@ export class NotificationsTrayComponent implements OnInit, OnDestroy {
'group' : '/groups/',
'loan' : '/loans/',
'center' : '/centers/',
'shareAccount' : '/sharesaccounts/',
'shareAccount' : '/shares-accounts/',
'fixedDeposit' : '/fixed-deposits-accounts/',
'recurringDepositAccount': '/recurringdeposits/',
'savingsAccount' : '/savingsaccounts/',
@@ -48,7 +48,7 @@ export class SearchPageComponent {
this.router.navigate(['groups', entity.entityId]);
break;
case 'SHARE':
this.router.navigate(['clients', entity.parentId, 'sharesaccounts', entity.entityId]);
this.router.navigate(['clients', entity.parentId, 'shares-accounts', entity.entityId]);
break;
case 'SAVING':
this.router.navigate(['clients', entity.parentId, 'savingsaccounts', entity.entityId]);
@@ -0,0 +1,41 @@
/** Angular Imports */
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
/** rxjs Imports */
import { Observable } from 'rxjs';
/** Custom Services */
import { SharesService } from '../shares.service';
/**
* Shares Account Actions data resolver.
*/
@Injectable()
export class ShareAccountActionsResolver implements Resolve<Object> {
/**
* @param {sharesService} SharesService Shares service.
*/
constructor(private sharesService: SharesService) { }
/**
* Returns the Shares account actions data.
* @param {ActivatedRouteSnapshot} route Route Snapshot
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const actionName = route.paramMap.get('name');
const shareAccountId = route.paramMap.get('shareAccountId') || route.parent.parent.paramMap.get('shareAccountId');
switch (actionName) {
case 'Apply Additional Shares':
case 'Redeem Shares':
case 'Approve Additional Shares':
case 'Reject Additional Shares':
return this.sharesService.getSharesAccountData(shareAccountId, true);
default:
return undefined;
}
}
}
@@ -98,7 +98,7 @@ export class EditSharesAccountComponent {
}
/**
* Creates a new share account.
* Updates a share account.
*/
submit() {
// TODO: Update once language and date settings are setup
@@ -18,7 +18,7 @@ import { SharesService } from 'app/shares/shares.service';
export class ApplySharesComponent implements OnInit {
/** Shares account data. */
@Input() sharesAccountData: any;
sharesAccountData: any;
/** Minimum date allowed. */
minDate = new Date(2000, 0, 1);
@@ -42,6 +42,9 @@ export class ApplySharesComponent implements OnInit {
private route: ActivatedRoute,
private router: Router) {
this.accountId = this.route.parent.snapshot.params['shareAccountId'];
this.route.data.subscribe((data: { shareAccountActionData: any }) => {
this.sharesAccountData = data.shareAccountActionData;
});
}
/**
@@ -21,7 +21,7 @@ import { SharesService } from 'app/shares/shares.service';
export class ApproveSharesComponent implements OnInit {
/** Shares account data. */
@Input() sharesAccountData: any;
sharesAccountData: any;
/** Shares account Id */
accountId: any;
@@ -46,6 +46,9 @@ export class ApproveSharesComponent implements OnInit {
private route: ActivatedRoute,
public dialog: MatDialog) {
this.accountId = this.route.parent.snapshot.params['shareAccountId'];
this.route.data.subscribe((data: { shareAccountActionData: any }) => {
this.sharesAccountData = data.shareAccountActionData;
});
}
/**
@@ -18,7 +18,7 @@ import { SharesService } from 'app/shares/shares.service';
export class RedeemSharesComponent implements OnInit {
/** Shares account data. */
@Input() sharesAccountData: any;
sharesAccountData: any;
/** Minimum date allowed. */
minDate = new Date(2000, 0, 1);
@@ -42,6 +42,9 @@ export class RedeemSharesComponent implements OnInit {
private route: ActivatedRoute,
private router: Router) {
this.accountId = this.route.parent.snapshot.params['shareAccountId'];
this.route.data.subscribe((data: { shareAccountActionData: any }) => {
this.sharesAccountData = data.shareAccountActionData;
});
}
/**
@@ -21,7 +21,7 @@ import { SharesService } from 'app/shares/shares.service';
export class RejectSharesComponent implements OnInit {
/** Shares account data. */
@Input() sharesAccountData: any;
sharesAccountData: any;
/** Shares account Id */
accountId: any;
@@ -48,6 +48,9 @@ export class RejectSharesComponent implements OnInit {
private route: ActivatedRoute,
public dialog: MatDialog) {
this.accountId = this.route.parent.snapshot.params['shareAccountId'];
this.route.data.subscribe((data: { shareAccountActionData: any }) => {
this.sharesAccountData = data.shareAccountActionData;
});
}
/**
@@ -3,7 +3,7 @@
<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 [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>
<mifosx-reject-shares [sharesAccountData]="sharesAccountData" *ngIf="actions['Reject Additional Shares']"></mifosx-reject-shares>
<mifosx-apply-shares *ngIf="actions['Apply Additional Shares']"></mifosx-apply-shares>
<mifosx-redeem-shares *ngIf="actions['Redeem Shares']"></mifosx-redeem-shares>
<mifosx-approve-shares *ngIf="actions['Approve Additional Shares']"></mifosx-approve-shares>
<mifosx-reject-shares *ngIf="actions['Reject Additional Shares']"></mifosx-reject-shares>
@@ -43,14 +43,9 @@ export class SharesAccountActionsComponent {
/**
* @param {ActivatedRoute} route Activated Route
*/
constructor(private route: ActivatedRoute,
private sharesService: SharesService) {
constructor(private route: ActivatedRoute) {
const name = this.route.snapshot.params['name'];
const accountId = this.route.parent.snapshot.params['shareAccountId'];
this.sharesService.getSharesAccountData(accountId, false).subscribe((response: any) => {
this.sharesAccountData = response;
this.actions[name] = true;
});
this.actions[name] = true;
}
}
@@ -38,7 +38,7 @@
<i class="{{button.icon}}"></i> {{button.name}}</button>
</ng-container>
<ng-container *ngIf="buttonConfig.options">
<ng-container *ngIf="buttonConfig.options.length">
<button mat-raised-button [matMenuTriggerFor]="More">More</button>
<mat-menu #More="matMenu">
<span *ngFor="let option of buttonConfig.options">
@@ -30,6 +30,9 @@ export class SharesAccountViewComponent implements OnInit {
/**
* Fetches shares account data from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SharesService} sharesService Shares Service
* @param {MatDialog} dialog Mat Dialog
*/
constructor(private route: ActivatedRoute,
private router: Router,
@@ -94,7 +97,7 @@ export class SharesAccountViewComponent implements OnInit {
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
break;
case 'Modify Application':
this.router.navigate(['edit-shares-account'], { relativeTo: this.route });
this.router.navigate(['edit'], { relativeTo: this.route });
break;
case 'Delete':
this.deleteSharesAccount();
+13 -4
View File
@@ -16,16 +16,18 @@ import { SharesAccountActionsComponent } from './shares-account-actions/shares-a
/** Custom Resolvers */
import { SharesAccountViewResolver } from './common-resolvers/share-account-view.resolver';
import { ShareAccountActionsResolver } from './common-resolvers/share-account-actions.resolver';
import { SharesAccountTemplateResolver } from './common-resolvers/shares-account-template.resolver';
import { SharesAccountAndTemplateResolver } from './common-resolvers/share-account-and-template.resolver';
/** Shares Routes */
const routes: Routes = [
{
path: '',
data: { title: extract('Shares'), breadcrumb: 'Shares', routeParamBreadcrumb: false },
children: [
{
path: 'create-shares-account',
path: 'create',
data: { title: extract('Create Shares Account'), breadcrumb: 'Create Shares Account' },
component: CreateSharesAccountComponent,
resolve: {
@@ -61,7 +63,7 @@ const routes: Routes = [
]
},
{
path: 'edit-shares-account',
path: 'edit',
data: { title: extract('Edit Shares Account'), breadcrumb: 'Edit', routeParamBreadcrumb: false },
component: EditSharesAccountComponent,
resolve: {
@@ -71,7 +73,10 @@ const routes: Routes = [
{
path: 'actions/:name',
data: { title: extract('Shares Account Actions'), breadcrumb: 'Actions', routeParamBreadcrumb: 'name' },
component: SharesAccountActionsComponent
component: SharesAccountActionsComponent,
resolve: {
shareAccountActionData: ShareAccountActionsResolver
}
}
]
},
@@ -79,13 +84,17 @@ const routes: Routes = [
}
];
/**
* Shares Routinf Module
*/
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
providers: [
SharesAccountViewResolver,
SharesAccountTemplateResolver,
SharesAccountAndTemplateResolver
SharesAccountAndTemplateResolver,
ShareAccountActionsResolver
]
})
export class SharesRoutingModule { }
+8 -2
View File
@@ -13,10 +13,14 @@ import { Observable } from 'rxjs';
})
export class SharesService {
/**
* @param {HttpClient} http Http Client
*/
constructor(private http: HttpClient) {}
/**
* @param accountId Shares Account Id of account to get data for.
* @param {string} accountId Shares Account Id of account to get data for.
* @param {boolean} template Shares account template required?.
* @returns {Observable<any>} Shares data.
*/
getSharesAccountData(accountId: string, template: boolean): Observable<any> {
@@ -25,7 +29,8 @@ export class SharesService {
}
/**
* @param clientId Client Id assosciated with shares account.
* @param {string} clientId Client Id assosciated with shares account.
* @param {string} productId Product Id
* @returns {Observable<any>} Shares account template.
*/
getSharesAccountTemplate(clientId: string, productId?: string): Observable<any> {
@@ -43,6 +48,7 @@ export class SharesService {
}
/**
* @param {string} accountId: Shares account Id.
* @param {any} sharesAccount Shares Account
* @returns {Observable<any>}
*/