From 4fd67746223a2ad4497c3e66c1a668dac83b145c Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Tue, 6 Jun 2023 18:54:37 +0200 Subject: [PATCH] RED-5912 - Suggestions make redactions disappear in PREVIEW mode --- .../src/app/models/file/annotation.wrapper.ts | 19 ++++++++++++++++++- .../file-preview-screen.component.ts | 2 +- .../services/file-data.service.ts | 7 ++++++- .../services/suggestions.service.ts | 8 ++++---- .../services/annotation-draw.service.ts | 9 ++++++++- 5 files changed, 37 insertions(+), 8 deletions(-) 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 6c19db2d8..f03c7d713 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -112,6 +112,10 @@ export class AnnotationWrapper implements IListable, Record { return this.type?.toLowerCase() === 'image' || this.image; } + get isNotSignatureImage() { + return this.isImage && this.recategorizationType === 'signature'; + } + get isOCR() { return this.type?.toLowerCase() === 'ocr'; } @@ -192,10 +196,18 @@ export class AnnotationWrapper implements IListable, Record { return this.superType === SuperTypes.SuggestionRecategorizeImage; } + get isSuggestionForceHint() { + return this.superType === SuperTypes.SuggestionForceHint; + } + get isSuggestionAdd() { return !!SuggestionAddSuperTypes[this.superType]; } + get isSuggestionAddDictionary() { + return this.superType === SuperTypes.SuggestionAddDictionary; + } + get isSuggestionRemove() { return !!SuggestionRemoveSuperTypes[this.superType]; } @@ -334,9 +346,14 @@ export class AnnotationWrapper implements IListable, Record { const entity = dictionaries.find(d => d.type === annotationWrapper.typeValue); annotationWrapper.entity = entity?.virtual ? null : entity; - const colorKey = annotationWrapper.isSuperTypeBasedColor + let colorKey = annotationWrapper.isSuperTypeBasedColor ? annotationDefaultColorConfig[annotationWrapper.superType] : annotationEntityColorConfig[annotationWrapper.superType]; + + if (annotationWrapper.isSuperTypeBasedColor && annotationWrapper.isSuggestionResize && !annotationWrapper.isModifyDictionary) { + colorKey = annotationDefaultColorConfig[SuperTypes.SuggestionAdd]; + } + annotationWrapper.color = annotationWrapper.isSuperTypeBasedColor ? defaultColors[colorKey] : (entity[colorKey] as string); return annotationWrapper; 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 87db0acbf..b8101a72c 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 @@ -220,7 +220,6 @@ export class FilePreviewScreenComponent switch (this._viewModeService.viewMode) { case ViewModes.STANDARD: { - this._readableRedactionsService.setAnnotationsColor(redactions, 'annotationColor'); const wrappers = await this._fileDataService.annotations; const ocrAnnotationIds = wrappers.filter(a => a.isOCR).map(a => a.id); const standardEntries = annotations @@ -229,6 +228,7 @@ export class FilePreviewScreenComponent const nonStandardEntries = annotations.filter( a => bool(a.getCustomData('changeLogRemoved')) || this._annotationManager.isHidden(a.Id), ); + this._readableRedactionsService.setAnnotationsColor(standardEntries, 'annotationColor'); this._readableRedactionsService.setAnnotationsOpacity(standardEntries, true); this._annotationManager.show(standardEntries); this._annotationManager.hide(nonStandardEntries); diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts index 158405170..25c7793f1 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts @@ -208,7 +208,12 @@ export class FileDataService extends EntitiesService { const lastChange = entry.manualChanges.at(-1); - if (lastChange?.annotationStatus === LogEntryStatuses.REQUESTED && !entry.hint) { + + if ( + lastChange?.annotationStatus === LogEntryStatuses.REQUESTED && + !entry.hint && + !entry.reason.includes('requested to force hint') + ) { entry.manualChanges.pop(); entry.reason = null; filtered.push(entry); 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 0732dc7bb..e94753ac4 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 @@ -27,7 +27,7 @@ export class SuggestionsService { if (this._readableRedactionsService.active) { if (this._userPreferenceService.getDisplaySuggestionsInPreview()) { const suggestionsRemove = annotations.filter( - a => bool(a.getCustomData('suggestionRemove')) || bool(a.getCustomData('suggestionRecategorizeImage')), + a => bool(a.getCustomData('suggestionRemove')) || bool(a.getCustomData('suggestionForceHint')), ); this._annotationManager.hide(suggestionsRemove); return; @@ -36,7 +36,7 @@ export class SuggestionsService { const suggestionsToHide = annotations.filter( a => (bool(a.getCustomData('suggestionAdd')) && !bool(a.getCustomData('suggestionAddToFalsePositive'))) || - bool(a.getCustomData('suggestionRecategorizeImage')), + bool(a.getCustomData('notSignatureImage')), ); annotations.forEach(a => { if (bool(a.getCustomData('suggestionRemove'))) { @@ -52,11 +52,11 @@ export class SuggestionsService { filterWorkloadSuggestionsInPreview(annotations: AnnotationWrapper[]): AnnotationWrapper[] { if (this._readableRedactionsService.active) { if (this._userPreferenceService.getDisplaySuggestionsInPreview()) { - return annotations.filter(a => !a.isSuggestionRemove && !a.isSuggestionRecategorizeImage); + return annotations.filter(a => !a.isSuggestionRemove && !a.isSuggestionForceHint); } } - annotations = annotations.filter(a => !a.isSuggestionAdd || a.isSuggestionAddToFalsePositive); + annotations = annotations.filter(a => (!a.isSuggestionAdd || a.isSuggestionAddToFalsePositive) && !a.isNotSignatureImage); for (let i = annotations.length - 1; i >= 0; i--) { const foundRemovedRedaction = this.#removedRedactions.find(r => r.id === annotations[i].id); if (foundRemovedRedaction) { diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts index 7211bbf13..b1f388abb 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts @@ -160,14 +160,21 @@ export class AnnotationDrawService { annotation.setCustomData('suggestionAddToFalsePositive', String(annotationWrapper.isSuggestionAddToFalsePositive)); annotation.setCustomData('suggestionRemove', String(annotationWrapper.isSuggestionRemove)); annotation.setCustomData('suggestionRecategorizeImage', String(annotationWrapper.isSuggestionRecategorizeImage)); + annotation.setCustomData('suggestionForceHint', String(annotationWrapper.isSuggestionForceHint)); annotation.setCustomData('skipped', String(annotationWrapper.isSkipped)); + annotation.setCustomData('notSignatureImage', String(annotationWrapper.isNotSignatureImage)); annotation.setCustomData('changeLog', String(annotationWrapper.isChangeLogEntry)); annotation.setCustomData('changeLogRemoved', String(annotationWrapper.isChangeLogRemoved)); annotation.setCustomData('opacity', String(annotation.Opacity)); + const dictionaryRequestColor = + annotationWrapper.isSuggestionAddDictionary || (annotationWrapper.isSuggestionResize && annotationWrapper.isModifyDictionary); + const redactionColor = annotationWrapper.isSuggestion && this._userPreferenceService.getDisplaySuggestionsInPreview() - ? this._defaultColorsService.getColor(dossierTemplateId, 'requestAddColor') + ? dictionaryRequestColor + ? this._defaultColorsService.getColor(dossierTemplateId, 'dictionaryRequestColor') + : this._defaultColorsService.getColor(dossierTemplateId, 'requestAddColor') : this._defaultColorsService.getColor(dossierTemplateId, 'previewColor'); annotation.setCustomData('redactionColor', String(redactionColor)); annotation.setCustomData('annotationColor', String(annotationWrapper.color));