diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index 378755fad..168ee1bc9 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -49,6 +49,7 @@ export class AnnotationWrapper { manual?: boolean; image?: boolean; + isHidden?: boolean; force?: boolean; textAfter?: string; diff --git a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.ts b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.ts index 42859ed31..2c2bf4d51 100644 --- a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.ts @@ -80,12 +80,14 @@ export class AnnotationActionsComponent implements OnInit { $event.stopPropagation(); this.viewer.annotManager.hideAnnotations(this.viewerAnnotations); this.viewer.annotManager.deselectAllAnnotations(); + this.annotationActionsService.updateHiddenAnnotation(this.annotations, this.viewerAnnotations, true); } showAnnotation($event: MouseEvent) { $event.stopPropagation(); this.viewer.annotManager.showAnnotations(this.viewerAnnotations); this.viewer.annotManager.deselectAllAnnotations(); + this.annotationActionsService.updateHiddenAnnotation(this.annotations, this.viewerAnnotations, false); } private _setPermissions() { diff --git a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts index 18d43d079..20393a244 100644 --- a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts @@ -31,8 +31,8 @@ import { loadCompareDocumentWrapper } from '../../utils/compare-mode.utils'; import { PdfViewerUtils } from '../../utils/pdf-viewer.utils'; import { ViewMode } from '@models/file/view-mode'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import TextTool = Tools.TextTool; import { ActivatedRoute } from '@angular/router'; +import TextTool = Tools.TextTool; @Component({ selector: 'redaction-pdf-viewer', @@ -406,7 +406,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { img: allAreVisible ? this._convertPath('/assets/icons/general/visibility-off.svg') : this._convertPath('/assets/icons/general/visibility.svg'), - title: this._translateService.instant('annotation-actions.hide'), + title: this._translateService.instant(`annotation-actions.${allAreVisible ? 'hide' : 'show'}`), onClick: () => { this._ngZone.run(() => { if (allAreVisible) { @@ -415,6 +415,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { this.instance.annotManager.showAnnotations(viewerAnnotations); } this.instance.annotManager.deselectAllAnnotations(); + this._annotationActionsService.updateHiddenAnnotation(this.annotations, viewerAnnotations, allAreVisible); }); } } diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index f462b5161..3db1dcf57 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -267,12 +267,17 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni } console.log('[REDACTION] Delete previous annotations time: ' + (new Date().getTime() - startTime) + 'ms'); const processStartTime = new Date().getTime(); - this.annotationData = this.fileData.getAnnotations( + const newAnnotationsData = this.fileData.getAnnotations( this.appStateService.dictionaryData[this.appStateService.activeDossier.dossierTemplateId], this.userService.currentUser, this.viewMode, this.userPreferenceService.areDevFeaturesEnabled ); + if (this.annotationData) { + this._setIsHiddenPropertyToNewAnnotations(newAnnotationsData.visibleAnnotations, this.annotationData.visibleAnnotations); + this._setIsHiddenPropertyToNewAnnotations(newAnnotationsData.allAnnotations, this.annotationData.allAnnotations); + } + this.annotationData = newAnnotationsData; const annotationFilters = this._annotationProcessingService.getAnnotationFilter(this.annotations); const primaryFilters = this._filterService.getGroup('primaryFilters')?.filters; this._filterService.addFilterGroup({ @@ -526,6 +531,15 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni window.open(`/html-debug/${this.dossierId}/${this.fileId}`, '_blank'); } + private _setIsHiddenPropertyToNewAnnotations(newAnnotations: AnnotationWrapper[], oldAnnotations: AnnotationWrapper[]) { + newAnnotations.map((newAnnotation: AnnotationWrapper) => { + const oldAnnotation = oldAnnotations.find((a: AnnotationWrapper) => a.annotationId === newAnnotation.annotationId); + if (oldAnnotation) { + newAnnotation.isHidden = oldAnnotation.isHidden; + } + }); + } + private async _doStampExcludedPages(excludedPages: number[]) { if (excludedPages && excludedPages.length > 0) { const document = await this._instance.docViewer.getDocument().getPDFDoc(); diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts index 4136c8d98..dab69a479 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts @@ -10,6 +10,7 @@ import { AnnotationPermissions } from '@models/file/annotation.permissions'; import { DossiersDialogService } from './dossiers-dialog.service'; import { BASE_HREF } from '../../../tokens'; import { UserService } from '@services/user.service'; +import { Annotations } from '@pdftron/webviewer'; @Injectable() export class AnnotationActionsService { @@ -280,6 +281,12 @@ export class AnnotationActionsService { return availableActions; } + updateHiddenAnnotation(annotations: AnnotationWrapper[], viewerAnnotations: Annotations.Annotation[], isHidden: boolean) { + const annotationId = (viewerAnnotations[0] as any).Tw; + const annotationToBeUpdated = annotations.find((a: AnnotationWrapper) => a.annotationId === annotationId); + annotationToBeUpdated.isHidden = isHidden; + } + private _processObsAndEmit(obs: Observable, annotation: AnnotationWrapper, annotationsChanged: EventEmitter) { obs.subscribe( () => { diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-draw.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-draw.service.ts index 6d0b3ac57..18368bbc9 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-draw.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-draw.service.ts @@ -91,8 +91,11 @@ export class AnnotationDrawService { highlight.ReadOnly = true; // change log entries are drawn lighter highlight.Opacity = annotationWrapper.isChangeLogRemoved ? 0.2 : 1; - highlight.Hidden = annotationWrapper.isChangeLogRemoved || (hideSkipped && annotationWrapper.isSkipped) || annotationWrapper.isOCR; - + highlight.Hidden = + annotationWrapper.isChangeLogRemoved || + (hideSkipped && annotationWrapper.isSkipped) || + annotationWrapper.isOCR || + annotationWrapper.isHidden; highlight.setCustomData('redacto-manager', true); highlight.setCustomData('redaction', annotationWrapper.isRedacted); highlight.setCustomData('skipped', annotationWrapper.isSkipped);