From 82f7864a0a384bd5b9900c072c56fdbcd29a4112 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Tue, 14 Dec 2021 21:03:50 +0200 Subject: [PATCH] rectangle/value/section for 3.x --- .../file/manual-redaction-entry.wrapper.ts | 1 - .../manual-annotation-dialog.component.html | 50 +++++++++++-------- .../manual-annotation-dialog.component.ts | 23 ++++++--- .../pdf-viewer/pdf-viewer.component.ts | 9 ++-- .../services/annotation-actions.service.ts | 11 +++- .../services/manual-annotation.service.ts | 4 +- .../redaction-log/add-redaction.request.ts | 2 + .../redaction-log/manual-redaction-entry.ts | 1 + 8 files changed, 63 insertions(+), 38 deletions(-) diff --git a/apps/red-ui/src/app/models/file/manual-redaction-entry.wrapper.ts b/apps/red-ui/src/app/models/file/manual-redaction-entry.wrapper.ts index 79504dea3..345b7c4e4 100644 --- a/apps/red-ui/src/app/models/file/manual-redaction-entry.wrapper.ts +++ b/apps/red-ui/src/app/models/file/manual-redaction-entry.wrapper.ts @@ -13,7 +13,6 @@ export class ManualRedactionEntryWrapper { readonly quads: any, readonly manualRedactionEntry: IManualRedactionEntry, readonly type: ManualRedactionEntryType, - readonly annotationType: 'TEXT' | 'RECTANGLE' = 'TEXT', readonly rectId?: string, ) {} } diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html b/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html index 1788ae51a..46db18d59 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html +++ b/apps/red-ui/src/app/modules/dossier/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html @@ -3,19 +3,37 @@
- +
{{ format(data.manualRedactionEntryWrapper.manualRedactionEntry.value) }}
- +
+
+ + + + {{ displayedDictionaryLabel }} + + + {{ dictionary.label }} + + + +
+
-
- - +
+ +
-
- +
+ + +
- - {{ displayedDictionaryLabel }} - - - {{ dictionary.label }} - - - +
+ +
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 55ce35c2b..710b4fc6b 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 @@ -28,7 +28,7 @@ export class ManualAnnotationDialogComponent implements OnInit { isDictionaryRequest: boolean; isFalsePositiveRequest: boolean; - redactionDictionaries: Dictionary[] = []; + possibleDictionaries: Dictionary[] = []; legalOptions: LegalBasisOption[] = []; private readonly _dossier: Dossier; @@ -51,7 +51,7 @@ export class ManualAnnotationDialogComponent implements OnInit { this.redactionForm = this._getForm(); - this.redactionDictionaries = this._redactionDictionaries; + this.possibleDictionaries = this._possibleDictionaries; } get title() { @@ -61,24 +61,25 @@ export class ManualAnnotationDialogComponent implements OnInit { get displayedDictionaryLabel() { const dictType = this.redactionForm.get('dictionary').value; if (dictType) { - return this.redactionDictionaries.find(d => d.type === dictType).label; + return this.possibleDictionaries.find(d => d.type === dictType).label; } return null; } - private get _redactionDictionaries(): Dictionary[] { - const redactionDictionaries: Dictionary[] = []; + private get _possibleDictionaries(): Dictionary[] { + const possibleDictionaries: Dictionary[] = []; const dossier = this._dossier; for (const key of Object.keys(this._appStateService.dictionaryData[dossier.dossierTemplateId])) { const dictionaryData = this._appStateService.getDictionary(key, dossier.dossierTemplateId); if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) { - redactionDictionaries.push(dictionaryData); + possibleDictionaries.push(dictionaryData); } } - redactionDictionaries.sort((a, b) => a.label.localeCompare(b.label)); - return redactionDictionaries; + possibleDictionaries.sort((a, b) => a.label.localeCompare(b.label)); + + return possibleDictionaries; } async ngOnInit() { @@ -111,11 +112,13 @@ export class ManualAnnotationDialogComponent implements OnInit { private _getForm(): FormGroup { return this._formBuilder.group({ + section: [null], reason: this.isDictionaryRequest ? [null] : [null, Validators.required], dictionary: this.isDictionaryRequest ? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required] : ['manual', Validators.required], comment: this.isDocumentAdmin ? [null] : [null, Validators.required], + classification: ['non-readable content'], }); } @@ -133,5 +136,9 @@ export class ManualAnnotationDialogComponent implements OnInit { } const commentValue = this.redactionForm.get('comment').value; addRedactionRequest.comment = commentValue ? { text: commentValue } : null; + addRedactionRequest.section = this.redactionForm.get('section').value; + addRedactionRequest.value = addRedactionRequest.rectangle + ? this.redactionForm.get('classification').value + : addRedactionRequest.value; } } diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts index b25e6535a..7db374e3b 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts @@ -495,12 +495,10 @@ export class PdfViewerComponent implements OnInit, OnChanges { const activeAnnotation = this.annotationManager.getSelectedAnnotations()[0]; const activePage = activeAnnotation.getPageNumber(); const quads = [this._annotationDrawService.annotationToQuads(activeAnnotation, this.instance)]; - const manualRedaction = this._getManualRedaction({ [activePage]: quads }, 'Rectangle'); + const manualRedaction = this._getManualRedaction({ [activePage]: quads }); this._cleanUpSelectionAndButtonState(); - this.manualAnnotationRequested.emit( - new ManualRedactionEntryWrapper(quads, manualRedaction, 'REDACTION', 'RECTANGLE', activeAnnotation.Id), - ); + this.manualAnnotationRequested.emit(new ManualRedactionEntryWrapper(quads, manualRedaction, 'REDACTION', activeAnnotation.Id)); } private _cleanUpSelectionAndButtonState() { @@ -619,7 +617,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { private _getManualRedaction( quads: Readonly>, - text: string, + text?: string, convertQuads = false, ): IManualRedactionEntry { const entry: IManualRedactionEntry = { positions: [] }; @@ -633,6 +631,7 @@ export class PdfViewerComponent implements OnInit, OnChanges { } entry.value = text; + entry.rectangle = !text; return entry; } diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts index 816c7f418..d9b5c3945 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts @@ -88,10 +88,17 @@ export class AnnotationActionsService { 'changeLegalBasis', $event, { annotations, dossier: this._dossier(file) }, - (data: { comment: string; legalBasis: string }) => { + (data: { comment: string; legalBasis: string; section: string; value: string }) => { annotations.forEach(annotation => { this._processObsAndEmit( - this._manualAnnotationService.changeLegalBasis(annotation.annotationId, file, data.legalBasis, data.comment), + this._manualAnnotationService.changeLegalBasis( + annotation.annotationId, + file, + data.section, + data.value, + data.legalBasis, + data.comment, + ), annotation, annotationsChanged, ); diff --git a/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts b/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts index aa9c72a1f..e633cfb30 100644 --- a/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts @@ -102,11 +102,11 @@ export class ManualAnnotationService extends GenericService } // /manualRedaction/request/legalBasis - changeLegalBasis(annotationId: string, file: File, legalBasis: string, comment?: string) { + changeLegalBasis(annotationId: string, file: File, section: string, value: string, legalBasis: string, comment?: string) { const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file)) ? 'change-legal-basis' : 'request-change-legal-basis'; - return this._makeRequest(mode, file, { annotationId, legalBasis, comment }); + return this._makeRequest(mode, file, { annotationId, legalBasis, comment, section, value }); } // this wraps diff --git a/libs/red-domain/src/lib/redaction-log/add-redaction.request.ts b/libs/red-domain/src/lib/redaction-log/add-redaction.request.ts index ca567f0e8..40040a583 100644 --- a/libs/red-domain/src/lib/redaction-log/add-redaction.request.ts +++ b/libs/red-domain/src/lib/redaction-log/add-redaction.request.ts @@ -10,4 +10,6 @@ export interface IAddRedactionRequest { reason?: string; type?: string; value?: string; + section?: string; + rectangle?: boolean; } diff --git a/libs/red-domain/src/lib/redaction-log/manual-redaction-entry.ts b/libs/red-domain/src/lib/redaction-log/manual-redaction-entry.ts index 45ae9f6c1..a8a9abf9d 100644 --- a/libs/red-domain/src/lib/redaction-log/manual-redaction-entry.ts +++ b/libs/red-domain/src/lib/redaction-log/manual-redaction-entry.ts @@ -16,4 +16,5 @@ export interface IManualRedactionEntry { type?: string; user?: string; value?: string; + rectangle?: boolean; }