No Suppliers available.
diff --git a/src/app/dashboard/suppliers.component.ts b/src/app/dashboard/suppliers.component.ts
index 3210cbc..50421cf 100644
--- a/src/app/dashboard/suppliers.component.ts
+++ b/src/app/dashboard/suppliers.component.ts
@@ -4,7 +4,7 @@ import { AgmCoreModule } from '@agm/core';
import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import { PaginationInstance } from 'ngx-pagination';
-import { FilterPipeModule } from 'ngx-filter-pipe';
+import { FilterPipeModule } from 'ngx-filter-pipe';
@Component({
templateUrl: 'suppliers.component.html',
})
@@ -13,6 +13,8 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
@Input() public categories: any;
public perPage: number = 10;
+ searchText: string;
+
supplierList: any;
supplierListAvailable = false;
sortBy = 'name';
@@ -25,10 +27,6 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
totalItems: 0
};
- public recurClick(event: any): void {
- this.onClick.emit( event );
- }
-
constructor(
private api: ApiService,
) { }
@@ -38,7 +36,7 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
}
loadSuppliers(logPage: number) {
- this.api.externalSuppliers(logPage, this.sortBy, this.sortDir, this.perPage).subscribe(
+ this.api.externalSuppliers(logPage, this.sortBy, this.sortDir, this.perPage, this.searchText).subscribe(
result => {
this.supplierList = result.suppliers;
if (this.supplierList) {
@@ -65,6 +63,11 @@ export class SuppliersComponent implements OnInit, AfterViewInit {
this.loadSuppliers(1);
}
+ searchSuppliers() {
+ // Go back to page 1 when searching
+ this.loadSuppliers(1);
+ }
+
ngAfterViewInit() {
}
diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts
index 5ac5c2a..8307371 100644
--- a/src/app/providers/api-service.ts
+++ b/src/app/providers/api-service.ts
@@ -144,26 +144,28 @@ export class ApiService {
);
}
- public loadMiscUrl(extra_url) {
+ public loadMiscUrl(extra_url, extraArgs = {}) {
const key = this.sessionKey;
return this.http.post
(
this.apiUrl + '/v1/' + extra_url,
{
session_key : key,
+ ...extraArgs,
}
);
}
- public externalSuppliers(data, sortBy, sortDir, perPage) {
+ public externalSuppliers(page, sortBy, sortDir, perPage, search) {
const key = this.sessionKey;
return this.http.post(
this.apiUrl + '/v1/organisation/external/suppliers',
{
session_key : key,
- page : data,
+ page : page,
sort_by : sortBy,
sort_dir : sortDir,
- per_page : perPage
+ per_page : perPage,
+ search : search,
}
);
}