From 0e1f47c55fae12712cf1bc5785c53414d853df87 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 6 Feb 2023 11:27:38 +0200 Subject: [PATCH] RED-5912 - Suggestions make redactions disappear in PREVIEW mode --- .../services/file-data.service.ts | 7 +---- .../services/suggestions.service.ts | 27 ++++++++++++++----- 2 files changed, 21 insertions(+), 13 deletions(-) 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 4f803c7e3..0841d0ba5 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 @@ -204,8 +204,7 @@ export class FileDataService extends EntitiesService { const lastChange = entry.manualChanges.at(-1); - const isRemoveChange = this.#isRemoveChange(lastChange?.manualRedactionType); - if (isRemoveChange) { + if (lastChange?.annotationStatus === LogEntryStatuses.REQUESTED) { entry.manualChanges.pop(); filtered.push(entry); } @@ -215,10 +214,6 @@ export class FileDataService extends EntitiesService bool(a.getCustomData('suggestion'))); this._annotationManager.hide(suggestions); - this.#convertRemoveSuggestionsToRedactions(suggestions); + this.#convertSuggestionsToRedactions(suggestions); } } @@ -39,11 +39,24 @@ export class SuggestionsService { return annotations; } - #convertRemoveSuggestionsToRedactions(suggestions: Annotation[]): void { - const removeSuggestions = suggestions.filter(a => bool(a.getCustomData('suggestionRemove'))); - removeSuggestions.forEach(s => s.setCustomData('suggestion', 'false')); - this._readableRedactionsService.setPreviewAnnotationsOpacity(removeSuggestions); - this._readableRedactionsService.setPreviewAnnotationsColor(removeSuggestions); - this._annotationManager.show(removeSuggestions); + #convertSuggestionsToRedactions(suggestions: Annotation[]): void { + suggestions = this.#filterSuggestions(suggestions); + suggestions.forEach(s => s.setCustomData('suggestion', 'false')); + this._readableRedactionsService.setPreviewAnnotationsOpacity(suggestions); + this._readableRedactionsService.setPreviewAnnotationsColor(suggestions); + this._annotationManager.show(suggestions); + } + + #filterSuggestions(suggestions: Annotation[]): Annotation[] { + const filteredSuggestions = []; + + this.#removedRedactions.forEach(r => { + const found = suggestions.find(s => s.Id === r.annotationId); + if (found) { + filteredSuggestions.push(found); + } + }); + + return filteredSuggestions; } }