From c807524991ec556cbf61db82d53f0db1342ad9ca Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Mon, 28 Feb 2022 19:32:21 +0200 Subject: [PATCH] Text highlight cleanup --- .../file-preview-screen.component.ts | 17 +++++++++++++---- libs/red-domain/src/lib/files/file.model.ts | 4 +++- libs/red-domain/src/lib/files/file.ts | 5 +++++ 3 files changed, 21 insertions(+), 5 deletions(-) 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 a4b57d3b2..2dd141fea 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 @@ -152,10 +152,19 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni return; } + const textHighlightAnnotationIds = this._fileData.textHighlightAnnotations.map(a => a.id); + const textHighlightAnnotations = this._getAnnotations((a: Core.Annotations.Annotation) => + textHighlightAnnotationIds.includes(a.Id), + ); + + this._instance.Core.annotationManager.deleteAnnotations(textHighlightAnnotations, { + imported: true, + force: true, + }); + const ocrAnnotationIds = this._fileData.allAnnotations.filter(a => a.isOCR).map(a => a.id); const annotations = this._getAnnotations(a => a.getCustomData('redact-manager')); const redactions = annotations.filter(a => a.getCustomData('redaction')); - const highlights = annotations.filter(a => a.getCustomData('highlight')); switch (this.viewModeService.viewMode) { case 'STANDARD': { @@ -166,7 +175,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni const nonStandardEntries = annotations.filter(a => a.getCustomData('changeLogRemoved') === 'true'); this._setAnnotationsOpacity(standardEntries, true); this._show(standardEntries); - this._hide([...nonStandardEntries, ...highlights]); + this._hide([...nonStandardEntries]); break; } case 'DELTA': { @@ -175,7 +184,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this._setAnnotationsColor(redactions, 'annotationColor'); this._setAnnotationsOpacity(changeLogEntries, true); this._show(changeLogEntries); - this._hide([...nonChangeLogEntries, ...highlights]); + this._hide([...nonChangeLogEntries]); break; } case 'REDACTED': { @@ -183,7 +192,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this._setAnnotationsOpacity(redactions); this._setAnnotationsColor(redactions, 'redactionColor'); this._show(redactions); - this._hide([...nonRedactionEntries, ...highlights]); + this._hide([...nonRedactionEntries]); break; } case 'TEXT_HIGHLIGHTS': { diff --git a/libs/red-domain/src/lib/files/file.model.ts b/libs/red-domain/src/lib/files/file.model.ts index b5930769c..deeddd3fd 100644 --- a/libs/red-domain/src/lib/files/file.model.ts +++ b/libs/red-domain/src/lib/files/file.model.ts @@ -40,6 +40,7 @@ export class File extends Entity implements IFile { readonly hasSuggestions: boolean; readonly processingStatus: ProcessingFileStatus; readonly workflowStatus: WorkflowFileStatus; + readonly fileManipulationDate: string; readonly statusSort: number; readonly cacheIdentifier?: string; @@ -96,9 +97,10 @@ export class File extends Entity implements IFile { this.uploader = file.uploader; this.excludedPages = file.excludedPages || []; this.hasSuggestions = !!file.hasSuggestions; + this.fileManipulationDate = file.fileManipulationDate; this.statusSort = StatusSorter[this.workflowStatus]; - this.cacheIdentifier = btoa((this.lastUploaded ?? '') + (this.lastOCRTime ?? '')); + this.cacheIdentifier = btoa(this.fileManipulationDate ?? ''); this.hintsOnly = this.hasHints && !this.hasRedactions; this.hasNone = !this.hasRedactions && !this.hasHints && !this.hasSuggestions; this.isProcessing = isProcessingStatuses.includes(this.processingStatus); diff --git a/libs/red-domain/src/lib/files/file.ts b/libs/red-domain/src/lib/files/file.ts index 6208d4fab..8f8c29446 100644 --- a/libs/red-domain/src/lib/files/file.ts +++ b/libs/red-domain/src/lib/files/file.ts @@ -147,4 +147,9 @@ export interface IFile { readonly processingStatus: ProcessingFileStatus; readonly workflowStatus: WorkflowFileStatus; + + /** + * Last time the actual file was touched + */ + readonly fileManipulationDate: string; }