feat: add server-side pagination sort and search for centers component (#506)

- Add server-side pagination, sort and search for centers component
- Refactor code to meet current guidelines

See: #234
This commit is contained in:
punwai
2020-05-07 02:54:09 +05:30
committed by GitHub
parent f2a19708b7
commit 3136cd3b30
6 changed files with 289 additions and 122 deletions
+51 -44
View File
@@ -1,53 +1,60 @@
<div class="container m-t-40 m-b-40">
<mat-card class="container">
<div fxLayout="row" fxLayoutAlign="start center">
<div class="search-box">
<mat-form-field>
<input matInput placeholder="Search by Name" [formControl]="name">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Search by ExternalID" [formControl]="externalId">
</mat-form-field>
<mat-checkbox #showClosedCenters labelPosition="after" (change)="changeShowClosedCenters()">Show Closed Centers
</mat-checkbox>
</div>
<div class="action-button" fxLayoutGap="25px">
<button mat-raised-button color="primary">
<fa-icon icon="download"></fa-icon>&nbsp;&nbsp;Import Center
</button>
<button mat-raised-button color="primary">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;Create Center
</button>
</div>
</div>
<mat-form-field class="filter">
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>
<table mat-table [dataSource]="dataSource" matSort>
<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 center"> {{ center.name }} </td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef mat-sort-header='name'> Name </th>
<td mat-cell *matCellDef="let row"> {{row?.name}} </td>
</ng-container>
<ng-container matColumnDef="accountNo">
<th mat-header-cell *matHeaderCellDef> Account # </th>
<td mat-cell *matCellDef="let center"> {{ center.accountNo }} </td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="accountno">
<th mat-header-cell *matHeaderCellDef mat-sort-header='accountno'> Account # </th>
<td mat-cell *matCellDef="let row"> {{row?.accountNo}} </td>
</ng-container>
<ng-container matColumnDef="externalId">
<th mat-header-cell *matHeaderCellDef> ExternalID </th>
<td mat-cell *matCellDef="let center"> {{ center.externalId }} </td>
</ng-container>
<!-- Account no Column -->
<ng-container matColumnDef="externalid">
<th mat-header-cell *matHeaderCellDef mat-sort-header='externalid'> ExternalID </th>
<td mat-cell *matCellDef="let row"> {{row?.externalId}} </td>
</ng-container>
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef> Status </th>
<td mat-cell *matCellDef="let row">
<div [ngClass]="row.active|statusLookup">
<fa-icon icon="stop"></fa-icon>
</div>
</td>
</ng-container>
<!-- External ID Column -->
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef mat-sort-header='status'> Status </th>
<td mat-cell *matCellDef="let row"> <div [className]="row.active === true ? 'active' : 'inactive'">
<i class="fa fa-circle fa-2x"> </i>
</div> </td>
</ng-container>
<ng-container matColumnDef="officeName">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Office Name </th>
<td mat-cell *matCellDef="let center"> {{ center.officeName }} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="[ ]"></tr>
</table>
<mat-paginator [length]="dataSource?.records$ | async" [pageSize]="10" [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
<!-- Status Column -->
<ng-container matColumnDef="office">
<th mat-header-cell *matHeaderCellDef mat-sort-header='office'> Office </th>
<td mat-cell *matCellDef="let row"> {{row?.officeName}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="[ ]">
</tr>
</table>
<mat-paginator [pageSizeOptions]="[10, 25, 100]"></mat-paginator>
</div>
</mat-card>