Browse Source

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
pull/778/head
Patrick Magee 4 years ago
committed by GitHub
parent
commit
225787e39f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      frontend/app/shared/components/schema-category.component.ts

8
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());

Loading…
Cancel
Save