From 225787e39f605de19c34f7758257f501f481d14f Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Wed, 27 Oct 2021 16:23:08 +0100 Subject: [PATCH] schema filtering enhancement (#776) * allow partial matches but as more terms are added filter the results to those partial matches * Optmisations and refactoring from PR feedback --- .../app/shared/components/schema-category.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/app/shared/components/schema-category.component.ts b/frontend/app/shared/components/schema-category.component.ts index 1a76d7e1d..437ad1c2b 100644 --- a/frontend/app/shared/components/schema-category.component.ts +++ b/frontend/app/shared/components/schema-category.component.ts @@ -63,8 +63,12 @@ export class SchemaCategoryComponent implements OnChanges { } if (this.schemasFilter) { - this.filteredSchemas = this.filteredSchemas.filter(x => x.name.indexOf(this.schemasFilter) >= 0); - + const terms = this.schemasFilter.trim().split(' ').map(x => new RegExp(x.trim(), 'i')); + const matches = (value: string | undefined | null) => value && terms.every(term => value.search(term) >= 0); + this.filteredSchemas = this.filteredSchemas.filter(x => + matches(x.name) || + matches(x.properties.label) || + matches(x.properties.hints)); this.isCollapsed = false; } else { this.isCollapsed = this.localStore.getBoolean(this.configKey());