Amended supplier list

This commit is contained in:
Finn 2019-07-12 20:05:06 +01:00
parent 40462b7d8f
commit 8202cdfdb1
No known key found for this signature in database
GPG key ID: 7455B4B17685B598
3 changed files with 30 additions and 6 deletions

View file

@ -18,6 +18,8 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
supplierList: any;
supplierListAvailable = false;
sortBy = 'name';
sortDir = 'asc';
public paginateConfig: PaginationInstance = {
id: 'transpaginate',
@ -39,7 +41,7 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
}
loadSuppliers(logPage: number) {
this.api.externalSuppliers(logPage).subscribe(
this.api.externalSuppliers(logPage, this.sortBy, this.sortDir).subscribe(
result => {
this.supplierList = result.suppliers;
this.paginateConfig.totalItems = result.page_no;
@ -53,6 +55,17 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
);
}
sortName() { this.sortByColumn('name'); }
sortPostcode() { this.sortByColumn('postcode'); }
sortSpend() { this.sortByColumn('spend'); }
sortByColumn(name) {
this.sortBy = name;
this.sortDir = this.sortDir === 'asc' ? 'desc' : 'asc';
this.loadSuppliers(1);
}
ngAfterViewInit() {
}