From f20f7d380116b692056e90cfca8e1e567bf30aaa Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Thu, 6 Jul 2023 17:43:13 +0300 Subject: [PATCH] RED-6774 - fixed redact text issues --- .../redact-text-dialog.component.html | 26 ++++++++--------- .../redact-text-dialog.component.ts | 28 ++++++++++++++++--- .../entity-services/dictionary.service.ts | 7 +++-- apps/red-ui/src/assets/i18n/redact/de.json | 3 +- apps/red-ui/src/assets/i18n/redact/en.json | 3 +- apps/red-ui/src/assets/i18n/scm/de.json | 3 +- apps/red-ui/src/assets/i18n/scm/en.json | 3 +- .../src/lib/dictionaries/dictionary.model.ts | 2 ++ .../src/lib/dictionaries/dictionary.ts | 2 ++ .../redaction-log/add-redaction.request.ts | 1 + 10 files changed, 51 insertions(+), 27 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html index f0652bbb7..8dcb7d4cc 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html @@ -1,6 +1,6 @@
-
+
@@ -39,6 +39,18 @@
+ +
+ + +
@@ -60,18 +72,6 @@
- -
- - -
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts index 10bf712eb..8915480d4 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts @@ -58,7 +58,7 @@ export class RedactTextDialogComponent readonly #translations = redactTextTranslations; readonly #dossier: Dossier; - readonly #hint: boolean; + readonly hint: boolean; constructor( private readonly _justificationsService: JustificationsService, @@ -70,7 +70,7 @@ export class RedactTextDialogComponent super(); this.#dossier = _activeDossiersService.find(this.data.dossierId); this.type = this.data.manualRedactionEntryWrapper.type; - this.#hint = this.type === ManualRedactionEntryTypes.HINT; + this.hint = this.type === ManualRedactionEntryTypes.HINT; this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.#manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId); this.options = this.#options(); @@ -98,14 +98,18 @@ export class RedactTextDialogComponent } get disabled() { - if (this.dictionaryRequest || this.#hint) { + if (this.dictionaryRequest || this.hint) { return !this.form.get('dictionary').value; } return !this.form.get('reason').value; } async ngOnInit(): Promise { - this.dictionaries = this._dictionaryService.getPossibleDictionaries(this.#dossier.dossierTemplateId, this.#hint); + this.dictionaries = this._dictionaryService.getPossibleDictionaries( + this.#dossier.dossierTemplateId, + this.hint, + !this.#applyToAllDossiers, + ); const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.#dossier.dossierTemplateId)); this.legalOptions = data.map(lbm => ({ @@ -121,6 +125,19 @@ export class RedactTextDialogComponent extraOptionChanged(option: DetailsRadioOption): void { this.#applyToAllDossiers = option.extraOption.checked; + + this.dictionaries = this._dictionaryService.getPossibleDictionaries( + this.#dossier.dossierTemplateId, + this.hint, + !this.#applyToAllDossiers, + ); + if (this.#applyToAllDossiers && this.form.get('dictionary').value) { + const selectedDictionaryLabel = this.form.get('dictionary').value; + const selectedDictionary = this.dictionaries.find(d => d.type === selectedDictionaryLabel); + if (!selectedDictionary) { + this.form.get('dictionary').setValue(null); + } + } } save(): void { @@ -185,6 +202,9 @@ export class RedactTextDialogComponent addRedactionRequest.value = addRedactionRequest.rectangle ? this.form.get('classification').value : this.form.get('selectedText').value; + if (this.dictionaryRequest) { + addRedactionRequest.addToAllDossiers = this.#applyToAllDossiers; + } } #options() { 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 56cfdb919..76b19b3bd 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 @@ -146,12 +146,15 @@ export class DictionaryService extends EntitiesService return !!this._dictionariesMapService.get(dossierTemplateId).find(e => e.type === SuperTypes.ManualRedaction && !e.virtual); } - getPossibleDictionaries(dossierTemplateId: string, hintTypes: boolean): Dictionary[] { + getPossibleDictionaries(dossierTemplateId: string, hintTypes: boolean, dossierDictionaryOnly = false): Dictionary[] { const possibleDictionaries: Dictionary[] = []; this._dictionariesMapService.get(dossierTemplateId).forEach((d: Dictionary) => { if (!hintTypes) { - if (!d.virtual && !d.hint && !d.systemManaged) { + if ( + (!d.virtual && !d.hint && !d.systemManaged && d.hasDictionary && d.addToDictionaryAction) || + (dossierDictionaryOnly && d.dossierDictionaryOnly) + ) { possibleDictionaries.push(d); } } else if (d.hint) { diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 294073cf1..87314194d 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -1647,8 +1647,6 @@ "license-info-screen": { "backend-version": "Backend-Version der Anwendung", "chart": { - "cumulative": "Seiten insgesamt", - "legend": "", "pages-per-month": "Seiten pro Monat", "total-pages": "Gesamtzahl der Seiten" }, @@ -1943,6 +1941,7 @@ "type": "", "type-placeholder": "" }, + "hint-title": "", "title": "" } }, diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 0c2d1092d..4da79ce07 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -1647,8 +1647,6 @@ "license-info-screen": { "backend-version": "Backend Application Version", "chart": { - "cumulative": "Cumulative Pages", - "legend": "Legend", "pages-per-month": "Pages per Month", "total-pages": "Total Pages" }, @@ -1943,6 +1941,7 @@ "type": "Type", "type-placeholder": "Select type ..." }, + "hint-title": "Add Hint", "title": "Redact text" } }, diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index 33d99d99a..38db993c9 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -1647,8 +1647,6 @@ "license-info-screen": { "backend-version": "Backend-Version der Anwendung", "chart": { - "cumulative": "Seiten insgesamt", - "legend": "", "pages-per-month": "Seiten pro Monat", "total-pages": "Gesamtzahl der Seiten" }, @@ -1943,6 +1941,7 @@ "type": "", "type-placeholder": "" }, + "hint-title": "", "title": "" } }, diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index 58e5b7566..d89f46b0b 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -1647,8 +1647,6 @@ "license-info-screen": { "backend-version": "Backend Application Version", "chart": { - "cumulative": "Cumulative Pages", - "legend": "Legend", "pages-per-month": "Pages per Month", "total-pages": "Total Pages" }, @@ -1943,6 +1941,7 @@ "type": "Type", "type-placeholder": "Select type ..." }, + "hint-title": "Add Hint", "title": "Redact text" } }, diff --git a/libs/red-domain/src/lib/dictionaries/dictionary.model.ts b/libs/red-domain/src/lib/dictionaries/dictionary.model.ts index 329d8472f..9c20bec42 100644 --- a/libs/red-domain/src/lib/dictionaries/dictionary.model.ts +++ b/libs/red-domain/src/lib/dictionaries/dictionary.model.ts @@ -18,6 +18,7 @@ export class Dictionary extends Entity implements IDictionary { readonly type: string; readonly hasDictionary?: boolean; readonly systemManaged?: boolean; + readonly dossierDictionaryOnly?: boolean; entries: List; falsePositiveEntries: List; @@ -42,6 +43,7 @@ export class Dictionary extends Entity implements IDictionary { this.type = entity.type; this.hasDictionary = entity.hasDictionary; this.systemManaged = entity.systemManaged; + this.dossierDictionaryOnly = entity.dossierDictionaryOnly; } get id(): string { diff --git a/libs/red-domain/src/lib/dictionaries/dictionary.ts b/libs/red-domain/src/lib/dictionaries/dictionary.ts index 2a6261360..d5bcfb254 100644 --- a/libs/red-domain/src/lib/dictionaries/dictionary.ts +++ b/libs/red-domain/src/lib/dictionaries/dictionary.ts @@ -58,4 +58,6 @@ export interface IDictionary { readonly hasDictionary?: boolean; readonly systemManaged?: boolean; + + readonly dossierDictionaryOnly?: boolean; } 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 f7121dc86..95e06eece 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 @@ -14,4 +14,5 @@ export interface IAddRedactionRequest { value?: string; section?: string; rectangle?: boolean; + addToAllDossiers?: boolean; }