From 5fb2e2888ce032c638e4b75d07458642f0833e52 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 May 2020 16:16:24 +0200 Subject: First implem global search --- client/src/app/shared/angular/highlight.pipe.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'client/src/app/shared/angular') diff --git a/client/src/app/shared/angular/highlight.pipe.ts b/client/src/app/shared/angular/highlight.pipe.ts index fb6042280..50ee5c1bd 100644 --- a/client/src/app/shared/angular/highlight.pipe.ts +++ b/client/src/app/shared/angular/highlight.pipe.ts @@ -11,19 +11,17 @@ export class HighlightPipe implements PipeTransform { /* use this for global search */ static MULTI_MATCH = 'Multi-Match' - // tslint:disable-next-line:no-empty - constructor () {} - transform ( - contentString: string = null, - stringToHighlight: string = null, - option = 'Single-And-StartsWith-Match', - caseSensitive = false, - highlightStyleName = 'search-highlight' + contentString: string = null, + stringToHighlight: string = null, + option = 'Single-And-StartsWith-Match', + caseSensitive = false, + highlightStyleName = 'search-highlight' ): SafeHtml { if (stringToHighlight && contentString && option) { let regex: any = '' const caseFlag: string = !caseSensitive ? 'i' : '' + switch (option) { case 'Single-Match': { regex = new RegExp(stringToHighlight, caseFlag) @@ -42,10 +40,12 @@ export class HighlightPipe implements PipeTransform { regex = new RegExp(stringToHighlight, 'gi') } } + const replaced = contentString.replace( - regex, - (match) => `${match}` + regex, + (match) => `${match}` ) + return replaced } else { return contentString -- cgit v1.2.3