feat: add fixed deposit products component (#345)
This commit is contained in:
committed by
Abhay Chawla
parent
6d125b3525
commit
24db7caed5
@@ -0,0 +1,40 @@
|
||||
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
|
||||
<button mat-raised-button color="primary">
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
Create Fixed Deposit Product
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div fxLayout="row" fxLayoutGap="20px">
|
||||
<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 fixedDepositProduct"> {{ fixedDepositProduct.name }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="shortName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Short Name </th>
|
||||
<td mat-cell *matCellDef="let fixedDepositProduct"> {{ fixedDepositProduct.shortName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
table {
|
||||
width: 100%;
|
||||
|
||||
.select-row:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { FixedDepositProductsComponent } from './fixed-deposit-products.component';
|
||||
|
||||
describe('FixedDepositProductsComponent', () => {
|
||||
let component: FixedDepositProductsComponent;
|
||||
let fixture: ComponentFixture<FixedDepositProductsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ FixedDepositProductsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FixedDepositProductsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { of } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Fixed Deposit Products component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-fixed-deposit-products',
|
||||
templateUrl: './fixed-deposit-products.component.html',
|
||||
styleUrls: ['./fixed-deposit-products.component.scss']
|
||||
})
|
||||
export class FixedDepositProductsComponent implements OnInit {
|
||||
|
||||
/** Fixed deposit products data. */
|
||||
fixedDepositProductData: any;
|
||||
/** Columns to be displayed in fixed deposit products table. */
|
||||
displayedColumns: string[] = ['name', 'shortName'];
|
||||
/** Data source for fixed deposit products table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for fixed deposit products table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for fixed deposit products table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
/**
|
||||
* Retrieves the fixed deposit products data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { fixedDepositProducts: any }) => {
|
||||
this.fixedDepositProductData = data.fixedDepositProducts;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters data in fixed deposit products table based on passed value.
|
||||
* @param {string} filterValue Value to filter data.
|
||||
*/
|
||||
applyFilter(filterValue: string) {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fixed deposit products table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setFixedDepositProducts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for fixed deposit products table.
|
||||
*/
|
||||
setFixedDepositProducts() {
|
||||
this.dataSource = new MatTableDataSource(this.fixedDepositProductData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/** 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';
|
||||
|
||||
/**
|
||||
* Fixed Deposit Products data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class FixedDepositProductsResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {ProductsService} productsService Products service.
|
||||
*/
|
||||
constructor(private productsService: ProductsService) {}
|
||||
|
||||
/**
|
||||
* Returns the fixed deposit products data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(): Observable<any> {
|
||||
return this.productsService.getFixedDepositProducts();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,10 +13,12 @@ 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';
|
||||
|
||||
/** 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';
|
||||
|
||||
/** Products Routes */
|
||||
const routes: Routes = [
|
||||
@@ -50,6 +52,14 @@ const routes: Routes = [
|
||||
},
|
||||
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' },
|
||||
},
|
||||
]
|
||||
}
|
||||
])
|
||||
@@ -66,6 +76,7 @@ const routes: Routes = [
|
||||
providers: [
|
||||
RecurringDepositProductsResolver,
|
||||
ChargesResolver,
|
||||
FixedDepositProductsResolver
|
||||
]
|
||||
})
|
||||
export class ProductsRoutingModule { }
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<p matLine>Defines rules for taking multiple rules</p>
|
||||
</mat-list-item>
|
||||
|
||||
<mat-list-item>
|
||||
<mat-list-item [routerLink]="['fixed-deposit-products']">
|
||||
<mat-icon matListIcon>
|
||||
<fa-icon icon="briefcase" size="sm"></fa-icon>
|
||||
</mat-icon>
|
||||
|
||||
@@ -10,6 +10,7 @@ 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';
|
||||
|
||||
/**
|
||||
* Products Module
|
||||
@@ -25,7 +26,8 @@ import { ChargesComponent } from './charges/charges.component';
|
||||
ProductsComponent,
|
||||
ManageTaxConfigurationsComponent,
|
||||
RecurringDepositProductsComponent,
|
||||
ChargesComponent
|
||||
ChargesComponent,
|
||||
FixedDepositProductsComponent
|
||||
],
|
||||
entryComponents: [
|
||||
]
|
||||
|
||||
@@ -34,4 +34,12 @@ export class ProductsService {
|
||||
return this.http.get('/charges');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} Fetches fixed deposit products.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getFixedDepositProducts(): Observable<any> {
|
||||
return this.http.get('/fixeddepositproducts');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user