RED-5912 - Suggestions make redactions disappear in PREVIEW mode

This commit is contained in:
Valentin Mihai 2023-02-06 11:27:38 +02:00
parent 42ae67b2ea
commit 0e1f47c55f
2 changed files with 21 additions and 13 deletions

View File

@ -204,8 +204,7 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
const redactionLogCopy = JSON.parse(JSON.stringify(redactionLog));
redactionLogCopy.redactionLogEntry = redactionLogCopy.redactionLogEntry?.reduce((filtered, entry) => {
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<AnnotationWrapper, Annotati
}
}
#isRemoveChange(type: ManualRedactionType) {
return type === 'REMOVE_LOCALLY' || type === 'REMOVE_FROM_DICTIONARY';
}
async #convertData(redactionLog: IRedactionLog, file: File) {
const result: RedactionLogEntry[] = [];
const sourceIdAnnotationIds: { [key: string]: RedactionLogEntry[] } = {};

View File

@ -27,7 +27,7 @@ export class SuggestionsService {
if (!this._userPreferenceService.getDisplaySuggestionsInPreview()) {
const suggestions = annotations.filter(a => 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;
}
}