From 568a2a6ee30a640904fa20140dee46b8abb0d0c5 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Mon, 21 Nov 2022 11:50:21 +0200 Subject: [PATCH] RED-5553 - entity selection if manual type is not available --- .../manual-annotation-dialog.component.html | 8 ++++++-- .../manual-annotation-dialog.component.ts | 10 ++++++++-- .../entity-services/dictionary.service.ts | 18 ++++++++++++++++++ apps/red-ui/src/assets/i18n/en.json | 1 + 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html index 6102f2b82..48aef3433 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html @@ -31,8 +31,12 @@ -
- +
+ + {{ displayedDictionaryLabel }} diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts index b59fa2c38..4702e1fc7 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts @@ -27,6 +27,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme isFalsePositiveRequest: boolean; isEditingSelectedText = false; applyOnMultiplePages = false; + manualRedactionTypeExists = true; possibleDictionaries: Dictionary[] = []; legalOptions: LegalBasisOption[] = []; @@ -47,6 +48,8 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme this.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE'; this.isDictionaryRequest = this.data.manualRedactionEntryWrapper.type === 'DICTIONARY' || this.isFalsePositiveRequest; + this.manualRedactionTypeExists = this._dictionaryService.hasManualType(this._dossier.dossierTemplateId) && false; + this.form = this._getForm(); this.initialFormValue = this.form.getRawValue(); } @@ -72,7 +75,10 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme } async ngOnInit() { - this.possibleDictionaries = await this._dictionaryService.getDictionariesOptions(this._dossier.dossierTemplateId, this._dossier.id); + this.possibleDictionaries = this.isDictionaryRequest + ? await this._dictionaryService.getDictionariesOptions(this._dossier.dossierTemplateId, this._dossier.id) + : this._dictionaryService.getRedactionTypes(this._dossier.dossierTemplateId); + const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._dossier.dossierTemplateId)); this.legalOptions = data.map(lbm => ({ legalBasis: lbm.reason, @@ -145,7 +151,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme reason: this.isDictionaryRequest ? [null] : [null, Validators.required], dictionary: this.isDictionaryRequest ? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required] - : ['manual', Validators.required], + : [this.manualRedactionTypeExists ? 'manual' : null, Validators.required], comment: [null], classification: ['non-readable content'], multiplePages: '', diff --git a/apps/red-ui/src/app/services/entity-services/dictionary.service.ts b/apps/red-ui/src/app/services/entity-services/dictionary.service.ts index 2cc5b18bd..c7151e5a3 100644 --- a/apps/red-ui/src/app/services/entity-services/dictionary.service.ts +++ b/apps/red-ui/src/app/services/entity-services/dictionary.service.ts @@ -143,6 +143,24 @@ export class DictionaryService extends EntitiesService return throwError(() => 'Entries too short'); } + hasManualType(dossierTemplateId: string): boolean { + return !!this._dictionariesMapService.get(dossierTemplateId).find(e => e.type === 'manual'); + } + + getRedactionTypes(dossierTemplateId: string): Dictionary[] { + const possibleDictionaries: Dictionary[] = []; + + for (const dictionary of this._dictionariesMapService.get(dossierTemplateId)) { + if (!dictionary.virtual && !dictionary.hint && !dictionary.systemManaged) { + possibleDictionaries.push(dictionary); + } + } + + possibleDictionaries.sort((a, b) => a.label.localeCompare(b.label)); + + return possibleDictionaries; + } + async getDictionariesOptions(dossierTemplateId: string, dossierId: string): Promise { const possibleDictionaries: Dictionary[] = []; diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index e550410d2..29ff85d02 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1640,6 +1640,7 @@ "classification": "Value / Classification", "comment": "Comment", "dictionary": "Dictionary", + "type": "Entity", "edit-selected-text": "Edit selected text", "legalBasis": "Legal Basis", "reason": "Reason",