diff --git a/src/app/dashboard/suppliers.component.html b/src/app/dashboard/suppliers.component.html
index ab8b3f6..9c442b7 100644
--- a/src/app/dashboard/suppliers.component.html
+++ b/src/app/dashboard/suppliers.component.html
@@ -4,9 +4,18 @@
- Name |
- Postcode |
- Spend |
+ Name
+
+
+ |
+ Postcode
+
+
+ |
+ Spend
+
+
+ |
diff --git a/src/app/dashboard/suppliers.component.ts b/src/app/dashboard/suppliers.component.ts
index 4885cb5..170f674 100644
--- a/src/app/dashboard/suppliers.component.ts
+++ b/src/app/dashboard/suppliers.component.ts
@@ -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() {
}
diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts
index 7d3f00e..b09bcfd 100644
--- a/src/app/providers/api-service.ts
+++ b/src/app/providers/api-service.ts
@@ -144,13 +144,15 @@ export class ApiService {
);
}
- public externalSuppliers(data) {
+ public externalSuppliers(data, sortBy, sortDir) {
const key = this.sessionKey;
return this.http.post(
this.apiUrl + '/v1/organisation/external/suppliers',
{
session_key : key,
- page : data
+ page : data,
+ sort_by : sortBy,
+ sort_dir : sortDir
}
);
}