From abbf8fd417bac3290f257c7d8495c2243124e916 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 30 Jun 2021 14:29:21 +0300 Subject: [PATCH] show short reason in file workload --- .../src/app/models/file/annotation.wrapper.ts | 59 +++++++++++-------- .../src/app/models/file/file-data.model.ts | 3 + .../file/redaction-log-entry.wrapper.ts | 3 +- .../file-workload.component.html | 20 +++---- .../file-workload/file-workload.component.ts | 4 +- .../pdf-viewer/pdf-viewer.component.ts | 6 +- .../manual-annotation-dialog.component.ts | 9 +-- 7 files changed, 55 insertions(+), 49 deletions(-) diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index ebed53aca..9d2783bc7 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -238,10 +238,10 @@ export class AnnotationWrapper { annotationWrapper.legalBasisChangeValue = redactionLogEntry.legalBasisChangeValue; annotationWrapper.comments = redactionLogEntry.comments || []; annotationWrapper.legalBasis = redactionLogEntry.legalBasis; - AnnotationWrapper._createContent(annotationWrapper, redactionLogEntry); - AnnotationWrapper._setSuperType(annotationWrapper, redactionLogEntry); - AnnotationWrapper._handleSkippedState(annotationWrapper, redactionLogEntry); - AnnotationWrapper._handleRecommendations(annotationWrapper, redactionLogEntry); + this._createContent(annotationWrapper, redactionLogEntry); + this._setSuperType(annotationWrapper, redactionLogEntry); + this._handleSkippedState(annotationWrapper, redactionLogEntry); + this._handleRecommendations(annotationWrapper, redactionLogEntry); annotationWrapper.typeLabel = 'annotation-type.' + annotationWrapper.superType; return annotationWrapper; @@ -351,25 +351,23 @@ export class AnnotationWrapper { annotationWrapper: AnnotationWrapper, redactionLogEntryWrapper: RedactionLogEntryWrapper ) { - if (annotationWrapper.superType === 'skipped') { - if (!annotationWrapper.userId) { - if ( - redactionLogEntryWrapper.manualRedactionType === 'REMOVE' || - redactionLogEntryWrapper.manualRedactionType === 'UNDO' - ) { - annotationWrapper.superType = 'pending-analysis'; - return; - } - } else { - if (redactionLogEntryWrapper.status === 'REQUESTED') { - annotationWrapper.superType = 'suggestion-force-redaction'; - return; - } - } + if (annotationWrapper.superType !== 'skipped') return; - if (redactionLogEntryWrapper.actionPendingReanalysis) { + if (!annotationWrapper.userId) { + if ( + redactionLogEntryWrapper.manualRedactionType === 'REMOVE' || + redactionLogEntryWrapper.manualRedactionType === 'UNDO' + ) { annotationWrapper.superType = 'pending-analysis'; + return; } + } else if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-force-redaction'; + return; + } + + if (redactionLogEntryWrapper.actionPendingReanalysis) { + annotationWrapper.superType = 'pending-analysis'; } } @@ -381,18 +379,29 @@ export class AnnotationWrapper { if (entry.matchedRule) { content += 'Rule ' + entry.matchedRule + ' matched \n\n'; } + if (entry.reason) { content += entry.reason + '\n\n'; } - if (entry.legalBasisChangeValue) { - content += 'Legal basis:' + entry.legalBasis + '\n\n'; - } else if (entry.legalBasis) { - content += 'Legal basis:' + entry.legalBasis + '\n\n'; + + if (entry.legalBasisChangeValue || entry.legalBasis) { + content += 'Legal basis: ' + entry.legalBasis + '\n\n'; } + if (entry.section) { content += 'In section: "' + entry.section + '"'; } - annotationWrapper.shortContent = entry.reason || content; + + annotationWrapper.shortContent = this._getShortContent(entry) || content; annotationWrapper.content = content; } + + private static _getShortContent(entry: RedactionLogEntryWrapper) { + if (entry.legalBasis) { + const lb = entry.legalBasisMapping?.find(lbm => lbm.description === entry.reason); + if (lb) return lb.name; + } + + return entry.reason; + } } diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index ab94ca08c..8aeb14511 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -251,11 +251,14 @@ export class FileDataModel { }); result.forEach(redactionLogEntry => { + redactionLogEntry.legalBasisMapping = this.redactionLog.legalBasis; + if (redactionLogEntry.manual) { if (redactionLogEntry.manualRedactionType === 'ADD') { const foundManualEntry = this.manualRedactions.entriesToAdd.find( me => me.id === redactionLogEntry.id ); + // ADD has been undone - not yet processed if (!foundManualEntry) { redactionLogEntry.hidden = true; diff --git a/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts b/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts index ea61f36ff..26253f957 100644 --- a/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts +++ b/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts @@ -1,4 +1,4 @@ -import { Comment, Rectangle } from '@redaction/red-ui-http'; +import { Comment, LegalBasisMapping, Rectangle } from '@redaction/red-ui-http'; export interface RedactionLogEntryWrapper { color?: Array; @@ -6,6 +6,7 @@ export interface RedactionLogEntryWrapper { hint?: boolean; id?: string; legalBasis?: string; + legalBasisMapping?: Array; manual?: boolean; manualRedactionType?: 'ADD' | 'REMOVE' | 'UNDO' | 'LEGAL_BASIS_CHANGE'; matchedRule?: number; diff --git a/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.html index a49723e6d..f18120c34 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.html @@ -175,7 +175,7 @@ *ngFor=" let annotation of displayedAnnotations[activeViewerPage]?.annotations " - [class.active]="annotationIsSelected(annotation)" + [class.active]="isSelected(annotation)" [class.multi-select-active]="multiSelectActive" attr.annotation-id="{{ annotation.id }}" attr.annotation-page="{{ activeViewerPage }}" @@ -213,10 +213,7 @@
@@ -269,11 +266,10 @@ - - - + diff --git a/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.ts index b0f25ef89..88dbbd086 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/file-workload/file-workload.component.ts @@ -123,7 +123,7 @@ export class FileWorkloadComponent { return this._translateService.instant(i18nString, { count: comments.length }); } - annotationIsSelected(annotation: AnnotationWrapper) { + isSelected(annotation: AnnotationWrapper) { return this.selectedAnnotations?.find(a => a?.id === annotation.id); } @@ -167,7 +167,7 @@ export class FileWorkloadComponent { annotationClicked(annotation: AnnotationWrapper, $event: MouseEvent) { this.pagesPanelActive = false; - if (this.annotationIsSelected(annotation)) { + if (this.isSelected(annotation)) { this.deselectAnnotations.emit([annotation]); } else { if (($event.ctrlKey || $event.metaKey) && this.selectedAnnotations.length > 0) { diff --git a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts index 0b5d93e7e..494a2d6d7 100644 --- a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts @@ -69,7 +69,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { private readonly _annotationDrawService: AnnotationDrawService, private readonly _annotationActionsService: AnnotationActionsService, private readonly _appConfigService: AppConfigService, - private readonly _appLoadStateService: LoadingService + private readonly _loadingService: LoadingService ) {} ngOnInit() { @@ -660,7 +660,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { const compareDocumentPageCount = await compareDocument.getPageCount(); const loadCompareDocument = async () => { - this._appLoadStateService.start(); + this._loadingService.start(); try { const maxPageCount = Math.max( @@ -746,7 +746,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { this.navigateToPage(1); } catch (e) {} - this._appLoadStateService.stop(); + this._loadingService.stop(); }; if (currentDocumentPageCount !== compareDocumentPageCount) { diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts index 086f02eb3..3955d420d 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts @@ -105,14 +105,11 @@ export class ManualAnnotationDialogComponent implements OnInit { this._manualAnnotationService .addAnnotation(this.manualRedactionEntryWrapper.manualRedactionEntry) .subscribe( - response => { + response => this.dialogRef.close( new ManualAnnotationResponse(this.manualRedactionEntryWrapper, response) - ); - }, - () => { - this.dialogRef.close(); - } + ), + () => this.dialogRef.close() ); }