External filament select for edit spool form

This commit is contained in:
Donkie
2024-05-12 22:08:47 +02:00
parent 4598d8f520
commit 55471062ab
3 changed files with 60 additions and 74 deletions

View File

@@ -35,3 +35,12 @@ export function getFiltersForField<Obj, Field extends keyof Obj>(
export function removeUndefined<T>(array: (T | undefined)[]): T[] {
return array.filter((value) => value !== undefined) as T[];
}
/**
* Performs a case-insensitive search for the given query in the given string.
* The query is broken down into words and the search is performed on each word.
*/
export function searchMatches(query: string, test: string): boolean {
const words = query.toLowerCase().split(" ");
return words.every((word) => test.toLowerCase().includes(word));
}