From 9cf802afe87fbefc54c45a0c6cb49d85057fee96 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Wed, 21 Dec 2022 15:54:43 +0200 Subject: [PATCH] RED-5399 - Toggle in preview: Make redactions (un)readable --- .../services/suggestions.service.ts | 1 + .../services/readable-redactions.service.ts | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts index 429a4d2bd..f9a2cfa4c 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts @@ -41,6 +41,7 @@ export class SuggestionsService { #convertRemoveSuggestionsToRedactions(suggestions: Annotation[]): void { const removeSuggestions = suggestions.filter(a => bool(a.getCustomData('suggestionRemove'))); + removeSuggestions.forEach(s => s.setCustomData('suggestion', 'false')); this._readableRedactionsService.setPreviewAnnotationsOpacity(removeSuggestions); this._readableRedactionsService.setPreviewAnnotationsColor(removeSuggestions); this._annotationManager.show(removeSuggestions); diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/readable-redactions.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/readable-redactions.service.ts index c98c4ba77..432d1807a 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/readable-redactions.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/readable-redactions.service.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from '@angular/core'; -import { BASE_HREF_FN, BaseHrefFn } from '@iqser/common-ui'; +import { BASE_HREF_FN, BaseHrefFn, bool } from '@iqser/common-ui'; import { TranslateService } from '@ngx-translate/core'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { HeaderElements } from '../../file-preview/utils/constants'; @@ -13,8 +13,8 @@ import Annotation = Core.Annotations.Annotation; @Injectable() export class ReadableRedactionsService { readonly active$: Observable; - readonly #enableIcon = this._convertPath('/assets/icons/general/pdftron-action-enable-tooltips.svg'); - readonly #disableIcon = this._convertPath('/assets/icons/general/pdftron-action-disable-tooltips.svg'); + readonly #enableIcon = this._convertPath('/assets/icons/general/pdftron-action-disable-tooltips.svg'); + readonly #disableIcon = this._convertPath('/assets/icons/general/pdftron-action-enable-tooltips.svg'); readonly #active$ = new BehaviorSubject(true); constructor( @@ -65,11 +65,18 @@ export class ReadableRedactionsService { } setPreviewAnnotationsOpacity(annotations: Annotation[]) { - this.setAnnotationsOpacity(annotations, !this.active); + annotations.forEach(annotation => { + const isSuggestion = bool(annotation.getCustomData('suggestion')); + const restoreToOriginal = !this.active && !isSuggestion; + this.setAnnotationsOpacity([annotation], restoreToOriginal); + }); } setPreviewAnnotationsColor(annotations: Annotation[]) { - const color = this.active ? 'redactionColor' : 'finalRedactionColor'; - this.setAnnotationsColor(annotations, color); + annotations.forEach(annotation => { + const isSuggestion = bool(annotation.getCustomData('suggestion')); + const color = this.active || isSuggestion ? 'redactionColor' : 'finalRedactionColor'; + this.setAnnotationsColor([annotation], color); + }); } }