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