diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts index 1ffd08512..743ff5bcd 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts @@ -9,6 +9,7 @@ import { IqserDialogComponent } from '../../../../../../../../libs/common-ui/src import { PermissionsService } from '@services/permissions.service'; import { tap } from 'rxjs/operators'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { RedactTextOption } from '../redact-text-dialog/redact-text-options'; const PIN_ICON = 'red:push-pin'; const FOLDER_ICON = 'red:folder'; @@ -25,6 +26,7 @@ export interface RemoveRedactionData { dossier: Dossier; falsePositiveContext: string; permissions: RemoveRedactionPermissions; + applyToAllDossiers: boolean; } export interface RemoveRedactionResult { @@ -50,6 +52,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< readonly #redaction: AnnotationWrapper; readonly #permissions: RemoveRedactionPermissions; readonly #translations = removeRedactionTranslations; + #applyToAllDossiers: boolean; constructor(private readonly _formBuilder: FormBuilder, private readonly _permissionsService: PermissionsService) { super(); @@ -57,13 +60,17 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< this.#permissions = this.data.permissions; this.options = this.#options(); this.form = this.#getForm(); + this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.form .get('option') .valueChanges.pipe( tap(() => { - this.options[1].extraOption.checked = true; - this.options[2].extraOption.checked = true; + for (const option of this.options) { + if (option.extraOption) { + option.extraOption.checked = this.#applyToAllDossiers; + } + } }), takeUntilDestroyed(), ) @@ -101,7 +108,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< value: RemoveRedactionOptions.IN_DOSSIER, extraOption: { label: this.#translations.IN_DOSSIER.extraOptionLabel, - checked: true, + checked: this.data.applyToAllDossiers ?? true, }, }); } @@ -114,7 +121,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< value: RemoveRedactionOptions.FALSE_POSITIVE, extraOption: { label: this.#translations.FALSE_POSITIVE.extraOptionLabel, - checked: true, + checked: this.data.applyToAllDossiers ?? true, }, }); } diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index c49211e79..6d8db68f3 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -125,6 +125,7 @@ export class AnnotationActionsService { canRemoveOrSuggestToRemoveFromDictionary: permissions.canRemoveOrSuggestToRemoveFromDictionary, canMarkAsFalsePositive: permissions.canMarkAsFalsePositive, }; + const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId); const result: RemoveRedactionResult = await this._iqserDialog .openDefault(RemoveRedactionDialogComponent, { @@ -133,24 +134,23 @@ export class AnnotationActionsService { dossier: this._state.dossier(), falsePositiveContext: this._getFalsePositiveText(redaction), permissions: removePermissions, + applyToAllDossiers: dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault, }, }) .result(); if (result) { if (result.option.value === RemoveRedactionOptions.FALSE_POSITIVE) { - this.#setAsFalsePositive(redaction, result.comment); + this.#setAsFalsePositive(redaction, result); } else { - const removeFromDictionary = result.option.value === RemoveRedactionOptions.IN_DOSSIER; - this.#removeRedaction(redaction, result.comment, removeFromDictionary); + this.#removeRedaction(redaction, result); } - } - if (result.option.extraOption) { - const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId); - const { ...body } = dossierTemplate; - body.applyDictionaryUpdatesToAllDossiersByDefault = result.applyToAllDossiers; - await this._dossierTemplatesService.createOrUpdate(body); + if (result.option.extraOption) { + const { ...body } = dossierTemplate; + body.applyDictionaryUpdatesToAllDossiersByDefault = result.option.extraOption.checked; + await this._dossierTemplatesService.createOrUpdate(body); + } } } @@ -380,29 +380,32 @@ export class AnnotationActionsService { return words; } - #setAsFalsePositive(redaction: AnnotationWrapper, comment: string) { + #setAsFalsePositive(redaction: AnnotationWrapper, dialogResult: RemoveRedactionResult) { const request = { sourceId: redaction.id, value: this._getFalsePositiveText(redaction), type: redaction.type, positions: redaction.positions, addToDictionary: true, + addToAllDossiers: !!dialogResult.option.extraOption?.checked, reason: 'False Positive', dictionaryEntryType: redaction.isRecommendation ? DictionaryEntryTypes.FALSE_RECOMMENDATION : DictionaryEntryTypes.FALSE_POSITIVE, - comment: comment ? { text: comment } : null, + comment: dialogResult.comment ? { text: dialogResult.comment } : null, }; const { dossierId, fileId } = this._state; this.#processObsAndEmit(this._manualRedactionService.addAnnotation([request], dossierId, fileId)).then(); } - #removeRedaction(redaction: AnnotationWrapper, comment: string, removeFromDictionary: boolean) { + #removeRedaction(redaction: AnnotationWrapper, dialogResult: RemoveRedactionResult) { + const removeFromDictionary = dialogResult.option.value === RemoveRedactionOptions.IN_DOSSIER; const body = { annotationId: redaction.id, - comment: comment, + comment: dialogResult.comment, removeFromDictionary, + removeFromAllDossiers: !!dialogResult.option.extraOption?.checked, }; const { dossierId, fileId } = this._state; this.#processObsAndEmit(