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 aa287465d..914897ebc 100644 --- a/apps/red-ui/src/app/models/file/annotation.permissions.ts +++ b/apps/red-ui/src/app/models/file/annotation.permissions.ts @@ -16,6 +16,7 @@ import { canUndo, } from './annotation-permissions.utils'; import { AnnotationWrapper } from './annotation.wrapper'; +import { IMAGE_CATEGORIES } from '../../modules/file-preview/utils/constants'; export class AnnotationPermissions { canUndo = true; @@ -30,6 +31,8 @@ export class AnnotationPermissions { canRecategorizeAnnotation = true; canForceHint = true; canEditAnnotations = true; + canEditHints = true; + canEditImages = true; static forUser( isApprover: boolean, @@ -58,7 +61,22 @@ export class AnnotationPermissions { permissions.canChangeLegalBasis = canChangeLegalBasis(annotation, canAddRedaction); permissions.canRecategorizeAnnotation = canRecategorizeAnnotation(annotation, canAddRedaction); permissions.canResizeAnnotation = canResizeAnnotation(annotation, canAddRedaction); - permissions.canEditAnnotations = annotation.isSkipped || annotation.isRedacted; + + // if (isDocumine) { + // annotation.isSkipped || annotation.isRedacted; + // } else { + // annotation.isImage || annotation.isOCR; + // annotation.isSkipped || annotation.isRedacted; + // annotation.isIgnoredHint || annotation.isDictBasedHint || annotation.isHint || annotation.isSuggestionForceHint; + // } + // const skippedRedacted = annotation.isSkipped || annotation.isRedacted; + // const ignoredHints = annotation.isIgnoredHint || annotation.isDictBasedHint || annotation.isHint || annotation.isSuggestionForceHint; + // const image = annotation + + permissions.canEditAnnotations = (annotation.isSkipped || annotation.isRedacted) && !annotation.isImage; + permissions.canEditHints = + annotation.isIgnoredHint || annotation.isDictBasedHint || annotation.isHint || annotation.isSuggestionForceHint; + permissions.canEditImages = [...IMAGE_CATEGORIES, 'ocr'].includes(annotation.type); summedPermissions._merge(permissions); } @@ -79,6 +97,8 @@ export class AnnotationPermissions { result.canRemoveRedaction = permissions.reduce((acc, next) => acc && next.canRemoveRedaction, true); result.canUndo = permissions.reduce((acc, next) => acc && next.canUndo, true); result.canEditAnnotations = permissions.reduce((acc, next) => acc && next.canEditAnnotations, true); + result.canEditHints = permissions.reduce((acc, next) => acc && next.canEditHints, true); + result.canEditImages = permissions.reduce((acc, next) => acc && next.canEditImages, true); return result; } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.html index 0f7faf0f4..31faa525d 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.html @@ -7,9 +7,13 @@ >
-
- - {{ redactedText }} +
+ + {{ redactedTexts }}
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 82828a887..71c5f0a75 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 @@ -1,5 +1,5 @@ import { Component, inject, OnInit } from '@angular/core'; -import { FormControl, FormGroup } from '@angular/forms'; +import { FormBuilder, FormControl } from '@angular/forms'; import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; import { Dictionary, SuperTypes } from '@red/domain'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; @@ -21,7 +21,7 @@ export class EditRedactionDialogComponent readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId); readonly #applyToAllDossiers = this.data.applyToAllDossiers; readonly iconButtonTypes = IconButtonTypes; - readonly redactedText: string; + readonly redactedTexts?: string[]; readonly isModifyDictionary: boolean; readonly isImage: boolean; readonly isManualRedaction: boolean; @@ -32,27 +32,23 @@ export class EditRedactionDialogComponent options: DetailsRadioOption[] | undefined; legalOptions: LegalBasisOption[] = []; dictionaries: Dictionary[] = []; - readonly form = new FormGroup({ - reason: new FormControl(null), - comment: new FormControl(null), - type: new FormControl(this.data.annotations[0].type), - section: new FormControl(this.data.annotations[0].section), - option: new FormControl(null), - value: new FormControl(this.allRectangles ? this.data.annotations[0].value : null), - }); + readonly form = this.#getForm(); constructor( private readonly _justificationsService: JustificationsService, private readonly _dictionaryService: DictionaryService, + private readonly _formBuilder: FormBuilder, ) { super(); const annotations = this.data.annotations; const firstEntry = annotations[0]; this.isImage = [...IMAGE_CATEGORIES, 'ocr'].includes(firstEntry.type); - this.redactedText = annotations.length === 1 && !this.isImage ? firstEntry.value : null; - this.isModifyDictionary = firstEntry.isModifyDictionary; - this.isManualRedaction = firstEntry.type === SuperTypes.ManualRedaction; - this.isHint = firstEntry.isHint; + const testImage = annotations.reduce((acc, next) => acc && [...IMAGE_CATEGORIES, 'ocr'].includes(next.type), true); + console.log(testImage); + this.redactedTexts = !testImage ? 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.showExtras = !(this.isImage || this.isHint); } @@ -125,4 +121,17 @@ export class EditRedactionDialogComponent { emitEvent: false }, ); } + + #getForm() { + const sameType = new Set(this.data.annotations.map(annotation => annotation.type)).size === 1; + const sameSection = new Set(this.data.annotations.map(annotation => annotation.section)).size === 1; + return this._formBuilder.group({ + reason: new FormControl(null), + comment: new FormControl(null), + type: new FormControl(sameType ? this.data.annotations[0].type : null), + section: new FormControl(sameSection ? this.data.annotations[0].section : null), + option: new FormControl(null), + value: new FormControl(this.allRectangles ? this.data.annotations[0].value : null), + }); + } } 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 b7cb9210f..a222a2f56 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 @@ -97,6 +97,7 @@ export class AnnotationActionsService { }; const result = await this.#getEditRedactionDialog(data).result(); + console.log(result); const requests: Observable[] = []; @@ -113,13 +114,11 @@ export class AnnotationActionsService { })); requests.push(this._manualRedactionService.changeLegalBasis(changeLegalBasisBody, dossierId, fileId)); } - if (this.#isDocumine) { - const recategorizeBody: List = annotations.map(annotation => ({ - annotationId: annotation.id, - type: result.type ?? annotation.type, - })); - requests.push(this._manualRedactionService.recategorizeRedactions(recategorizeBody, dossierId, fileId)); - } + const recategorizeBody: List = annotations.map(annotation => ({ + annotationId: annotation.id, + type: result.type ?? annotation.type, + })); + requests.push(this._manualRedactionService.recategorizeRedactions(recategorizeBody, dossierId, fileId)); if (!requests.length) { return; 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 329236294..c8e16acd3 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 @@ -48,12 +48,25 @@ export class PdfAnnotationActionsService { availableActions.push(resizeButton); } + + /* + + */ + + console.log(annotations); + console.log(annotations.map(annotation => annotation.type)); + console.log(permissions); const canEditRedactions = permissions.canChangeLegalBasis || permissions.canRecategorizeAnnotation || permissions.canForceHint || permissions.canForceRedaction; - const canEdit = this.#isDocumine && annotations.length > 1 ? permissions.canEditAnnotations : canEditRedactions; + const canEdit = + annotations.length > 1 + ? this.#isDocumine + ? permissions.canEditAnnotations + : permissions.canEditHints || permissions.canEditImages || permissions.canEditAnnotations + : canEditRedactions; if (canEdit) { const editButton = this.#getButton('edit', _('annotation-actions.edit-redaction.label'), () => this.#annotationActionsService.editRedaction(annotations), diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index b022421b1..42bf5941f 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -3,7 +3,7 @@ "ADMIN_CONTACT_URL": null, "API_URL": "https://dan.iqser.cloud", "APP_NAME": "RedactManager", - "IS_DOCUMINE": true, + "IS_DOCUMINE": false, "RULE_EDITOR_DEV_ONLY": false, "AUTO_READ_TIME": 3, "BACKEND_APP_VERSION": "4.4.40", @@ -18,8 +18,8 @@ "SELECTION_MODE": "structural", "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview", "ANNOTATIONS_THRESHOLD": 1000, - "THEME": "scm", - "BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/scm/", + "THEME": "redact", + "BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/redact/", "AVAILABLE_NOTIFICATIONS_DAYS": 30, "AVAILABLE_OLD_NOTIFICATIONS_MINUTES": 60, "NOTIFICATIONS_THRESHOLD": 1000, diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 862b5baa7..6853b04a3 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -2056,7 +2056,7 @@ "label": "Remove here" } }, - "redacted-text": "" + "redacted-text": "Redacted {length, plural, one{text} other {texts}}" }, "title": "Remove {count, plural, one{annotation} other {annotations}}" }