Skip to content

Commit

Permalink
feat(admin-ui): Improve facet filtering for product search input
Browse files Browse the repository at this point in the history
Closes #1078
  • Loading branch information
skid authored and michaelbromley committed Sep 14, 2021
1 parent abfd986 commit 43f0adb
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
);
};

Expand Down

0 comments on commit 43f0adb

Please sign in to comment.