diff options
Diffstat (limited to 'src/client/util/SearchUtil.ts')
-rw-r--r-- | src/client/util/SearchUtil.ts | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index 65b9a977d..609fedfa9 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -8,16 +8,16 @@ import { DocOptions, FInfo } from '../documents/Documents'; export namespace SearchUtil { export type HighlightingResult = { [id: string]: { [key: string]: string[] } }; - export function SearchCollection(collectionDoc: Opt<Doc>, query: string, matchKeyNames: boolean, onlyKeys?: string[]) { + export function SearchCollection(collectionDoc: Opt<Doc>, queryIn: string, matchKeyNames: boolean, onlyKeys?: string[]) { const blockedTypes = [DocumentType.PRESELEMENT, DocumentType.CONFIG, DocumentType.KVP, DocumentType.FONTICON, DocumentType.BUTTON, DocumentType.SCRIPTING]; const blockedKeys = matchKeyNames ? [] : Object.entries(DocOptions) - .filter(([key, info]: [string, FInfo]) => !info?.searchable()) + .filter(([, info]: [string, FInfo]) => !info?.searchable()) .map(([key]) => key); - const exact = query.startsWith('='); - query = query.toLowerCase().split('=').lastElement(); + const exact = queryIn.startsWith('='); + const query = queryIn.toLowerCase().split('=').lastElement(); const results = new ObservableMap<Doc, string[]>(); if (collectionDoc) { @@ -51,7 +51,11 @@ export namespace SearchUtil { */ export function documentKeys(doc: Doc) { const keys: { [key: string]: boolean } = {}; - Doc.GetAllPrototypes(doc).map(proto => Object.keys(proto).forEach(key => (keys[key] = false))); + Doc.GetAllPrototypes(doc).map(proto => + Object.keys(proto).forEach(key => { + keys[key] = false; + }) + ); return Array.from(Object.keys(keys)); } @@ -62,12 +66,14 @@ export namespace SearchUtil { * This method iterates through an array of docs and all docs within those docs, calling * the function func on each doc. */ - export function foreachRecursiveDoc(docs: Doc[], func: (depth: number, doc: Doc) => void) { + export function foreachRecursiveDoc(docsIn: Doc[], func: (depth: number, doc: Doc) => void) { + let docs = docsIn; let newarray: Doc[] = []; - var depth = 0; + let depth = 0; const visited: Doc[] = []; while (docs.length > 0) { newarray = []; + // eslint-disable-next-line no-loop-func docs.filter(d => d && !visited.includes(d)).forEach(d => { visited.push(d); const fieldKey = Doc.LayoutFieldKey(d); |