From 43f0adb3fb5f8e5d413fb5bb40290c8a89dd607d Mon Sep 17 00:00:00 2001 From: Dushko Jordanovski Date: Tue, 14 Sep 2021 15:32:49 +0200 Subject: [PATCH] feat(admin-ui): Improve facet filtering for product search input Closes #1078 --- .../product-search-input.component.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/admin-ui/src/lib/catalog/src/components/product-search-input/product-search-input.component.ts b/packages/admin-ui/src/lib/catalog/src/components/product-search-input/product-search-input.component.ts index 23f64ec428..2c192d35a0 100644 --- a/packages/admin-ui/src/lib/catalog/src/components/product-search-input/product-search-input.component.ts +++ b/packages/admin-ui/src/lib/catalog/src/components/product-search-input/product-search-input.component.ts @@ -60,9 +60,21 @@ export class ProductSearchInputComponent { if (!this.isFacetValueItem(item)) { return false; } + + const cix = term.indexOf(':'); + const facetName = cix > -1 ? term.toLowerCase().slice(0, cix) : null; + const facetVal = cix > -1 ? term.toLowerCase().slice(cix + 1) : term.toLowerCase(); + + if (facetName) { + return ( + item.facetValue.facet.name.toLowerCase().includes(facetName) && + item.facetValue.name.toLocaleLowerCase().includes(facetVal) + ); + } + return ( - item.facetValue.name.toLowerCase().startsWith(term.toLowerCase()) || - item.facetValue.facet.name.toLowerCase().startsWith(term.toLowerCase()) + item.facetValue.name.toLowerCase().includes(term.toLowerCase()) || + item.facetValue.facet.name.toLowerCase().includes(term.toLowerCase()) ); };