From 050b0bc55accd6cc50958d348b209fbac8e131f2 Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Mon, 3 Jun 2024 13:07:14 +0300 Subject: [PATCH] RED-5108: added redact functionality for hint images. --- .../src/app/models/file/annotation-permissions.utils.ts | 5 ++++- .../annotation-actions/annotation-actions.component.html | 2 +- .../annotation-actions/annotation-actions.component.ts | 4 ++++ .../force-annotation-dialog.component.html | 1 + .../force-annotation-dialog.component.ts | 4 ++++ .../services/pdf-annotation-actions.service.ts | 7 +++++-- apps/red-ui/src/app/modules/icons/icons.module.ts | 1 + libs/red-domain/src/lib/files/super-types.ts | 2 +- 8 files changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/red-ui/src/app/models/file/annotation-permissions.utils.ts b/apps/red-ui/src/app/models/file/annotation-permissions.utils.ts index dfb735ba7..0fa2a9a88 100644 --- a/apps/red-ui/src/app/models/file/annotation-permissions.utils.ts +++ b/apps/red-ui/src/app/models/file/annotation-permissions.utils.ts @@ -8,7 +8,10 @@ export const canForceHint = (annotation: AnnotationWrapper, canAddRedaction: boo canAddRedaction && annotation.isIgnoredHint && !annotation.pending; export const canForceRedaction = (annotation: AnnotationWrapper, canAddRedaction: boolean) => - canAddRedaction && annotation.isSkipped && !annotation.isFalsePositive && !annotation.pending; + canAddRedaction && + (annotation.isSkipped || (annotation.IMAGE_HINT && !annotation.hasBeenForcedRedaction)) && + !annotation.isFalsePositive && + !annotation.pending; export const canAcceptRecommendation = (annotation: AnnotationWrapper) => annotation.isRecommendation && !annotation.pending; diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html index 61017a470..ae90408c4 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html @@ -108,7 +108,7 @@ [tooltip]="'annotation-actions.force-redaction.label' | translate" [type]="buttonType" [buttonId]="annotations.length === 1 ? 'annotation-' + annotations[0].id + '-force_redaction' : 'annotations-force_redaction'" - icon="iqser:thumb-up" + [icon]="isImageHint ? 'red:pdftron-action-add-redaction' : 'iqser:thumb-up'" > annotation.IMAGE_HINT); + } + @Input() set annotations(annotations: AnnotationWrapper[]) { this.#annotations = annotations.filter(a => a !== undefined); diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.html index 3c4c15b55..775c89566 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.html @@ -8,6 +8,7 @@ [columns]="tableColumns" [data]="tableData" [staticColumns]="true" + *ngIf="!isImageHint" >
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.ts index 3925d5752..7a151a4f6 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.ts @@ -53,6 +53,10 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen this.form = this.#getForm(); } + get isImageHint() { + return this._data.annotations.every(annotation => annotation.IMAGE_HINT); + } + get isHintDialog() { return this._data.hint; } diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-annotation-actions.service.ts index c2086fa7f..deac10928 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-annotation-actions.service.ts @@ -81,8 +81,11 @@ export class PdfAnnotationActionsService { } if (permissions.canForceRedaction && annotationChangesAllowed) { - const forceRedactionButton = this.#getButton('thumb-up', _('annotation-actions.force-redaction.label'), () => - this.#annotationActionsService.forceAnnotation(annotations), + const isImageHint = annotations.every(annotation => annotation.IMAGE_HINT); + const forceRedactionButton = this.#getButton( + isImageHint ? 'general/pdftron-action-add-redaction' : 'thumb-up', + _('annotation-actions.force-redaction.label'), + () => this.#annotationActionsService.forceAnnotation(annotations), ); availableActions.push(forceRedactionButton); } diff --git a/apps/red-ui/src/app/modules/icons/icons.module.ts b/apps/red-ui/src/app/modules/icons/icons.module.ts index a2b7a8376..dab2ac28d 100644 --- a/apps/red-ui/src/app/modules/icons/icons.module.ts +++ b/apps/red-ui/src/app/modules/icons/icons.module.ts @@ -86,6 +86,7 @@ export class IconsModule { 'visibility', 'visibility-off', 'warning', + 'pdftron-action-add-redaction', ]; for (const icon of icons) { diff --git a/libs/red-domain/src/lib/files/super-types.ts b/libs/red-domain/src/lib/files/super-types.ts index c673fc945..027b4eecc 100644 --- a/libs/red-domain/src/lib/files/super-types.ts +++ b/libs/red-domain/src/lib/files/super-types.ts @@ -88,7 +88,7 @@ export const SuperTypeMapper: Record resolveRedactionType(entry), }, [EntityTypes.IMAGE_HINT]: { - [EntryStates.APPLIED]: wrongSuperTypeHandler, + [EntryStates.APPLIED]: entry => resolveRedactionType(entry), [EntryStates.SKIPPED]: () => SuperTypes.Hint, [EntryStates.IGNORED]: () => SuperTypes.IgnoredHint, [EntryStates.REMOVED]: wrongSuperTypeHandler,