forked from xurror/web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(products): add share products component (openMF#459)
Add share products component to list all share products.
Fixes: #458
- Loading branch information
1 parent
9d0e7d3
commit b6110a9
Showing
9 changed files
with
167 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/app/products/share-products/share-products.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
3 changes: 3 additions & 0 deletions
3
src/app/products/share-products/share-products.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table { | ||
width: 100%; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/products/share-products/share-products.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
src/app/products/share-products/share-products.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/app/products/share-products/share-products.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |