RED-6240 - WIP on applying redaction color as in final document without opacity
This commit is contained in:
parent
5bd1fae73f
commit
6c4ede5ad6
@ -243,8 +243,10 @@ export class FilePreviewScreenComponent
|
||||
const nonRedactionEntries = annotations.filter(
|
||||
a => !bool(a.getCustomData('redaction')) || bool(a.getCustomData('changeLogRemoved')),
|
||||
);
|
||||
this._readableRedactionsService.setPreviewAnnotationsOpacity(redactions);
|
||||
this._readableRedactionsService.setPreviewAnnotationsColor(redactions);
|
||||
if (this._readableRedactionsService.active) {
|
||||
this._readableRedactionsService.setAnnotationsColor(redactions, 'redactionColor');
|
||||
this._readableRedactionsService.setAnnotationsOpacity(redactions);
|
||||
}
|
||||
this._annotationManager.show(redactions);
|
||||
this._annotationManager.hide(nonRedactionEntries);
|
||||
this._suggestionsService.hideSuggestionsInPreview(redactions);
|
||||
@ -698,6 +700,11 @@ export class FilePreviewScreenComponent
|
||||
? this._viewerHeaderService.enableRotationButtons()
|
||||
: this._viewerHeaderService.disableRotationButtons(),
|
||||
),
|
||||
tap(viewMode =>
|
||||
viewMode === 'REDACTED' && !this._readableRedactionsService.active
|
||||
? this._readableRedactionsService.setCustomDrawHandler()
|
||||
: this._readableRedactionsService.restoreDraw(),
|
||||
),
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
@ -42,8 +42,8 @@ export class SuggestionsService {
|
||||
#convertSuggestionsToRedactions(suggestions: Annotation[]): void {
|
||||
suggestions = this.#filterSuggestions(suggestions);
|
||||
suggestions.forEach(s => s.setCustomData('suggestion', 'false'));
|
||||
this._readableRedactionsService.setPreviewAnnotationsOpacity(suggestions);
|
||||
this._readableRedactionsService.setPreviewAnnotationsColor(suggestions);
|
||||
this._readableRedactionsService.setAnnotationsColor(suggestions, 'redactionColor');
|
||||
this._readableRedactionsService.setAnnotationsOpacity(suggestions);
|
||||
this._annotationManager.show(suggestions);
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@ import Quad = Core.Math.Quad;
|
||||
|
||||
const DEFAULT_TEXT_ANNOTATION_OPACITY = 1;
|
||||
const DEFAULT_REMOVED_ANNOTATION_OPACITY = 0.2;
|
||||
const FINAL_REDACTION_COLOR = '#000000';
|
||||
|
||||
@Injectable()
|
||||
export class AnnotationDrawService {
|
||||
@ -165,7 +164,6 @@ export class AnnotationDrawService {
|
||||
? this._defaultColorsService.getColor(dossierTemplateId, 'requestAddColor')
|
||||
: this._defaultColorsService.getColor(dossierTemplateId, 'previewColor');
|
||||
annotation.setCustomData('redactionColor', String(redactionColor));
|
||||
annotation.setCustomData('finalRedactionColor', FINAL_REDACTION_COLOR);
|
||||
annotation.setCustomData('annotationColor', String(annotationWrapper.color));
|
||||
|
||||
return annotation;
|
||||
|
||||
@ -48,6 +48,36 @@ export class ReadableRedactionsService {
|
||||
title: this.toggleReadableRedactionsBtnTitle,
|
||||
img: this.toggleReadableRedactionsBtnIcon,
|
||||
});
|
||||
|
||||
if (!this.active) {
|
||||
this.setCustomDrawHandler();
|
||||
} else {
|
||||
this.restoreDraw();
|
||||
}
|
||||
}
|
||||
|
||||
setCustomDrawHandler(): void {
|
||||
const annotationClass: any = this._pdf.instance.Core.Annotations.TextHighlightAnnotation;
|
||||
this._pdf.instance.Core.Annotations.setCustomDrawHandler(
|
||||
annotationClass,
|
||||
(ctx: CanvasRenderingContext2D, pageMatrix, rotation, options) => {
|
||||
const annotation = options.annotation;
|
||||
ctx.globalCompositeOperation = 'source-over';
|
||||
|
||||
(options.annotation as any).Quads.forEach(q => {
|
||||
const yMin = Math.min(q.y1, q.y2, q.y3, q.y4);
|
||||
const height = Math.sqrt(Math.pow(q.x1 - q.x4, 2) + Math.pow(q.y1 - q.y4, 2));
|
||||
const width = Math.sqrt(Math.pow(q.x1 - q.x2, 2) + Math.pow(q.y1 - q.y2, 2));
|
||||
ctx.fillStyle = annotation.getCustomData('redactionColor');
|
||||
ctx.fillRect(q.x1, yMin, width, height);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
restoreDraw(): void {
|
||||
const annotationClass: any = this._pdf.instance.Core.Annotations.TextHighlightAnnotation;
|
||||
this._pdf.instance.Core.Annotations.restoreDraw(annotationClass);
|
||||
}
|
||||
|
||||
setAnnotationsOpacity(annotations: Annotation[], restoreToOriginal = false) {
|
||||
@ -63,20 +93,4 @@ export class ReadableRedactionsService {
|
||||
annotation['FillColor'] = color;
|
||||
});
|
||||
}
|
||||
|
||||
setPreviewAnnotationsOpacity(annotations: Annotation[]) {
|
||||
annotations.forEach(annotation => {
|
||||
const isSuggestion = bool(annotation.getCustomData('suggestion'));
|
||||
const restoreToOriginal = !this.active && !isSuggestion;
|
||||
this.setAnnotationsOpacity([annotation], restoreToOriginal);
|
||||
});
|
||||
}
|
||||
|
||||
setPreviewAnnotationsColor(annotations: Annotation[]) {
|
||||
annotations.forEach(annotation => {
|
||||
const isSuggestion = bool(annotation.getCustomData('suggestion'));
|
||||
const color = this.active || isSuggestion ? 'redactionColor' : 'finalRedactionColor';
|
||||
this.setAnnotationsColor([annotation], color);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,19 +89,6 @@ export class NotificationsService extends EntitiesService<INotification, Notific
|
||||
return true;
|
||||
}
|
||||
|
||||
console.log('------------------------------------------------------------------------------');
|
||||
console.log('id: ', n.id);
|
||||
console.log('today date: ', todayDate);
|
||||
console.log('read date: ', readDate);
|
||||
console.log('diff in minutes: ', todayDate.diff(readDate, 'minute'));
|
||||
console.log(
|
||||
'should be shown: ',
|
||||
todayDate.diff(readDate, 'minute') <=
|
||||
(this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES ?? AVAILABLE_OLD_NOTIFICATIONS_MINUTES),
|
||||
);
|
||||
console.log('CONFIG AVAILABLE_OLD_NOTIFICATIONS_MINUTES: ', this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES);
|
||||
console.log('DEFAULT AVAILABLE_OLD_NOTIFICATIONS_MINUTES: ', AVAILABLE_OLD_NOTIFICATIONS_MINUTES);
|
||||
|
||||
return (
|
||||
todayDate.diff(readDate, 'minute') <=
|
||||
(this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES ?? AVAILABLE_OLD_NOTIFICATIONS_MINUTES)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user