RED-5399 - Toggle in preview: Make redactions (un)readable

This commit is contained in:
Valentin Mihai 2022-12-21 15:54:43 +02:00
parent f7062d2d73
commit 9cf802afe8
2 changed files with 14 additions and 6 deletions

View File

@ -41,6 +41,7 @@ export class SuggestionsService {
#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);

View File

@ -1,5 +1,5 @@
import { Inject, Injectable } from '@angular/core';
import { BASE_HREF_FN, BaseHrefFn } from '@iqser/common-ui';
import { BASE_HREF_FN, BaseHrefFn, bool } from '@iqser/common-ui';
import { TranslateService } from '@ngx-translate/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { HeaderElements } from '../../file-preview/utils/constants';
@ -13,8 +13,8 @@ import Annotation = Core.Annotations.Annotation;
@Injectable()
export class ReadableRedactionsService {
readonly active$: Observable<boolean>;
readonly #enableIcon = this._convertPath('/assets/icons/general/pdftron-action-enable-tooltips.svg');
readonly #disableIcon = this._convertPath('/assets/icons/general/pdftron-action-disable-tooltips.svg');
readonly #enableIcon = this._convertPath('/assets/icons/general/pdftron-action-disable-tooltips.svg');
readonly #disableIcon = this._convertPath('/assets/icons/general/pdftron-action-enable-tooltips.svg');
readonly #active$ = new BehaviorSubject<boolean>(true);
constructor(
@ -65,11 +65,18 @@ export class ReadableRedactionsService {
}
setPreviewAnnotationsOpacity(annotations: Annotation[]) {
this.setAnnotationsOpacity(annotations, !this.active);
annotations.forEach(annotation => {
const isSuggestion = bool(annotation.getCustomData('suggestion'));
const restoreToOriginal = !this.active && !isSuggestion;
this.setAnnotationsOpacity([annotation], restoreToOriginal);
});
}
setPreviewAnnotationsColor(annotations: Annotation[]) {
const color = this.active ? 'redactionColor' : 'finalRedactionColor';
this.setAnnotationsColor(annotations, color);
annotations.forEach(annotation => {
const isSuggestion = bool(annotation.getCustomData('suggestion'));
const color = this.active || isSuggestion ? 'redactionColor' : 'finalRedactionColor';
this.setAnnotationsColor([annotation], color);
});
}
}