feat: add recurring deposit products component (#341)
This commit is contained in:
committed by
Abhay Chawla
parent
40e328ceb4
commit
07573d011c
@@ -11,6 +11,10 @@ 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';
|
||||
|
||||
/** Custom Resolvers */
|
||||
import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver';
|
||||
|
||||
/** Products Routes */
|
||||
const routes: Routes = [
|
||||
@@ -28,6 +32,14 @@ const routes: Routes = [
|
||||
component: ManageTaxConfigurationsComponent,
|
||||
data: { title: extract('Manage Tax Configurations'), breadcrumb: 'Manage Tax Configurations' },
|
||||
},
|
||||
{
|
||||
path: 'recurring-deposit-products',
|
||||
component: RecurringDepositProductsComponent,
|
||||
resolve: {
|
||||
recurringDepositProducts: RecurringDepositProductsResolver
|
||||
},
|
||||
data: { title: extract('Recurring Deposit Products'), breadcrumb: 'Recurring Deposit Products' },
|
||||
},
|
||||
]
|
||||
}
|
||||
])
|
||||
@@ -42,6 +54,7 @@ const routes: Routes = [
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
RecurringDepositProductsResolver,
|
||||
]
|
||||
})
|
||||
export class ProductsRoutingModule { }
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<p matLine>Add, modify or inactivate a Fixed deposit product</p>
|
||||
</mat-list-item>
|
||||
|
||||
<mat-list-item>
|
||||
<mat-list-item [routerLink]="['recurring-deposit-products']">
|
||||
<mat-icon matListIcon>
|
||||
<fa-icon icon="briefcase" size="sm"></fa-icon>
|
||||
</mat-icon>
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ProductsRoutingModule } from './products-routing.module';
|
||||
/** 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';
|
||||
|
||||
/**
|
||||
* Products Module
|
||||
@@ -22,6 +23,7 @@ import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/ma
|
||||
declarations: [
|
||||
ProductsComponent,
|
||||
ManageTaxConfigurationsComponent,
|
||||
RecurringDepositProductsComponent
|
||||
],
|
||||
entryComponents: [
|
||||
]
|
||||
|
||||
@@ -17,4 +17,13 @@ export class ProductsService {
|
||||
* @param {HttpClient} http Http Client to send requests.
|
||||
*/
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
/**
|
||||
* @param {any} Fetches recurring deposit products.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getRecurringDepositProducts(): Observable<any> {
|
||||
return this.http.get('/recurringdepositproducts');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 Recurring 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 recurringDepositProduct"> {{ recurringDepositProduct.name }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="shortName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Short Name </th>
|
||||
<td mat-cell *matCellDef="let recurringDepositProduct"> {{ recurringDepositProduct.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;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { RecurringDepositProductsComponent } from './recurring-deposit-products.component';
|
||||
|
||||
describe('RecurringDepositProductsComponent', () => {
|
||||
let component: RecurringDepositProductsComponent;
|
||||
let fixture: ComponentFixture<RecurringDepositProductsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ RecurringDepositProductsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(RecurringDepositProductsComponent);
|
||||
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';
|
||||
|
||||
/**
|
||||
* Recurring Deposit Products component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-recurring-deposit-products',
|
||||
templateUrl: './recurring-deposit-products.component.html',
|
||||
styleUrls: ['./recurring-deposit-products.component.scss']
|
||||
})
|
||||
export class RecurringDepositProductsComponent implements OnInit {
|
||||
|
||||
/** Data table data. */
|
||||
recurringDepositProductData: any;
|
||||
/** Columns to be displayed in recurring deposit products table. */
|
||||
displayedColumns: string[] = ['name', 'shortName'];
|
||||
/** Data source for recurring deposit products table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for recurring deposit products table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for recurring deposit products table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
/**
|
||||
* Retrieves the recurring deposit products data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { recurringDepositProducts: any }) => {
|
||||
this.recurringDepositProductData = data.recurringDepositProducts;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters data in recurring 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 recurring deposit products table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setRecurringDepositProducts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for recurring deposit products table.
|
||||
*/
|
||||
setRecurringDepositProducts() {
|
||||
this.dataSource = new MatTableDataSource(this.recurringDepositProductData);
|
||||
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';
|
||||
|
||||
/**
|
||||
* Recurring Deposit Products data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class RecurringDepositProductsResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {ProductsService} productsService Products service.
|
||||
*/
|
||||
constructor(private productsService: ProductsService) {}
|
||||
|
||||
/**
|
||||
* Returns the recurring deposit products data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(): Observable<any> {
|
||||
return this.productsService.getRecurringDepositProducts();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user