Amended supplier list
This commit is contained in:
parent
40462b7d8f
commit
8202cdfdb1
3 changed files with 30 additions and 6 deletions
|
@ -4,9 +4,18 @@
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th (click)="sortName()">Name <span class="fa-stack">
|
||||||
<th>Postcode</th>
|
<i *ngIf="sortBy !== 'name' || sortDir == 'asc'" class="fa fa-sort-up fa-stack-1x"></i>
|
||||||
<th>Spend</th>
|
<i *ngIf="sortBy !== 'name' || sortDir == 'desc'" class="fa fa-sort-down fa-stack-1x"></i>
|
||||||
|
</span></th>
|
||||||
|
<th (click)="sortPostcode()">Postcode <span class="fa-stack">
|
||||||
|
<i *ngIf="sortBy !== 'postcode' || sortDir == 'asc'" class="fa fa-sort-up fa-stack-1x"></i>
|
||||||
|
<i *ngIf="sortBy !== 'postcode' || sortDir == 'desc'" class="fa fa-sort-down fa-stack-1x"></i>
|
||||||
|
</span></th>
|
||||||
|
<th (click)="sortSpend()">Spend <span class="fa-stack">
|
||||||
|
<i *ngIf="sortBy !== 'spend' || sortDir == 'asc'" class="fa fa-sort-up fa-stack-1x"></i>
|
||||||
|
<i *ngIf="sortBy !== 'spend' || sortDir == 'desc'" class="fa fa-sort-down fa-stack-1x"></i>
|
||||||
|
</span></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
|
@ -18,6 +18,8 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
supplierList: any;
|
supplierList: any;
|
||||||
supplierListAvailable = false;
|
supplierListAvailable = false;
|
||||||
|
sortBy = 'name';
|
||||||
|
sortDir = 'asc';
|
||||||
|
|
||||||
public paginateConfig: PaginationInstance = {
|
public paginateConfig: PaginationInstance = {
|
||||||
id: 'transpaginate',
|
id: 'transpaginate',
|
||||||
|
@ -39,7 +41,7 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSuppliers(logPage: number) {
|
loadSuppliers(logPage: number) {
|
||||||
this.api.externalSuppliers(logPage).subscribe(
|
this.api.externalSuppliers(logPage, this.sortBy, this.sortDir).subscribe(
|
||||||
result => {
|
result => {
|
||||||
this.supplierList = result.suppliers;
|
this.supplierList = result.suppliers;
|
||||||
this.paginateConfig.totalItems = result.page_no;
|
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() {
|
ngAfterViewInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,13 +144,15 @@ export class ApiService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public externalSuppliers(data) {
|
public externalSuppliers(data, sortBy, sortDir) {
|
||||||
const key = this.sessionKey;
|
const key = this.sessionKey;
|
||||||
return this.http.post<any>(
|
return this.http.post<any>(
|
||||||
this.apiUrl + '/v1/organisation/external/suppliers',
|
this.apiUrl + '/v1/organisation/external/suppliers',
|
||||||
{
|
{
|
||||||
session_key : key,
|
session_key : key,
|
||||||
page : data
|
page : data,
|
||||||
|
sort_by : sortBy,
|
||||||
|
sort_dir : sortDir
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue