From 00e6ef9b8ffef8433c317386652ba01cff798a50 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 31 Oct 2022 21:04:20 +0200 Subject: [PATCH] RED-5399 - fixed bugs --- .../file-preview/file-preview-screen.component.ts | 6 ++++-- .../modules/file-preview/services/pdf-proxy.service.ts | 10 +++++++--- .../pdf-viewer/services/readable-redactions.service.ts | 10 ---------- .../pdf-viewer/services/viewer-header.service.ts | 2 +- apps/red-ui/src/assets/i18n/en.json | 2 +- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 7b7613640..5cd780217 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -241,11 +241,13 @@ export class FilePreviewScreenComponent case ViewModes.REDACTED: { const nonRedactionEntries = annotations.filter(a => !bool(a.getCustomData('redaction'))); if (this._readableRedactionsService.active) { - this._readableRedactionsService.makeRedactionsReadable(redactions); + this._setAnnotationsOpacity(redactions, true); + this._setAnnotationsColor(redactions, 'annotationColor'); } else { this._setAnnotationsOpacity(redactions); + this._setAnnotationsColor(redactions, 'redactionColor'); } - this._setAnnotationsColor(redactions, 'redactionColor'); + this._annotationManager.show(redactions); this._annotationManager.hide(nonRedactionEntries); break; diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts index d0847e9a3..3732e9767 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts @@ -1,5 +1,5 @@ import { ChangeDetectorRef, Inject, Injectable, NgZone } from '@angular/core'; -import { IHeaderElement, IManualRedactionEntry } from '@red/domain'; +import { IHeaderElement, IManualRedactionEntry, ViewModes } from '@red/domain'; import { Core } from '@pdftron/webviewer'; import { TranslateService } from '@ngx-translate/core'; import { @@ -274,6 +274,12 @@ export class PdfProxyService { private _handleCustomActions() { const isCurrentPageExcluded = this._state.file.isPageExcluded(this._pdf.currentPage); + if (this._viewModeService.viewMode === ViewModes.REDACTED) { + this._viewerHeaderService.enable([HeaderElements.TOGGLE_READABLE_REDACTIONS]); + } else { + this._viewerHeaderService.disable([HeaderElements.TOGGLE_READABLE_REDACTIONS]); + } + if (this.canPerformActions && !isCurrentPageExcluded) { try { this._pdf.instance.UI.enableTools(['AnnotationCreateRectangle']); @@ -282,7 +288,6 @@ export class PdfProxyService { } this._pdf.enable(TEXT_POPUPS_TO_TOGGLE); this._viewerHeaderService.enable(HEADER_ITEMS_TO_TOGGLE); - this._viewerHeaderService.disable([HeaderElements.TOGGLE_READABLE_REDACTIONS]); if (this._documentViewer.selectedText.length > 2) { this._pdf.enable([TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE]); @@ -305,7 +310,6 @@ export class PdfProxyService { this._pdf.disable(textPopupElementsToDisable); this._viewerHeaderService.disable(headerElementsToDisable); - this._viewerHeaderService.enable([HeaderElements.TOGGLE_READABLE_REDACTIONS]); } private _getManualRedaction(quads: Record, text?: string, convertQuads = false): IManualRedactionEntry { 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 0a9ca7f63..dbdf893b1 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 @@ -6,12 +6,8 @@ import { HeaderElements } from '../../file-preview/utils/constants'; import { PdfViewer } from './pdf-viewer.service'; import { REDAnnotationManager } from './annotation-manager.service'; import { AnnotationDrawService } from './annotation-draw.service'; -import { Core } from '@pdftron/webviewer'; -import Annotation = Core.Annotations.Annotation; import { BehaviorSubject, Observable } from 'rxjs'; -const READABLE_REDACTION_OPACITY = 0.4; - @Injectable() export class ReadableRedactionsService { readonly #enableIcon = this._convertPath('/assets/icons/general/pdftron-action-enable-tooltips.svg'); @@ -43,12 +39,6 @@ export class ReadableRedactionsService { return this.active ? this.#enableIcon : this.#disableIcon; } - makeRedactionsReadable(redactions: Annotation[]): void { - redactions.forEach(redaction => { - redaction['Opacity'] = READABLE_REDACTION_OPACITY; - }); - } - toggleReadableRedactions(): void { this.#active$.next(!this.active); diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts index f20533488..8146d6ca7 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts @@ -26,7 +26,7 @@ export class ViewerHeaderService { readonly #config = new Map([ [HeaderElements.SHAPE_TOOL_GROUP_BUTTON, true], [HeaderElements.TOGGLE_TOOLTIPS, true], - [HeaderElements.TOGGLE_READABLE_REDACTIONS, true], + [HeaderElements.TOGGLE_READABLE_REDACTIONS, false], [HeaderElements.LOAD_ALL_ANNOTATIONS, false], [HeaderElements.COMPARE_BUTTON, true], [HeaderElements.CLOSE_COMPARE_BUTTON, false], diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 9fae51328..401307cfa 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1771,7 +1771,7 @@ "search": "Search for selection" } }, - "toggle-readable-redactions": "Show redactions as {active, select, true{opaque} false{transparent} other{}}", + "toggle-readable-redactions": "Show redactions {active, select, true{as in final document} false{in preview color} other{}}", "toggle-tooltips": "{active, select, true{Disable} false{Enable} other{}} annotation tooltips" }, "permissions-screen": {