From 0be67a85891987823d1f1ce8109da24ec7644edd Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 23 Sep 2024 17:23:15 +0300 Subject: [PATCH] RED-7345 - added bulk local remove logic for "remove redaction" dialog --- .../manual-annotation-dialog.component.ts | 4 +- .../remove-redaction-dialog.component.ts | 13 ------ .../services/annotation-actions.service.ts | 42 +++++++++++++++---- .../services/manual-redaction.service.ts | 17 ++++---- .../file-preview/utils/dialog-options.ts | 1 - .../redaction-log/remove-redaction.request.ts | 13 ++++++ 6 files changed, 61 insertions(+), 29 deletions(-) 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 970bd01d9..c4630f766 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 @@ -32,6 +32,8 @@ export interface LegalBasisOption { description?: string; } +export const NON_READABLE_CONTENT = 'non-readable content'; + @Component({ templateUrl: './manual-annotation-dialog.component.html', styleUrls: ['./manual-annotation-dialog.component.scss'], @@ -196,7 +198,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme ? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required] : [this.manualRedactionTypeExists ? SuperTypes.ManualRedaction : null, Validators.required], comment: [null], - classification: ['non-readable content'], + classification: [NON_READABLE_CONTENT], multiplePages: '', }); } 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 547c4f9ca..8b6812666 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 @@ -134,19 +134,6 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< super(); } - get helpButtonKey() { - if (this.hint) { - return DialogHelpModeKeys.HINT_REMOVE; - } - if (this.recommendation) { - return DialogHelpModeKeys.RECOMMENDATION_REMOVE; - } - if (this.skipped) { - return DialogHelpModeKeys.SKIPPED_REMOVE; - } - return DialogHelpModeKeys.REDACTION_REMOVE; - } - get hasFalsePositiveOption() { return !!this.options.find(option => option.value === RemoveRedactionOptions.FALSE_POSITIVE); } 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 366b809f6..4fd55bba0 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 @@ -8,9 +8,11 @@ import { Core } from '@pdftron/webviewer'; import { DictionaryEntryTypes, EarmarkOperation, + type IBulkLocalRemoveRequest, ILegalBasisChangeRequest, IRecategorizationRequest, IRectangle, + type IRemoveRedactionRequest, IResizeRequest, } from '@red/domain'; import { CommentsApiService } from '@services/comments-api.service'; @@ -45,6 +47,7 @@ import { FilePreviewDialogService } from './file-preview-dialog.service'; import { FilePreviewStateService } from './file-preview-state.service'; import { ManualRedactionService } from './manual-redaction.service'; import { SkippedService } from './skipped.service'; +import { NON_READABLE_CONTENT } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component'; @Injectable() export class AnnotationActionsService { @@ -456,13 +459,7 @@ export class AnnotationActionsService { #removeRedaction(redactions: AnnotationWrapper[], dialogResult: RemoveRedactionResult) { const removeFromDictionary = dialogResult.option.value === RemoveRedactionOptions.IN_DOSSIER; const includeUnprocessed = redactions.every(redaction => this.#includeUnprocessed(redaction, true)); - const body = redactions.map(redaction => ({ - annotationId: redaction.id, - value: redaction.value, - comment: dialogResult.comment, - removeFromDictionary, - removeFromAllDossiers: !!dialogResult.option.extraOption?.checked || !!dialogResult.applyToAllDossiers, - })); + const body = this.#getRemoveRedactionBody(redactions, dialogResult); // todo: might not be correct, probably shouldn't get to this point if they are not all the same const isHint = redactions.every(r => r.isHint); const { dossierId, fileId } = this._state; @@ -545,4 +542,35 @@ export class AnnotationActionsService { } return false; } + + #getRemoveRedactionBody( + redactions: AnnotationWrapper[], + dialogResult: RemoveRedactionResult, + ): List | IBulkLocalRemoveRequest { + if (dialogResult.bulkLocal) { + const redaction = redactions[0]; + if (redaction.value === NON_READABLE_CONTENT) { + return { + value: redaction.value, + rectangle: true, + position: redaction.entry.positions[0], + originTypes: [redaction.entry.type], + pageNumbers: [redaction.pageNumber], + }; + } + + return { + value: redaction.value, + rectangle: false, + }; + } + + return redactions.map(redaction => ({ + annotationId: redaction.id, + value: redaction.value, + comment: dialogResult.comment, + removeFromDictionary: dialogResult.option.value === RemoveRedactionOptions.IN_DOSSIER, + removeFromAllDossiers: !!dialogResult.option.extraOption?.checked || !!dialogResult.applyToAllDossiers, + })); + } } diff --git a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts index 6186a2b12..36504f8db 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts @@ -8,6 +8,7 @@ import { type ManualRedactionEntryType } from '@models/file/manual-redaction-ent import type { DictionaryActions, IAddRedactionRequest, + IBulkLocalRemoveRequest, ILegalBasisChangeRequest, IManualAddResponse, IRecategorizationRequest, @@ -109,7 +110,7 @@ export class ManualRedactionService extends GenericService { } removeRedaction( - body: List, + body: List | IBulkLocalRemoveRequest, dossierId: string, fileId: string, removeFromDictionary = false, @@ -151,13 +152,15 @@ export class ManualRedactionService extends GenericService { return super.delete(annotationIds, url).pipe(this.#log('Undo', annotationIds)); } - remove(body: List, dossierId: string, fileId: string, includeUnprocessed = false, bulkLocal = false) { + remove( + body: List | IBulkLocalRemoveRequest, + dossierId: string, + fileId: string, + includeUnprocessed = false, + bulkLocal = false, + ) { const bulkPath = bulkLocal ? this.#bulkLocal : this.#bulkRedaction; - const newBody = { - value: body[0].value, - rectangle: false, - }; - return this._post(newBody, `${bulkPath}/remove/${dossierId}/${fileId}?includeUnprocessed=${includeUnprocessed}`).pipe( + return this._post(body, `${bulkPath}/remove/${dossierId}/${fileId}?includeUnprocessed=${includeUnprocessed}`).pipe( this.#log('Remove', body), ); } diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts index 217c4e891..35dd23be6 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts @@ -151,7 +151,6 @@ export const getRemoveRedactionOptions = ( applyToAllDossiers: boolean, isDocumine: boolean = false, ): DetailsRadioOption[] => { - console.log('TEST'); const translations = isDocumine ? removeAnnotationTranslations : removeRedactionTranslations; const { permissions, redactions, isApprover, falsePositiveContext } = data; const isBulk = redactions.length > 1; diff --git a/libs/red-domain/src/lib/redaction-log/remove-redaction.request.ts b/libs/red-domain/src/lib/redaction-log/remove-redaction.request.ts index 1967a85cb..364198733 100644 --- a/libs/red-domain/src/lib/redaction-log/remove-redaction.request.ts +++ b/libs/red-domain/src/lib/redaction-log/remove-redaction.request.ts @@ -1,6 +1,19 @@ +import { IEntityLogEntryPosition } from './entity-log-entry'; + export interface IRemoveRedactionRequest { annotationId?: string; comment?: string; removeFromDictionary?: boolean; + removeFromAllDossiers?: boolean; value?: string; } + +export interface IBulkLocalRemoveRequest { + rectangle: boolean; + value: string; + caseSensitive?: boolean; + position?: IEntityLogEntryPosition; + originTypes?: string[]; + originLegalBases?: string[]; + pageNumbers?: number[]; +}