RED-7980 - removed polyline annotation and displayed pending annotations as before, but with 50% opacity

This commit is contained in:
Valentin Mihai 2024-03-11 15:43:18 +02:00
parent bc704dc7c2
commit 0c0557050b
5 changed files with 19 additions and 53 deletions

View File

@ -273,9 +273,7 @@ export class AnnotationWrapper implements IListable {
annotationWrapper.lastManualChange = lastRelevantManualChange?.manualRedactionType;
annotationWrapper.pending = logEntry.state === EntryStates.PENDING;
if (annotationWrapper.pending) {
const removedEntry = allLogEntries.find(
(e: IEntityLogEntry) => e.id === annotationWrapper.id && e.state === EntryStates.REMOVED,
);
const removedEntry = allLogEntries.find((e: IEntityLogEntry) => e.id === annotationWrapper.id);
logEntry.oldState = removedEntry?.state;
}
annotationWrapper.superType = SuperTypeMapper[logEntry.entryType][logEntry.state](logEntry);
@ -286,13 +284,14 @@ export class AnnotationWrapper implements IListable {
annotationWrapper.typeLabel = dictionary?.virtual ? undefined : dictionary?.label;
if (annotationWrapper.pending) {
annotationWrapper.color = defaultColors[annotationDefaultColorConfig.analysis] as string;
} else {
const colorKey = annotationEntityColorConfig[annotationWrapper.superType];
const defaultColor = annotationDefaultColorConfig[annotationWrapper.superType];
annotationWrapper.color = dictionary ? (dictionary[colorKey] as string) : (defaultColors[defaultColor] as string);
let colorKey = annotationEntityColorConfig[annotationWrapper.superType];
if (annotationWrapper.pending && lastRelevantManualChange.manualRedactionType === ManualRedactionTypes.REMOVE_FROM_DICTIONARY) {
colorKey = annotationWrapper.isHint
? annotationEntityColorConfig[SuperTypes.IgnoredHint]
: annotationEntityColorConfig[SuperTypes.Skipped];
}
const defaultColor = annotationDefaultColorConfig[annotationWrapper.superType];
annotationWrapper.color = dictionary ? (dictionary[colorKey] as string) : (defaultColors[defaultColor] as string);
annotationWrapper['entry'] = logEntry;
return annotationWrapper;

View File

@ -178,7 +178,7 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
async #convertData(entityLog: IEntityLog) {
const file = this._state.file();
const annotations: AnnotationWrapper[] = [];
let annotations: AnnotationWrapper[] = [];
const defaultColors = this._defaultColorsService.find(this._state.dossierTemplateId);
let dictionaries = this._state.dictionaries;
let checkDictionary = true;
@ -237,6 +237,12 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
defaultColors,
);
if (annotation.pending) {
const oldAnnotationIndex = annotations.findIndex(a => a.id === annotation.id && !a.pending);
annotations[oldAnnotationIndex] = annotation;
continue;
}
annotations.push(annotation);
}

View File

@ -11,7 +11,6 @@ import { REDDocumentViewer } from './document-viewer.service';
import { PdfViewer } from './pdf-viewer.service';
import Annotation = Core.Annotations.Annotation;
import Quad = Core.Math.Quad;
import PolylineAnnotation = Core.Annotations.PolylineAnnotation;
const DEFAULT_TEXT_ANNOTATION_OPACITY = 1;
const DEFAULT_REMOVED_ANNOTATION_OPACITY = 0.2;
@ -129,24 +128,6 @@ export class AnnotationDrawService {
return;
}
if (annotationWrapper.pending) {
const polylineAnnot = this._pdf.polyline();
polylineAnnot.ReadOnly = true;
polylineAnnot.StrokeColor = this.convertColor(annotationWrapper.color);
polylineAnnot.StrokeThickness = 4;
polylineAnnot.Id = annotationWrapper.id;
polylineAnnot.PageNumber = pageNumber;
polylineAnnot.Opacity = 0.5;
const points = this.#computePolylinePoints(annotationWrapper.positions, annotationWrapper.pageNumber);
for (let i = 0; i < points.length; i++) {
const y = i % 2 === 1 ? points[i - 1].y : points[i].y;
polylineAnnot.addPathPoint(points[i].x, y);
}
return polylineAnnot;
}
if (annotationWrapper.superType === SuperTypes.TextHighlight) {
const rectangleAnnot = this._pdf.rectangle();
const pageHeight = this._documentViewer.getHeight(pageNumber);
@ -186,7 +167,7 @@ export class AnnotationDrawService {
annotation.setCustomData('skipped', String(annotationWrapper.isSkipped));
annotation.setCustomData('changeLog', String(annotationWrapper.isChangeLogEntry));
annotation.setCustomData('changeLogRemoved', String(annotationWrapper.isRemoved));
annotation.setCustomData('opacity', String(annotation.Opacity));
annotation.setCustomData('opacity', String(!annotationWrapper.pending ? annotation.Opacity : annotation.Opacity / 2));
const redactionColor = this._defaultColorsService.getColor(dossierTemplateId, 'previewColor');
annotation.setCustomData('redactionColor', String(redactionColor));
@ -211,24 +192,6 @@ export class AnnotationDrawService {
return this._pdf.quad(x1, y1, x2, y2, x3, y3, x4, y4);
}
#computePolylinePoints(positions: IRectangle[], pageNumber: number): IPoint[] {
const pageHeight = this._documentViewer.getHeight(pageNumber);
const points = [this.#topLeft(positions[0], pageHeight)];
for (let i = 0; i < positions.length; i++) {
points.push(this.#topRight(positions[i], pageHeight));
points.push(this.#bottomRight(positions[i], pageHeight));
}
for (let i = positions.length - 1; i >= 0; i--) {
points.push(this.#bottomLeft(positions[i], pageHeight));
points.push(this.#topLeft(positions[i], pageHeight));
}
points.push(this.#topRight(positions[0], pageHeight));
return points;
}
#topLeft(rectangle: IRectangle, pageHeight: number): IPoint {
const x = rectangle.topLeft.x;
const y = pageHeight - (rectangle.topLeft.y + rectangle.height);

View File

@ -243,10 +243,6 @@ export class PdfViewer {
return new this.#instance.Core.Annotations.TextHighlightAnnotation();
}
polyline() {
return new this.#instance.Core.Annotations.PolylineAnnotation();
}
isTextHighlight(annotation: Annotation): annotation is TextHighlightAnnotation {
return annotation instanceof this.#instance.Core.Annotations.TextHighlightAnnotation;
}

View File

@ -20,7 +20,9 @@ function wrongSuperTypeHandler(): never | undefined {
function resolveRedactionType(entry: IEntityLogEntry, hint = false) {
if (entry.state === EntryStates.PENDING && entry.oldState) {
return SuperTypeMapper[entry.entryType][entry.oldState](entry);
const oldState = entry.oldState;
delete entry.oldState;
return SuperTypeMapper[entry.entryType][oldState](entry);
}
const redaction = hint ? SuperTypes.Hint : SuperTypes.Redaction;