From 55fb0f660aef112359147f2899f96cf64a90cd79 Mon Sep 17 00:00:00 2001 From: panic-coder Date: Thu, 9 Jan 2020 12:56:59 +0530 Subject: [PATCH] fix case insensitive search in bin locations, categories and suppliers #359 #361 --- .../products/bin-locations/bin-locations.component.ts | 4 +++- .../app/home/products/categories/categories.component.ts | 8 ++++---- admin/src/app/home/suppliers/suppliers.component.ts | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/admin/src/app/home/products/bin-locations/bin-locations.component.ts b/admin/src/app/home/products/bin-locations/bin-locations.component.ts index bece2de3..4d72688c 100644 --- a/admin/src/app/home/products/bin-locations/bin-locations.component.ts +++ b/admin/src/app/home/products/bin-locations/bin-locations.component.ts @@ -170,9 +170,11 @@ export class BinLocationsComponent implements OnInit { */ searchSKU() { this.loading = true; + var pattern = new RegExp('.*'+this.searchSKUText+'.*', "i"); /* case-insensitive RegExp search */ + var filterData = pattern.toString(); let filter = { where: { - sku: this.searchSKUText + sku: { "regexp": filterData } } }; this.orgModelApi.getProductModels(this.userProfile.orgModelId, filter) diff --git a/admin/src/app/home/products/categories/categories.component.ts b/admin/src/app/home/products/categories/categories.component.ts index a257a826..8bb8b100 100644 --- a/admin/src/app/home/products/categories/categories.component.ts +++ b/admin/src/app/home/products/categories/categories.component.ts @@ -71,16 +71,16 @@ export class CategoriesComponent implements OnInit { where: {} }; if (searchText) { + var pattern = new RegExp('.*'+searchText+'.*', "i"); /* case-insensitive RegExp search */ + var filterData = pattern.toString(); filter.where = { - name: { - like: searchText - } + name: { "regexp": filterData } } } let fetchCategories = combineLatest( this.orgModelApi.getCategoryModels(this.userProfile.orgModelId, filter), this.orgModelApi.countCategoryModels(this.userProfile.orgModelId)); - fetchCategories.subscribe((data: any) => { + fetchCategories.subscribe((data: any) => { this.loading = false; this.categories = data[0]; this.totalCategories = data[1].count; diff --git a/admin/src/app/home/suppliers/suppliers.component.ts b/admin/src/app/home/suppliers/suppliers.component.ts index 4e64cc4d..e60c2388 100644 --- a/admin/src/app/home/suppliers/suppliers.component.ts +++ b/admin/src/app/home/suppliers/suppliers.component.ts @@ -87,11 +87,11 @@ export class SuppliersComponent implements OnInit { */ searchSupplier() { this.loading = true; + var pattern = new RegExp('.*'+this.searchSupplierText+'.*', "i"); /* case-insensitive RegExp search */ + var filterData = pattern.toString(); let filter = { where: { - name: { - like: this.searchSupplierText - } + name: { "regexp": filterData } } }; this.orgModelApi.getSupplierModels(this.userProfile.orgModelId, filter)