refactor: add 'mobile' and 'gender' columns in client list (#354)

Fixes: #79
This commit is contained in:
Meet Patel
2019-01-03 01:57:01 +05:30
committed by Abhay Chawla
parent f83c262bf7
commit ff77528990
2 changed files with 19 additions and 2 deletions
+12
View File
@@ -37,6 +37,18 @@
</td>
</ng-container>
<!-- Mobile Number Column-->
<ng-container matColumnDef="mobileNo">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Mobile Number </th>
<td mat-cell *matCellDef="let client"> {{ client.mobileNo }} </td>
</ng-container>
<!--Gender column-->
<ng-container matColumnDef="gender">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Gender </th>
<td mat-cell *matCellDef="let client" > {{ client.gender.name }} </td>
</ng-container>
<!-- Color Column -->
<ng-container matColumnDef="office">
<th mat-header-cell *matHeaderCellDef mat-sort-header='officeName'> OfficeName </th>
+7 -2
View File
@@ -14,7 +14,7 @@ import { Observable } from 'rxjs';
export class ClientsComponent implements OnInit {
post: any = [];
private ELEMENT_DATA: any = undefined;
displayedColumns = ['name', 'clientno', 'externalid', 'status', 'office', 'staff'];
displayedColumns = ['name', 'clientno', 'externalid', 'status', 'mobileNo', 'gender', 'office', 'staff'];
dataSource = new MatTableDataSource();
@ViewChild(MatPaginator) paginator: MatPaginator;
@@ -35,8 +35,13 @@ export class ClientsComponent implements OnInit {
res.active = !!res.active;
this.dataSource = new MatTableDataSource(res);
this.dataSource.paginator = this.paginator;
this.dataSource.sortingDataAccessor = (data: any, property: any) => {
switch (property) {
case 'gender': return data.gender.name;
default: return data[property];
}
};
this.dataSource.sort = this.sort;
this.dataSource.sortingDataAccessor = (data, header) => data[header];
})
);
}