feat(products): add loan products component (#430)
Add loan products component to list all loan products. Fixes: #429
This commit is contained in:
@@ -25,6 +25,8 @@ export class StatusLookupPipe implements PipeTransform {
|
||||
'shareAccountStatusType.approved': 'status-approved',
|
||||
'shareAccountStatusType.active': 'status-active',
|
||||
'shareAccountStatusType.rejected': 'status-rejected',
|
||||
'loanProduct.active': 'status-active',
|
||||
'loanProduct.inActive': 'status-inactive'
|
||||
};
|
||||
return cssClassNameLookup[status];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
|
||||
<button mat-raised-button color="primary" [routerLink]="['create']">
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
Create Loan Product
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div fxLayout="row">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Filter</mat-label>
|
||||
<input matInput (keyup)="applyFilter($event.target.value)">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div class="mat-elevation-z8">
|
||||
|
||||
<table mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
|
||||
<td mat-cell *matCellDef="let loanProduct"> {{ loanProduct.name }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="shortName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Short Name </th>
|
||||
<td mat-cell *matCellDef="let loanProduct"> {{ loanProduct.shortName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="closeDate">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Expiry Date </th>
|
||||
<td mat-cell *matCellDef="let loanProduct"> {{ loanProduct.closeDate | date }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="status">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
|
||||
<td mat-cell *matCellDef="let loanProduct">
|
||||
<div [className]="loanProduct.status | statusLookup">
|
||||
<fa-icon matTooltip="{{ loanProduct.status === 'loanProduct.active' ? 'Active' : 'Inactive' }}" matTooltipPosition="right" icon="circle" size="lg"></fa-icon>
|
||||
</div>
|
||||
</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,3 @@
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LoanProductsComponent } from './loan-products.component';
|
||||
|
||||
describe('LoanProductsComponent', () => {
|
||||
let component: LoanProductsComponent;
|
||||
let fixture: ComponentFixture<LoanProductsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ LoanProductsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LoanProductsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-loan-products',
|
||||
templateUrl: './loan-products.component.html',
|
||||
styleUrls: ['./loan-products.component.scss']
|
||||
})
|
||||
export class LoanProductsComponent implements OnInit {
|
||||
|
||||
loanProductsData: any;
|
||||
displayedColumns: string[] = ['name', 'shortName', 'closeDate', 'status'];
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe((data: { loanProducts: any }) => {
|
||||
this.loanProductsData = data.loanProducts;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.dataSource = new MatTableDataSource(this.loanProductsData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
applyFilter(filterValue: string) {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/** Custom Services */
|
||||
import { ProductsService } from '../products.service';
|
||||
|
||||
/**
|
||||
* Loan products data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class LoanProductsResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {ProductsService} productsService Products service.
|
||||
*/
|
||||
constructor(private productsService: ProductsService) {}
|
||||
|
||||
/**
|
||||
* Returns the loan products data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(): Observable<any> {
|
||||
return this.productsService.getLoanProducts();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,109 +1,125 @@
|
||||
/** Angular Imports */
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
/** Routing Imports */
|
||||
import { Route } from '../core/route/route.service';
|
||||
|
||||
/** Translation Imports */
|
||||
import { extract } from '../core/i18n/i18n.service';
|
||||
|
||||
/** Custom Components */
|
||||
import { ProductsComponent } from './products.component';
|
||||
import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component';
|
||||
import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component';
|
||||
import { ChargesComponent } from './charges/charges.component';
|
||||
import { FixedDepositProductsComponent } from './fixed-deposit-products/fixed-deposit-products.component';
|
||||
import { ProductsMixComponent } from './products-mix/products-mix.component';
|
||||
import { ManageTaxComponentsComponent } from './manage-tax-components/manage-tax-components.component';
|
||||
|
||||
/** Custom Resolvers */
|
||||
import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver';
|
||||
import { ChargesResolver } from './charges/charges.resolver';
|
||||
import { FixedDepositProductsResolver } from './fixed-deposit-products/fixed-deposit-products.resolver';
|
||||
import { ProductsMixResolver } from './products-mix/products-mix.resolver';
|
||||
import { ManageTaxComponentsResolver } from './manage-tax-components/manage-tax-components.resolver';
|
||||
|
||||
/** Products Routes */
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
{
|
||||
path: 'products',
|
||||
data: { title: extract('Products'), breadcrumb: 'Products' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: ProductsComponent
|
||||
},
|
||||
{
|
||||
path: 'tax-configurations',
|
||||
data: { title: extract('Manage Tax Configurations'), breadcrumb: 'Manage Tax Configurations' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: ManageTaxConfigurationsComponent,
|
||||
},
|
||||
{
|
||||
path: 'tax-components',
|
||||
component: ManageTaxComponentsComponent,
|
||||
resolve: {
|
||||
taxComponents: ManageTaxComponentsResolver
|
||||
},
|
||||
data: { title: extract('Manage Tax Components'), breadcrumb: 'Tax Components'},
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'recurring-deposit-products',
|
||||
component: RecurringDepositProductsComponent,
|
||||
resolve: {
|
||||
recurringDepositProducts: RecurringDepositProductsResolver
|
||||
},
|
||||
data: { title: extract('Recurring Deposit Products'), breadcrumb: 'Recurring Deposit Products' },
|
||||
},
|
||||
{
|
||||
path: 'charges',
|
||||
component: ChargesComponent,
|
||||
resolve: {
|
||||
charges: ChargesResolver
|
||||
},
|
||||
data: { title: extract('Charges'), breadcrumb: 'Charges' },
|
||||
},
|
||||
{
|
||||
path: 'fixed-deposit-products',
|
||||
component: FixedDepositProductsComponent,
|
||||
resolve: {
|
||||
fixedDepositProducts: FixedDepositProductsResolver
|
||||
},
|
||||
data: { title: extract('Fixed Deposit Products'), breadcrumb: 'Fixed Deposit Products' },
|
||||
},
|
||||
{
|
||||
path: 'products-mix',
|
||||
component: ProductsMixComponent,
|
||||
resolve: {
|
||||
products: ProductsMixResolver
|
||||
},
|
||||
data: { title: extract('Products Mix'), breadcrumb: 'Products Mix' },
|
||||
},
|
||||
]
|
||||
}
|
||||
])
|
||||
];
|
||||
|
||||
/**
|
||||
* Products Routing Module
|
||||
*
|
||||
* Configures the products routes.
|
||||
*/
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
RecurringDepositProductsResolver,
|
||||
ChargesResolver,
|
||||
FixedDepositProductsResolver,
|
||||
ProductsMixResolver,
|
||||
ManageTaxComponentsResolver
|
||||
]
|
||||
})
|
||||
export class ProductsRoutingModule { }
|
||||
/** Angular Imports */
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
/** Routing Imports */
|
||||
import { Route } from '../core/route/route.service';
|
||||
|
||||
/** Translation Imports */
|
||||
import { extract } from '../core/i18n/i18n.service';
|
||||
|
||||
/** Custom Components */
|
||||
import { ProductsComponent } from './products.component';
|
||||
import { LoanProductsComponent } from './loan-products/loan-products.component';
|
||||
import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component';
|
||||
import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component';
|
||||
import { ChargesComponent } from './charges/charges.component';
|
||||
import { FixedDepositProductsComponent } from './fixed-deposit-products/fixed-deposit-products.component';
|
||||
import { ProductsMixComponent } from './products-mix/products-mix.component';
|
||||
import { ManageTaxComponentsComponent } from './manage-tax-components/manage-tax-components.component';
|
||||
|
||||
/** Custom Resolvers */
|
||||
import { LoanProductsResolver } from './loan-products/loan-products.resolver';
|
||||
import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver';
|
||||
import { ChargesResolver } from './charges/charges.resolver';
|
||||
import { FixedDepositProductsResolver } from './fixed-deposit-products/fixed-deposit-products.resolver';
|
||||
import { ProductsMixResolver } from './products-mix/products-mix.resolver';
|
||||
import { ManageTaxComponentsResolver } from './manage-tax-components/manage-tax-components.resolver';
|
||||
|
||||
/** Products Routes */
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
{
|
||||
path: 'products',
|
||||
data: { title: extract('Products'), breadcrumb: 'Products' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: ProductsComponent
|
||||
},
|
||||
{
|
||||
path: 'loan-products',
|
||||
data: { title: extract('Loan Products'), breadcrumb: 'Loan Products' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: LoanProductsComponent,
|
||||
resolve: {
|
||||
loanProducts: LoanProductsResolver
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'tax-configurations',
|
||||
data: { title: extract('Manage Tax Configurations'), breadcrumb: 'Manage Tax Configurations' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: ManageTaxConfigurationsComponent,
|
||||
},
|
||||
{
|
||||
path: 'tax-components',
|
||||
component: ManageTaxComponentsComponent,
|
||||
resolve: {
|
||||
taxComponents: ManageTaxComponentsResolver
|
||||
},
|
||||
data: { title: extract('Manage Tax Components'), breadcrumb: 'Tax Components'},
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'recurring-deposit-products',
|
||||
component: RecurringDepositProductsComponent,
|
||||
resolve: {
|
||||
recurringDepositProducts: RecurringDepositProductsResolver
|
||||
},
|
||||
data: { title: extract('Recurring Deposit Products'), breadcrumb: 'Recurring Deposit Products' },
|
||||
},
|
||||
{
|
||||
path: 'charges',
|
||||
component: ChargesComponent,
|
||||
resolve: {
|
||||
charges: ChargesResolver
|
||||
},
|
||||
data: { title: extract('Charges'), breadcrumb: 'Charges' },
|
||||
},
|
||||
{
|
||||
path: 'fixed-deposit-products',
|
||||
component: FixedDepositProductsComponent,
|
||||
resolve: {
|
||||
fixedDepositProducts: FixedDepositProductsResolver
|
||||
},
|
||||
data: { title: extract('Fixed Deposit Products'), breadcrumb: 'Fixed Deposit Products' },
|
||||
},
|
||||
{
|
||||
path: 'products-mix',
|
||||
component: ProductsMixComponent,
|
||||
resolve: {
|
||||
products: ProductsMixResolver
|
||||
},
|
||||
data: { title: extract('Products Mix'), breadcrumb: 'Products Mix' },
|
||||
},
|
||||
]
|
||||
}
|
||||
])
|
||||
];
|
||||
|
||||
/**
|
||||
* Products Routing Module
|
||||
*
|
||||
* Configures the products routes.
|
||||
*/
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
LoanProductsResolver,
|
||||
RecurringDepositProductsResolver,
|
||||
ChargesResolver,
|
||||
FixedDepositProductsResolver,
|
||||
ProductsMixResolver,
|
||||
ManageTaxComponentsResolver
|
||||
]
|
||||
})
|
||||
export class ProductsRoutingModule { }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<mat-nav-list>
|
||||
|
||||
<mat-list-item>
|
||||
<mat-list-item [routerLink]="['loan-products']">
|
||||
<mat-icon matListIcon>
|
||||
<fa-icon icon="briefcase" size="sm"></fa-icon>
|
||||
</mat-icon>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
/** Angular Imports */
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
|
||||
/** Custom Modules */
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { ProductsRoutingModule } from './products-routing.module';
|
||||
import { PipesModule } from 'app/pipes/pipes.module';
|
||||
|
||||
/** Custom Components */
|
||||
import { ProductsComponent } from './products.component';
|
||||
import { LoanProductsComponent } from './loan-products/loan-products.component';
|
||||
import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component';
|
||||
import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component';
|
||||
import { ChargesComponent } from './charges/charges.component';
|
||||
@@ -22,10 +25,12 @@ import { ManageTaxComponentsComponent } from './manage-tax-components/manage-tax
|
||||
@NgModule({
|
||||
imports: [
|
||||
SharedModule,
|
||||
ProductsRoutingModule
|
||||
ProductsRoutingModule,
|
||||
PipesModule
|
||||
],
|
||||
declarations: [
|
||||
ProductsComponent,
|
||||
LoanProductsComponent,
|
||||
ManageTaxConfigurationsComponent,
|
||||
RecurringDepositProductsComponent,
|
||||
ChargesComponent,
|
||||
@@ -34,6 +39,7 @@ import { ManageTaxComponentsComponent } from './manage-tax-components/manage-tax
|
||||
ManageTaxComponentsComponent
|
||||
],
|
||||
entryComponents: [
|
||||
]
|
||||
],
|
||||
providers: [DatePipe]
|
||||
})
|
||||
export class ProductsModule { }
|
||||
|
||||
@@ -1,58 +1,65 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Products service.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ProductsService {
|
||||
|
||||
/**
|
||||
* @param {HttpClient} http Http Client to send requests.
|
||||
*/
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Recurring deposit products data
|
||||
*/
|
||||
getRecurringDepositProducts(): Observable<any> {
|
||||
return this.http.get('/recurringdepositproducts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Charges data
|
||||
*/
|
||||
getCharges(): Observable<any> {
|
||||
return this.http.get('/charges');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Fixed deposit products data
|
||||
*/
|
||||
getFixedDepositProducts(): Observable<any> {
|
||||
return this.http.get('/fixeddepositproducts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Tax Components data
|
||||
*/
|
||||
getTaxComponents(): Observable<any> {
|
||||
return this.http.get('/taxes/component');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Product mixes data
|
||||
*/
|
||||
getProductMixes(): Observable<any> {
|
||||
let httpParams = new HttpParams();
|
||||
httpParams = httpParams.set('associations', 'productMixes');
|
||||
return this.http.get('/loanproducts', { params: httpParams });
|
||||
}
|
||||
|
||||
}
|
||||
/** Angular Imports */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Products service.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ProductsService {
|
||||
|
||||
/**
|
||||
* @param {HttpClient} http Http Client to send requests.
|
||||
*/
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Loan products data
|
||||
*/
|
||||
getLoanProducts(): Observable<any> {
|
||||
return this.http.get('/loanproducts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Recurring deposit products data
|
||||
*/
|
||||
getRecurringDepositProducts(): Observable<any> {
|
||||
return this.http.get('/recurringdepositproducts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Charges data
|
||||
*/
|
||||
getCharges(): Observable<any> {
|
||||
return this.http.get('/charges');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Fixed deposit products data
|
||||
*/
|
||||
getFixedDepositProducts(): Observable<any> {
|
||||
return this.http.get('/fixeddepositproducts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Tax Components data
|
||||
*/
|
||||
getTaxComponents(): Observable<any> {
|
||||
return this.http.get('/taxes/component');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Product mixes data
|
||||
*/
|
||||
getProductMixes(): Observable<any> {
|
||||
let httpParams = new HttpParams();
|
||||
httpParams = httpParams.set('associations', 'productMixes');
|
||||
return this.http.get('/loanproducts', { params: httpParams });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ $accent: $peter-river;
|
||||
|
||||
//Status Colors Defined Here
|
||||
$status-active: #00ce00;
|
||||
$status-inactive: #666f73;
|
||||
$status-deleted: #000000;
|
||||
$status-pending: #ffa500;
|
||||
$status-approved: #0f36e4;
|
||||
|
||||
@@ -1673,6 +1673,10 @@ textarea.noresize {
|
||||
color: $status-active;
|
||||
}
|
||||
|
||||
.status-inactive {
|
||||
color: $status-inactive;
|
||||
}
|
||||
|
||||
.status-deleted {
|
||||
color: $status-deleted;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user