feat: add navigation component (#590)

Fixes: #256
This commit is contained in:
punwai
2020-05-24 22:28:47 +05:30
committed by GitHub
parent 7a5069e590
commit e2707a1d0a
43 changed files with 1713 additions and 9 deletions
@@ -0,0 +1,44 @@
<div fxLayout="row" fxLayoutAlign="space-between center">
<mat-form-field fxFlex="50%">
<mat-label>Filter</mat-label>
<input matInput (keyup)="applyFilter($event.target.value)">
</mat-form-field>
<button mat-raised-button color="primary" (click)="toggleClosed()">
{{ showClosed ? 'View Active' : 'View Closed' }}
</button>
</div>
<table mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="accountNo">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Account Number </th>
<td mat-cell *matCellDef="let loanAccount">{{ loanAccount.accountNo }}</td>
</ng-container>
<ng-container matColumnDef="productName">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Loan Account </th>
<td mat-cell *matCellDef="let loanAccount">{{ loanAccount.productName }}</td>
</ng-container>
<ng-container matColumnDef="Type">
<th mat-header-cell *matHeaderCellDef> Type </th>
<td mat-cell *matCellDef="let loanAccount">
<fa-icon matTooltip="{{ loanAccount.loanType.value }}" matTooltipPosition="right" [icon]="(loanAccount.loanType.code === 'accountType.individual') ? 'user' : 'users'" size="lg"></fa-icon>
</td>
</ng-container>
<ng-container matColumnDef="Status">
<th mat-header-cell *matHeaderCellDef> Status </th>
<td mat-cell *matCellDef="let loanAccount">
<span [className]="loanAccount.inArrears?'status-active-overdue' : (loanAccount.status.code | statusLookup)">
<fa-icon matTooltip="{{ loanAccount.status.value }}" matTooltipPosition="right" icon="circle" size="md"></fa-icon>
</span>
</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]" showFirstLastButtons></mat-paginator>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoanAccountTableComponent } from './loan-account-table.component';
describe('LoanAccountTableComponent', () => {
let component: LoanAccountTableComponent;
let fixture: ComponentFixture<LoanAccountTableComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoanAccountTableComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoanAccountTableComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,65 @@
/** Angular Imports */
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
/** Custom Pipes */
import { AccountsFilterPipe } from '../../pipes/accounts-filter.pipe';
@Component({
selector: 'mifosx-loan-account-table',
templateUrl: './loan-account-table.component.html',
styleUrls: ['./loan-account-table.component.scss']
})
export class LoanAccountTableComponent implements OnInit {
/** Columns to be displayed in the loan accounts table. */
displayedColumns: string[] = ['accountNo', 'productName', 'Type', 'Status'];
/** Show closed loan accounts */
showClosed = false;
/** Data source for loan account table. */
dataSource: MatTableDataSource<any>;
/** Loan Account Data */
accountData: any;
/** Paginator for loan accounts table. */
@ViewChild(MatPaginator) paginator: MatPaginator;
/** Sorter for loan accounts table. */
@ViewChild(MatSort) sort: MatSort;
/** Loan Account Setter */
@Input() set loanAccountData(data: any) {
this.accountData = data;
const filteredAccountData = this.accountsFilterPipe.transform(data, 'loan', this.showClosed ? 'closed' : 'open');
this.dataSource = new MatTableDataSource(filteredAccountData);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
/**
* @param {AccountsFilterPipe} accountsFilterPipe Accounts Filter Pipe.
*/
constructor(private accountsFilterPipe: AccountsFilterPipe) { }
/**
* Filters data in users table based on passed value.
* @param {string} filterValue Value to filter data.
*/
applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
ngOnInit() {
}
/**
* Toggles the loan status
*/
toggleClosed() {
this.showClosed = !this.showClosed;
const filteredAccountData = this.accountsFilterPipe.transform(this.accountData, 'loan', this.showClosed ? 'closed' : 'open');
this.dataSource = new MatTableDataSource(filteredAccountData);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
}