RED-5912 - Suggestions make redactions disappear in PREVIEW mode
This commit is contained in:
parent
1d4184be1b
commit
63595742b5
@ -363,7 +363,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
|
|
||||||
if (this._viewModeService.isRedacted) {
|
if (this._viewModeService.isRedacted) {
|
||||||
annotations = annotations.filter(a => !bool(a.isChangeLogRemoved));
|
annotations = annotations.filter(a => !bool(a.isChangeLogRemoved));
|
||||||
annotations = this._suggestionsService.convertWorkloadRemoveSuggestionsToRedactions(annotations);
|
annotations = this._suggestionsService.filterWorkloadSuggestionsInPreview(annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary);
|
this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary);
|
||||||
|
|||||||
@ -210,7 +210,8 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
|||||||
}
|
}
|
||||||
return filtered;
|
return filtered;
|
||||||
}, []);
|
}, []);
|
||||||
this._suggestionsService.removedRedactions = await this.#buildAnnotations(redactionLogCopy, file);
|
const annotations = await this.#buildAnnotations(redactionLogCopy, file);
|
||||||
|
this._suggestionsService.removedRedactions = annotations.filter(a => !a.isSkipped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,39 +24,47 @@ export class SuggestionsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hideSuggestionsInPreview(annotations: Annotation[]): void {
|
hideSuggestionsInPreview(annotations: Annotation[]): void {
|
||||||
if (!this._userPreferenceService.getDisplaySuggestionsInPreview()) {
|
if (this._readableRedactionsService.active) {
|
||||||
const suggestions = annotations.filter(a => bool(a.getCustomData('suggestion')));
|
if (this._userPreferenceService.getDisplaySuggestionsInPreview()) {
|
||||||
this._annotationManager.hide(suggestions);
|
const suggestionsRemove = annotations.filter(
|
||||||
this.#convertSuggestionsToRedactions(suggestions);
|
a => bool(a.getCustomData('suggestionRemove')) || bool(a.getCustomData('suggestionRecategorizeImage')),
|
||||||
|
);
|
||||||
|
this._annotationManager.hide(suggestionsRemove);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
const suggestionsToHide = annotations.filter(
|
||||||
|
a =>
|
||||||
|
(bool(a.getCustomData('suggestionAdd')) && !bool(a.getCustomData('suggestionAddToFalsePositive'))) ||
|
||||||
|
bool(a.getCustomData('suggestionRecategorizeImage')),
|
||||||
|
);
|
||||||
|
annotations.forEach(a => {
|
||||||
|
if (bool(a.getCustomData('suggestionRemove'))) {
|
||||||
|
const foundRedaction = this.#removedRedactions.find(r => r.id === a.Id);
|
||||||
|
if (!foundRedaction) {
|
||||||
|
suggestionsToHide.push(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this._annotationManager.hide(suggestionsToHide);
|
||||||
}
|
}
|
||||||
|
|
||||||
convertWorkloadRemoveSuggestionsToRedactions(annotations: AnnotationWrapper[]): AnnotationWrapper[] {
|
filterWorkloadSuggestionsInPreview(annotations: AnnotationWrapper[]): AnnotationWrapper[] {
|
||||||
if (!this._userPreferenceService.getDisplaySuggestionsInPreview()) {
|
if (this._readableRedactionsService.active) {
|
||||||
annotations = annotations.filter(a => !a.isSuggestion);
|
if (this._userPreferenceService.getDisplaySuggestionsInPreview()) {
|
||||||
annotations = [...annotations, ...this.#removedRedactions];
|
return annotations.filter(a => !a.isSuggestionRemove && !a.isSuggestionRecategorizeImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
annotations = annotations.filter(a => !a.isSuggestionAdd || a.isSuggestionAddToFalsePositive);
|
||||||
|
for (let i = annotations.length - 1; i >= 0; i--) {
|
||||||
|
const foundRemovedRedaction = this.#removedRedactions.find(r => r.id === annotations[i].id);
|
||||||
|
if (foundRemovedRedaction) {
|
||||||
|
annotations[i] = foundRemovedRedaction;
|
||||||
|
} else if (annotations[i].isSuggestionRemove) {
|
||||||
|
annotations.splice(i, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return annotations;
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
#convertSuggestionsToRedactions(suggestions: Annotation[]): void {
|
|
||||||
suggestions = this.#filterSuggestions(suggestions);
|
|
||||||
suggestions.forEach(s => s.setCustomData('suggestion', 'false'));
|
|
||||||
this._readableRedactionsService.setAnnotationsColor(suggestions, 'redactionColor');
|
|
||||||
this._readableRedactionsService.setAnnotationsOpacity(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,7 +156,10 @@ export class AnnotationDrawService {
|
|||||||
annotation.setCustomData('redact-manager', 'true');
|
annotation.setCustomData('redact-manager', 'true');
|
||||||
annotation.setCustomData('redaction', String(annotationWrapper.previewAnnotation));
|
annotation.setCustomData('redaction', String(annotationWrapper.previewAnnotation));
|
||||||
annotation.setCustomData('suggestion', String(annotationWrapper.isSuggestion));
|
annotation.setCustomData('suggestion', String(annotationWrapper.isSuggestion));
|
||||||
|
annotation.setCustomData('suggestionAdd', String(annotationWrapper.isSuggestionAdd));
|
||||||
|
annotation.setCustomData('suggestionAddToFalsePositive', String(annotationWrapper.isSuggestionAddToFalsePositive));
|
||||||
annotation.setCustomData('suggestionRemove', String(annotationWrapper.isSuggestionRemove));
|
annotation.setCustomData('suggestionRemove', String(annotationWrapper.isSuggestionRemove));
|
||||||
|
annotation.setCustomData('suggestionRecategorizeImage', String(annotationWrapper.isSuggestionRecategorizeImage));
|
||||||
annotation.setCustomData('skipped', String(annotationWrapper.isSkipped));
|
annotation.setCustomData('skipped', String(annotationWrapper.isSkipped));
|
||||||
annotation.setCustomData('changeLog', String(annotationWrapper.isChangeLogEntry));
|
annotation.setCustomData('changeLog', String(annotationWrapper.isChangeLogEntry));
|
||||||
annotation.setCustomData('changeLogRemoved', String(annotationWrapper.isChangeLogRemoved));
|
annotation.setCustomData('changeLogRemoved', String(annotationWrapper.isChangeLogRemoved));
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Inject, Injectable } from '@angular/core';
|
import { inject, Injectable } from '@angular/core';
|
||||||
import { BASE_HREF_FN, BaseHrefFn, bool } from '@iqser/common-ui';
|
import { BASE_HREF_FN } from '@iqser/common-ui';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
import { HeaderElements } from '../../file-preview/utils/constants';
|
import { HeaderElements } from '../../file-preview/utils/constants';
|
||||||
@ -13,12 +13,12 @@ import Annotation = Core.Annotations.Annotation;
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ReadableRedactionsService {
|
export class ReadableRedactionsService {
|
||||||
readonly active$: Observable<boolean>;
|
readonly active$: Observable<boolean>;
|
||||||
|
private readonly _convertPath = inject(BASE_HREF_FN);
|
||||||
readonly #enableIcon = this._convertPath('/assets/icons/general/redaction-preview.svg');
|
readonly #enableIcon = this._convertPath('/assets/icons/general/redaction-preview.svg');
|
||||||
readonly #disableIcon = this._convertPath('/assets/icons/general/redaction-final.svg');
|
readonly #disableIcon = this._convertPath('/assets/icons/general/redaction-final.svg');
|
||||||
readonly #active$ = new BehaviorSubject<boolean>(true);
|
readonly #active$ = new BehaviorSubject<boolean>(true);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(BASE_HREF_FN) private readonly _convertPath: BaseHrefFn,
|
|
||||||
private readonly _pdf: PdfViewer,
|
private readonly _pdf: PdfViewer,
|
||||||
private readonly _translateService: TranslateService,
|
private readonly _translateService: TranslateService,
|
||||||
private readonly _annotationManager: REDAnnotationManager,
|
private readonly _annotationManager: REDAnnotationManager,
|
||||||
@ -79,7 +79,8 @@ export class ReadableRedactionsService {
|
|||||||
|
|
||||||
setAnnotationsOpacity(annotations: Annotation[], restoreToOriginal = false) {
|
setAnnotationsOpacity(annotations: Annotation[], restoreToOriginal = false) {
|
||||||
annotations.forEach(annotation => {
|
annotations.forEach(annotation => {
|
||||||
annotation['Opacity'] = restoreToOriginal ? parseFloat(annotation.getCustomData('opacity')) : 0.5;
|
const isSuggestion = annotation.getCustomData('suggestion');
|
||||||
|
annotation['Opacity'] = restoreToOriginal || isSuggestion ? parseFloat(annotation.getCustomData('opacity')) : 0.5;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user