From 0504086fefd96d5800607cb1f1fb6c0f9425ab22 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Sat, 6 Nov 2021 02:49:57 +0200 Subject: [PATCH] show manual redactions and their pages when excluded --- .../src/app/models/file/file-data.model.ts | 2 +- .../file-workload.component.html | 1 + .../file-workload/file-workload.component.ts | 5 ++++ .../pdf-viewer/pdf-viewer.component.ts | 25 +++++++++++-------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index 4a82bd0a4..6407c15fd 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -24,7 +24,7 @@ export class FileDataModel { const entries: RedactionLogEntryWrapper[] = this._convertData(); let allAnnotations = entries .map(entry => AnnotationWrapper.fromData(entry)) - .filter(ann => !this.file.excludedPages.includes(ann.pageNumber)); + .filter(ann => ann.manual || !this.file.excludedPages.includes(ann.pageNumber)); if (!areDevFeaturesEnabled) { allAnnotations = allAnnotations.filter(annotation => !annotation.isFalsePositive); diff --git a/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.html index e3074ac88..7ee814bf5 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.html @@ -88,6 +88,7 @@ [activeSelection]="pageHasSelection(pageNumber)" [active]="pageNumber === activeViewerPage" [number]="pageNumber" + [showDottedIcon]="hasOnlyManualRedactionsAndNotExcluded(pageNumber)" [viewedPages]="fileData?.viewedPages" > diff --git a/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.ts index 6d5cabf4e..6f7328ee1 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.ts @@ -118,6 +118,11 @@ export class FileWorkloadComponent { } } + hasOnlyManualRedactionsAndNotExcluded(pageNumber: number): boolean { + const hasOnlyManualRedactions = this.displayedAnnotations.get(pageNumber).every(annotation => annotation.manual); + return hasOnlyManualRedactions && this.fileData.file.excludedPages.includes(pageNumber); + } + pageHasSelection(page: number) { return this.multiSelectActive && !!this.selectedAnnotations?.find(a => a.pageNumber === page); } 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 a5cbb42ed..e460b7e02 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 @@ -323,7 +323,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { textTool.SELECTION_MODE = this._configService.values.SELECTION_MODE; } - private _toggleRectangleAnnotationAction(readonly: boolean) { + private _toggleRectangleAnnotationAction(readonly = false) { if (!readonly) { this.instance.UI.enableElements([dataElements.ADD_RECTANGLE]); } else { @@ -529,14 +529,14 @@ export class PdfViewerComponent implements OnInit, OnChanges { this.instance.UI.textPopup.add([ { type: 'actionButton', - dataElement: 'add-redaction', + dataElement: dataElements.ADD_REDACTION, img: this._convertPath('/assets/icons/general/pdftron-action-add-redaction.svg'), title: this._translateService.instant(this._manualAnnotationService.getTitle(ManualRedactionEntryTypes.REDACTION)), onClick: () => this._addManualRedactionOfType(ManualRedactionEntryTypes.REDACTION), }, { type: 'actionButton', - dataElement: 'add-dictionary', + dataElement: dataElements.ADD_DICTIONARY, img: this._convertPath('/assets/icons/general/pdftron-action-add-dict.svg'), title: this._translateService.instant(this._manualAnnotationService.getTitle(ManualRedactionEntryTypes.DICTIONARY)), onClick: () => this._addManualRedactionOfType(ManualRedactionEntryTypes.DICTIONARY), @@ -555,13 +555,14 @@ export class PdfViewerComponent implements OnInit, OnChanges { private _handleCustomActions() { this.instance.UI.setToolMode('AnnotationEdit'); + const { ANNOTATION_POPUP, ADD_RECTANGLE, ADD_REDACTION, SHAPE_TOOL_GROUP_BUTTON } = dataElements; const elements = [ - 'add-redaction', - 'add-rectangle', + ADD_REDACTION, + ADD_RECTANGLE, 'add-false-positive', - 'shapeToolGroupButton', + SHAPE_TOOL_GROUP_BUTTON, 'rectangleToolDivider', - 'annotationPopup', + ANNOTATION_POPUP, ]; if (this.canPerformActions && !this.utils.isCurrentPageExcluded) { @@ -575,13 +576,15 @@ export class PdfViewerComponent implements OnInit, OnChanges { return; } - const elementsToDisable = [...elements, dataElements.ADD_RECTANGLE]; + let elementsToDisable = [...elements, ADD_RECTANGLE]; + if (this.utils.isCurrentPageExcluded) { - elementsToDisable.splice(elementsToDisable.indexOf(dataElements.ADD_REDACTION), 1); - elementsToDisable.splice(elementsToDisable.indexOf(dataElements.SHAPE_TOOL_GROUP_BUTTON), 1); + const allowedActionsWhenPageExcluded: string[] = [ANNOTATION_POPUP, ADD_RECTANGLE, ADD_REDACTION, SHAPE_TOOL_GROUP_BUTTON]; + elementsToDisable = elementsToDisable.filter(element => !allowedActionsWhenPageExcluded.includes(element)); + } else { + this.instance.UI.disableTools(['AnnotationCreateRectangle']); } - this.instance.UI.disableTools(['AnnotationCreateRectangle']); this.instance.UI.disableElements(elementsToDisable); }