manual annotationd drawing
This commit is contained in:
parent
912fa000ff
commit
f3e7ed6b3b
@ -107,7 +107,7 @@
|
|||||||
<redaction-annotation-actions
|
<redaction-annotation-actions
|
||||||
[annotation]="annotation"
|
[annotation]="annotation"
|
||||||
[canPerformAnnotationActions]="canPerformAnnotationActions"
|
[canPerformAnnotationActions]="canPerformAnnotationActions"
|
||||||
(annotationsChanged)="annotationsChangedByReviewAction()"
|
(annotationsChanged)="annotationsChangedByReviewAction(annotation)"
|
||||||
></redaction-annotation-actions>
|
></redaction-annotation-actions>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -367,28 +367,23 @@ export class FilePreviewScreenComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _cleanupAndRedrawManualAnnotations() {
|
private _cleanupAndRedrawManualAnnotations(singleAnnotation: AnnotationWrapper) {
|
||||||
this._fileDownloadService.loadActiveFileManualAnnotations().subscribe((manualRedactions) => {
|
this._fileDownloadService.loadActiveFileManualAnnotations().subscribe((manualRedactions) => {
|
||||||
const annotationsToRemove = [];
|
|
||||||
const previouslyDrawnAnnotations = this.annotations.filter((a) => a.shouldDraw);
|
|
||||||
previouslyDrawnAnnotations.forEach((annotationWrapper) => {
|
|
||||||
const annotation = this.activeViewer.annotManager.getAnnotationById(annotationWrapper.id);
|
|
||||||
if (annotation) {
|
|
||||||
annotationsToRemove.push(annotation);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.activeViewer.annotManager.deleteAnnotations(annotationsToRemove, false, true);
|
|
||||||
this.fileData.manualRedactions = manualRedactions;
|
this.fileData.manualRedactions = manualRedactions;
|
||||||
this._rebuildFilters();
|
this._rebuildFilters();
|
||||||
this._annotationDrawService.drawAnnotations(
|
this._annotationDrawService.drawAnnotations(
|
||||||
this.instance,
|
this.instance,
|
||||||
this.annotations.filter((a) => a.shouldDraw)
|
this.annotations.filter((item) => (singleAnnotation ? singleAnnotation.id === item.id && singleAnnotation.shouldDraw : item.shouldDraw))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
annotationsChangedByReviewAction() {
|
annotationsChangedByReviewAction(annotation: AnnotationWrapper) {
|
||||||
this._cleanupAndRedrawManualAnnotations();
|
const viewerAnnotation = this.activeViewer.annotManager.getAnnotationById(annotation.id);
|
||||||
|
if (viewerAnnotation) {
|
||||||
|
this.activeViewer.annotManager.deleteAnnotation(viewerAnnotation, true, true);
|
||||||
|
}
|
||||||
|
this._cleanupAndRedrawManualAnnotations(annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fileActionPerformed(action: string) {
|
async fileActionPerformed(action: string) {
|
||||||
@ -406,6 +401,4 @@ export class FilePreviewScreenComponent implements OnInit {
|
|||||||
this.canPerformAnnotationActions = this.permissionsService.canPerformAnnotationActions();
|
this.canPerformAnnotationActions = this.permissionsService.canPerformAnnotationActions();
|
||||||
await this.appStateService.reloadActiveProjectFiles();
|
await this.appStateService.reloadActiveProjectFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
// allManualRedactionsApplied
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,8 +41,15 @@ export class AnnotationWrapper {
|
|||||||
const annotationWrapper = new AnnotationWrapper();
|
const annotationWrapper = new AnnotationWrapper();
|
||||||
|
|
||||||
annotationWrapper.comments = comments ? comments : [];
|
annotationWrapper.comments = comments ? comments : [];
|
||||||
|
annotationWrapper.shouldDraw = true;
|
||||||
if (redactionLogEntry) {
|
if (redactionLogEntry) {
|
||||||
|
if (redactionLogEntry.manual) {
|
||||||
|
if (!manualRedactionEntry && redactionLogEntry.manualRedactionType === 'ADD') {
|
||||||
|
// do not draw if it is no longer in the manual redactions
|
||||||
|
annotationWrapper.shouldDraw = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
annotationWrapper.id = redactionLogEntry.id;
|
annotationWrapper.id = redactionLogEntry.id;
|
||||||
annotationWrapper.redaction = redactionLogEntry.redacted;
|
annotationWrapper.redaction = redactionLogEntry.redacted;
|
||||||
annotationWrapper.hint = redactionLogEntry.hint;
|
annotationWrapper.hint = redactionLogEntry.hint;
|
||||||
@ -52,30 +59,10 @@ export class AnnotationWrapper {
|
|||||||
annotationWrapper.positions = redactionLogEntry.positions;
|
annotationWrapper.positions = redactionLogEntry.positions;
|
||||||
annotationWrapper.content = AnnotationWrapper.createContentForRedactionLog(redactionLogEntry);
|
annotationWrapper.content = AnnotationWrapper.createContentForRedactionLog(redactionLogEntry);
|
||||||
// either marked as manual or idRemove or manualRedactionEntry exists
|
// either marked as manual or idRemove or manualRedactionEntry exists
|
||||||
annotationWrapper.manual = redactionLogEntry.manual || !!manualRedactionEntry || !!idRemoval;
|
annotationWrapper.manual = redactionLogEntry.manual;
|
||||||
|
annotationWrapper.canUndo = manualRedactionEntry?.user === user.id || idRemoval?.user === user.id;
|
||||||
annotationWrapper.modifyDictionary = !!manualRedactionEntry?.addToDictionary || !!idRemoval?.removeFromDictionary;
|
annotationWrapper.modifyDictionary = !!manualRedactionEntry?.addToDictionary || !!idRemoval?.removeFromDictionary;
|
||||||
switch (redactionLogEntry.status) {
|
AnnotationWrapper._setSuperType(annotationWrapper, redactionLogEntry, manualRedactionEntry, idRemoval);
|
||||||
case 'REQUESTED':
|
|
||||||
annotationWrapper.superType = idRemoval?.status === 'REQUESTED' || idRemoval?.status === 'APPROVED' ? 'suggestion-remove' : 'suggestion';
|
|
||||||
break;
|
|
||||||
case 'APPROVED':
|
|
||||||
annotationWrapper.superType = annotationWrapper.redaction ? 'redaction' : annotationWrapper.hint ? 'hint' : 'ignore';
|
|
||||||
break;
|
|
||||||
case 'DECLINED':
|
|
||||||
// TODO check this
|
|
||||||
annotationWrapper.superType = 'ignore';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
annotationWrapper.superType =
|
|
||||||
idRemoval?.status === 'REQUESTED' || idRemoval?.status === 'APPROVED'
|
|
||||||
? 'suggestion-remove'
|
|
||||||
: annotationWrapper.redaction
|
|
||||||
? 'redaction'
|
|
||||||
: annotationWrapper.hint
|
|
||||||
? 'hint'
|
|
||||||
: 'ignore';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const dictionary = dictionaryData[manualRedactionEntry.type];
|
const dictionary = dictionaryData[manualRedactionEntry.type];
|
||||||
annotationWrapper.id = manualRedactionEntry.id;
|
annotationWrapper.id = manualRedactionEntry.id;
|
||||||
@ -90,30 +77,8 @@ export class AnnotationWrapper {
|
|||||||
annotationWrapper.comments = comments[manualRedactionEntry.id] ? comments[manualRedactionEntry.id] : [];
|
annotationWrapper.comments = comments[manualRedactionEntry.id] ? comments[manualRedactionEntry.id] : [];
|
||||||
annotationWrapper.userId = manualRedactionEntry.user;
|
annotationWrapper.userId = manualRedactionEntry.user;
|
||||||
annotationWrapper.canUndo = manualRedactionEntry?.user === user.id;
|
annotationWrapper.canUndo = manualRedactionEntry?.user === user.id;
|
||||||
annotationWrapper.shouldDraw = AnnotationWrapper._shouldDraw(manualRedactionEntry, fileStatus);
|
|
||||||
annotationWrapper.modifyDictionary = manualRedactionEntry.addToDictionary;
|
annotationWrapper.modifyDictionary = manualRedactionEntry.addToDictionary;
|
||||||
switch (manualRedactionEntry.status) {
|
AnnotationWrapper._setSuperType(annotationWrapper, redactionLogEntry, manualRedactionEntry, idRemoval);
|
||||||
case 'REQUESTED':
|
|
||||||
annotationWrapper.superType = idRemoval?.status === 'REQUESTED' || idRemoval?.status === 'APPROVED' ? 'suggestion-remove' : 'suggestion';
|
|
||||||
break;
|
|
||||||
case 'APPROVED':
|
|
||||||
annotationWrapper.superType = redactionLogEntry.redacted ? 'redaction' : redactionLogEntry.hint ? 'hint' : 'ignore';
|
|
||||||
break;
|
|
||||||
case 'DECLINED':
|
|
||||||
// TODO check this
|
|
||||||
annotationWrapper.superType = 'ignore';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
annotationWrapper.superType =
|
|
||||||
idRemoval?.status === 'REQUESTED' || idRemoval?.status === 'APPROVED'
|
|
||||||
? 'suggestion-remove'
|
|
||||||
: annotationWrapper.redaction
|
|
||||||
? 'redaction'
|
|
||||||
: annotationWrapper.hint
|
|
||||||
? 'hint'
|
|
||||||
: 'ignore';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnotationWrapper._setTypeLabel(annotationWrapper);
|
AnnotationWrapper._setTypeLabel(annotationWrapper);
|
||||||
@ -121,14 +86,31 @@ export class AnnotationWrapper {
|
|||||||
return annotationWrapper;
|
return annotationWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _shouldDraw(manualRedaction: ManualRedactionEntry, fileStatus: FileStatus): boolean {
|
private static _setSuperType(
|
||||||
const isRequested =
|
annotationWrapper: AnnotationWrapper,
|
||||||
manualRedaction.status === 'REQUESTED' && new Date(manualRedaction.requestDate).getTime() > new Date(fileStatus.lastProcessed).getTime();
|
redactionLogEntry?: RedactionLogEntry,
|
||||||
const isApprovedOrDeclined =
|
manualRedactionEntry?: ManualRedactionEntry,
|
||||||
(manualRedaction.status === 'APPROVED' || manualRedaction.status === 'DECLINED') &&
|
idRemoval?: IdRemoval
|
||||||
new Date(manualRedaction.requestDate).getTime() > new Date(fileStatus.lastProcessed).getTime();
|
) {
|
||||||
|
if (idRemoval) {
|
||||||
return isRequested || isApprovedOrDeclined;
|
if (idRemoval.status === 'REQUESTED') {
|
||||||
|
annotationWrapper.superType = 'suggestion-remove';
|
||||||
|
}
|
||||||
|
if (idRemoval.status === 'APPROVED') {
|
||||||
|
annotationWrapper.superType = 'ignore';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (manualRedactionEntry) {
|
||||||
|
if (manualRedactionEntry.status === 'REQUESTED') {
|
||||||
|
annotationWrapper.superType = 'suggestion';
|
||||||
|
}
|
||||||
|
if (manualRedactionEntry.status === 'APPROVED') {
|
||||||
|
annotationWrapper.superType = annotationWrapper.redaction ? 'redaction' : annotationWrapper.hint ? 'hint' : 'ignore';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!annotationWrapper.superType) {
|
||||||
|
annotationWrapper.superType = annotationWrapper.redaction ? 'redaction' : annotationWrapper.hint ? 'hint' : 'ignore';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _setTypeLabel(annotationWrapper: AnnotationWrapper) {
|
private static _setTypeLabel(annotationWrapper: AnnotationWrapper) {
|
||||||
|
|||||||
@ -39,7 +39,9 @@ export class FileDataModel {
|
|||||||
pair.idRemoval,
|
pair.idRemoval,
|
||||||
pair.comments
|
pair.comments
|
||||||
);
|
);
|
||||||
annotations.push(annotation);
|
if (annotation) {
|
||||||
|
annotations.push(annotation);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return annotations;
|
return annotations;
|
||||||
|
|||||||
@ -46,10 +46,7 @@ export class AnnotationProcessingService {
|
|||||||
return filters.sort((a, b) => SuperTypeSorter[a.key] - SuperTypeSorter[b.key]);
|
return filters.sort((a, b) => SuperTypeSorter[a.key] - SuperTypeSorter[b.key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterAndGroupAnnotations(
|
filterAndGroupAnnotations(annotations: AnnotationWrapper[], filters: FilterModel[]): { [key: number]: { annotations: AnnotationWrapper[] } } {
|
||||||
annotations: AnnotationWrapper[],
|
|
||||||
filters: FilterModel[]
|
|
||||||
): { [key: number]: { annotations: AnnotationWrapper[] } } {
|
|
||||||
const obj = {};
|
const obj = {};
|
||||||
|
|
||||||
const hasActiveFilters = this._hasActiveFilters(filters);
|
const hasActiveFilters = this._hasActiveFilters(filters);
|
||||||
@ -68,9 +65,7 @@ export class AnnotationProcessingService {
|
|||||||
for (const filter of flatFilters) {
|
for (const filter of flatFilters) {
|
||||||
if (
|
if (
|
||||||
filter.checked &&
|
filter.checked &&
|
||||||
((filter.key === annotation.dictionary &&
|
((filter.key === annotation.dictionary && (annotation.superType === 'hint' || annotation.superType === 'redaction')) ||
|
||||||
(annotation.superType === 'hint' ||
|
|
||||||
annotation.superType === 'redaction')) ||
|
|
||||||
filter.key === annotation.superType)
|
filter.key === annotation.superType)
|
||||||
) {
|
) {
|
||||||
found = true;
|
found = true;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export class FileDownloadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public loadActiveFileData(): Observable<FileDataModel> {
|
public loadActiveFileData(): Observable<FileDataModel> {
|
||||||
const annotatedObs = this.loadFile('ANNOTATED', this._appStateService.activeFileId);
|
const annotatedObs = this.loadFile('ORIGINAL', this._appStateService.activeFileId);
|
||||||
const redactedObs = this.loadFile('REDACTED', this._appStateService.activeFileId);
|
const redactedObs = this.loadFile('REDACTED', this._appStateService.activeFileId);
|
||||||
const reactionLogObs = this._redactionLogControllerService.getRedactionLog(this._appStateService.activeFileId);
|
const reactionLogObs = this._redactionLogControllerService.getRedactionLog(this._appStateService.activeFileId);
|
||||||
const manualRedactionsObs = this._manualRedactionControllerService.getManualRedaction(
|
const manualRedactionsObs = this._manualRedactionControllerService.getManualRedaction(
|
||||||
|
|||||||
@ -20,6 +20,7 @@ export interface RedactionLogEntry {
|
|||||||
positions?: Array<Rectangle>;
|
positions?: Array<Rectangle>;
|
||||||
reason?: string;
|
reason?: string;
|
||||||
redacted?: boolean;
|
redacted?: boolean;
|
||||||
|
manualRedactionType?: string;
|
||||||
section?: string;
|
section?: string;
|
||||||
sectionNumber?: number;
|
sectionNumber?: number;
|
||||||
status?: RedactionLogEntry.StatusEnum;
|
status?: RedactionLogEntry.StatusEnum;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user