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 fd1ff6d7c..179b87bea 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 @@ -39,3 +39,9 @@ export const canResizeAnnotation = (annotation: AnnotationWrapper, canAddRedacti !annotation.isSkipped && !annotation.pending && (annotation.isRedacted || annotation.isImage || annotation.isDictBasedHint || annotation.isRecommendation); + +export const canEditAnnotation = (annotation: AnnotationWrapper) => (annotation.isRedacted || annotation.isSkipped) && !annotation.isImage; + +export const canEditHint = (annotation: AnnotationWrapper) => annotation.HINT || annotation.isIgnoredHint; + +export const canEditImage = (annotation: AnnotationWrapper) => annotation.isImage; diff --git a/apps/red-ui/src/app/models/file/annotation.permissions.ts b/apps/red-ui/src/app/models/file/annotation.permissions.ts index cddebeb9a..02ef8c65c 100644 --- a/apps/red-ui/src/app/models/file/annotation.permissions.ts +++ b/apps/red-ui/src/app/models/file/annotation.permissions.ts @@ -2,10 +2,12 @@ import { IqserPermissionsService } from '@iqser/common-ui'; import { Dictionary } from '@red/domain'; import { Roles } from '@users/roles'; import { isArray } from 'lodash-es'; -import { IMAGE_CATEGORIES } from '../../modules/file-preview/utils/constants'; import { canAcceptRecommendation, canChangeLegalBasis, + canEditAnnotation, + canEditHint, + canEditImage, canForceHint, canForceRedaction, canMarkAsFalsePositive, @@ -61,11 +63,9 @@ export class AnnotationPermissions { permissions.canChangeLegalBasis = canChangeLegalBasis(annotation, canAddRedaction); permissions.canRecategorizeAnnotation = canRecategorizeAnnotation(annotation, canAddRedaction); permissions.canResizeAnnotation = canResizeAnnotation(annotation, canAddRedaction); - - permissions.canEditAnnotations = (annotation.isSkipped || annotation.isRedacted) && !annotation.isImage; - permissions.canEditHints = annotation.isIgnoredHint || annotation.isDictBasedHint || annotation.isHint; - permissions.canEditImages = [...IMAGE_CATEGORIES, 'ocr'].includes(annotation.type); - + permissions.canEditAnnotations = canEditAnnotation(annotation); + permissions.canEditHints = canEditHint(annotation); + permissions.canEditImages = canEditImage(annotation); summedPermissions._merge(permissions); } return summedPermissions; diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index 26fa7ca9c..1f70f65d3 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -43,6 +43,7 @@ export class AnnotationWrapper implements IListable { AREA = false; HINT = false; IMAGE = false; + IMAGE_HINT = false; section?: string; reference: string[] = []; imported = false; @@ -91,7 +92,7 @@ export class AnnotationWrapper implements IListable { } get isImage() { - return this.type?.toLowerCase() === 'image' || this.IMAGE; + return this.type?.toLowerCase() === 'image' || this.IMAGE || this.IMAGE_HINT; } get isOCR() { @@ -229,6 +230,7 @@ export class AnnotationWrapper implements IListable { annotationWrapper.HINT = logEntry.entryType === EntityTypes.HINT; annotationWrapper.IMAGE = logEntry.entryType === EntityTypes.IMAGE; annotationWrapper.AREA = logEntry.entryType === EntityTypes.AREA; + annotationWrapper.IMAGE_HINT = logEntry.entryType === EntityTypes.IMAGE_HINT; annotationWrapper.isIgnored = logEntry.state === EntryStates.IGNORED; diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts index c9e1733b7..f5ad1c9f9 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts @@ -6,7 +6,6 @@ import { ActiveDossiersService } from '@services/dossiers/active-dossiers.servic import { DictionaryService } from '@services/entity-services/dictionary.service'; import { JustificationsService } from '@services/entity-services/justifications.service'; import { firstValueFrom } from 'rxjs'; -import { IMAGE_CATEGORIES } from '../../utils/constants'; import { getEditRedactionOptions, RedactOrHintOption } from '../../utils/dialog-options'; import { EditRedactionData, EditRedactResult } from '../../utils/dialog-types'; import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component'; @@ -41,11 +40,11 @@ export class EditRedactionDialogComponent ) { super(); const annotations = this.data.annotations; - this.isImage = annotations.reduce((acc, next) => acc && [...IMAGE_CATEGORIES, 'ocr'].includes(next.type), true); + this.isImage = annotations.reduce((acc, next) => acc && next.isImage, true); this.redactedTexts = !this.isImage ? annotations.map(annotation => annotation.value) : null; this.isModifyDictionary = annotations.every(annotation => annotation.isModifyDictionary); this.isManualRedaction = annotations.every(annotation => annotation.type === SuperTypes.ManualRedaction); - this.isHint = annotations.every(annotation => annotation.isHint); + this.isHint = annotations.every(annotation => annotation.HINT); this.showExtras = !(this.isImage || this.isHint); }