feat(products): add share products component (#459)
Add share products component to list all share products. Fixes: #458
This commit is contained in:
@@ -18,6 +18,7 @@ import { SavingProductsComponent } from './saving-products/saving-products.compo
|
||||
import { CreateSavingProductComponent } from './saving-products/create-saving-product/create-saving-product.component';
|
||||
import { ViewSavingProductComponent } from './saving-products/view-saving-product/view-saving-product.component';
|
||||
import { EditSavingProductComponent } from './saving-products/edit-saving-product/edit-saving-product.component';
|
||||
import { ShareProductsComponent } from './share-products/share-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';
|
||||
@@ -34,6 +35,7 @@ import { SavingProductsResolver } from './saving-products/saving-products.resolv
|
||||
import { SavingProductsTemplateResolver } from './saving-products/saving-products-template.resolver';
|
||||
import { SavingProductResolver } from './saving-products/saving-product.resolver';
|
||||
import { SavingProductAndTemplateResolver } from './saving-products/edit-saving-product/saving-product-and-template.resolver';
|
||||
import { ShareProductsResolver } from './share-products/share-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';
|
||||
@@ -135,6 +137,19 @@ const routes: Routes = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'share-products',
|
||||
data: { title: extract('Share Products'), breadcrumb: 'Share Products' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: ShareProductsComponent,
|
||||
resolve: {
|
||||
shareProducts: ShareProductsResolver
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'tax-configurations',
|
||||
data: { title: extract('Manage Tax Configurations'), breadcrumb: 'Manage Tax Configurations' },
|
||||
@@ -207,6 +222,7 @@ const routes: Routes = [
|
||||
SavingProductsTemplateResolver,
|
||||
SavingProductResolver,
|
||||
SavingProductAndTemplateResolver,
|
||||
ShareProductsResolver,
|
||||
RecurringDepositProductsResolver,
|
||||
ChargesResolver,
|
||||
FixedDepositProductsResolver,
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<p matLine>Add new savings product or modify or inactivate savings product</p>
|
||||
</mat-list-item>
|
||||
|
||||
<mat-list-item>
|
||||
<mat-list-item [routerLink]="['share-products']">
|
||||
<mat-icon matListIcon>
|
||||
<fa-icon icon="briefcase" size="sm"></fa-icon>
|
||||
</mat-icon>
|
||||
|
||||
@@ -37,6 +37,7 @@ import { SavingProductPreviewStepComponent } from './saving-products/saving-prod
|
||||
import { CreateSavingProductComponent } from './saving-products/create-saving-product/create-saving-product.component';
|
||||
import { ViewSavingProductComponent } from './saving-products/view-saving-product/view-saving-product.component';
|
||||
import { EditSavingProductComponent } from './saving-products/edit-saving-product/edit-saving-product.component';
|
||||
import { ShareProductsComponent } from './share-products/share-products.component';
|
||||
|
||||
/**
|
||||
* Products Module
|
||||
@@ -78,7 +79,8 @@ import { EditSavingProductComponent } from './saving-products/edit-saving-produc
|
||||
SavingProductPreviewStepComponent,
|
||||
CreateSavingProductComponent,
|
||||
ViewSavingProductComponent,
|
||||
EditSavingProductComponent
|
||||
EditSavingProductComponent,
|
||||
ShareProductsComponent
|
||||
],
|
||||
entryComponents: [
|
||||
],
|
||||
|
||||
@@ -66,6 +66,13 @@ export class ProductsService {
|
||||
return this.http.put(`/savingsproducts/${savingProductId}`, savingProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Share products data
|
||||
*/
|
||||
getShareProducts(): Observable<any> {
|
||||
return this.http.get('/products/share');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Recurring deposit products data
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<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 Share 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 shareProduct"> {{ shareProduct.name }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="shortName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Short Name </th>
|
||||
<td mat-cell *matCellDef="let shareProduct"> {{ shareProduct.shortName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="totalShares">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Total Shares </th>
|
||||
<td mat-cell *matCellDef="let shareProduct"> {{ shareProduct.totalShares }} </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 { ShareProductsComponent } from './share-products.component';
|
||||
|
||||
describe('ShareProductsComponent', () => {
|
||||
let component: ShareProductsComponent;
|
||||
let fixture: ComponentFixture<ShareProductsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ShareProductsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ShareProductsComponent);
|
||||
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-share-products',
|
||||
templateUrl: './share-products.component.html',
|
||||
styleUrls: ['./share-products.component.scss']
|
||||
})
|
||||
export class ShareProductsComponent implements OnInit {
|
||||
|
||||
shareProductsData: any;
|
||||
displayedColumns: string[] = ['name', 'shortName', 'totalShares'];
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe((data: { shareProducts: any }) => {
|
||||
this.shareProductsData = data.shareProducts.pageItems;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.dataSource = new MatTableDataSource(this.shareProductsData);
|
||||
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';
|
||||
|
||||
/**
|
||||
* Share products data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class ShareProductsResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {ProductsService} productsService Products service.
|
||||
*/
|
||||
constructor(private productsService: ProductsService) {}
|
||||
|
||||
/**
|
||||
* Returns the share products data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(): Observable<any> {
|
||||
return this.productsService.getShareProducts();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user