From 4e3de53e45ec51d2870ec11595ea25735ddc6a7e Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Thu, 21 Nov 2024 14:47:52 +0200 Subject: [PATCH] RED-10484: removed multiplePages option for imported rectangles. --- .../edit-redaction-dialog.component.ts | 7 +++---- .../remove-redaction-dialog.component.ts | 7 +++++-- .../modules/file-preview/utils/dialog-options.ts | 15 +++++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) 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 fafa9fb64..af37b314b 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 @@ -82,14 +82,14 @@ export class EditRedactionDialogComponent readonly isManualRedaction = this.annotations.some(annotation => annotation.type === SuperTypes.ManualRedaction); readonly isHint = this.annotations.every(annotation => annotation.HINT || annotation.IMAGE_HINT); readonly isRedacted = this.annotations.every(annotation => annotation.isRedacted); - readonly isImported: boolean = this.annotations.every(annotation => annotation.imported); + readonly isImported: boolean = this.annotations.every(annotation => annotation.imported || annotation.type === 'imported_redaction'); readonly allRectangles = this.annotations.reduce((acc, a) => acc && a.AREA, true); readonly tableColumns: ValueColumn[] = [{ label: 'Value' }, { label: 'Type' }]; readonly tableData: ValueColumn[][] = this.data.annotations.map(redaction => [ { label: redaction.value, bold: true }, { label: redaction.typeLabel }, ]); - options = this.allRectangles ? getRectangleRedactOptions('edit') : getEditRedactionOptions(this.isHint); + options = this.allRectangles ? getRectangleRedactOptions('edit', this.data.annotations) : getEditRedactionOptions(this.isHint); legalOptions: LegalBasisOption[] = []; dictionaries: Dictionary[] = []; typeSelectOptions: TypeSelectOptions[] = []; @@ -104,8 +104,7 @@ export class EditRedactionDialogComponent private readonly _dictionaryService: DictionaryService, ) { super(); - - if (this.allRectangles) { + if (this.allRectangles && !this.isImported) { prefillPageRange( this.data.annotations[0], this.data.allFileAnnotations, 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 87a11092e..76da3737f 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 @@ -104,6 +104,9 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< extra: false, }, }; + readonly isImported: boolean = this.data.redactions.every( + annotation => annotation.imported || annotation.type === 'imported_redaction', + ); readonly allRectangles = this.data.redactions.reduce((acc, a) => acc && a.AREA, true); readonly #applyToAllDossiers = this.systemDefaultByType[this.annotationsType].extra; readonly isSystemDefault = this.optionByType[this.annotationsType].main === SystemDefaultOption.SYSTEM_DEFAULT; @@ -113,7 +116,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< : this.optionByType[this.annotationsType].main; readonly extraOptionPreference = stringToBoolean(this.optionByType[this.annotationsType].extra); readonly options: DetailsRadioOption[] = this.allRectangles - ? getRectangleRedactOptions('remove', this.data) + ? getRectangleRedactOptions('remove', this.data.redactions) : getRemoveRedactionOptions( this.data, this.isSystemDefault || this.isExtraOptionSystemDefault ? this.#applyToAllDossiers : this.extraOptionPreference, @@ -151,7 +154,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< ) { super(); - if (this.allRectangles) { + if (this.allRectangles && !this.isImported) { prefillPageRange( this.data.redactions[0], this.data.allFileRedactions, 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 bd35ccf4c..5fabf77b9 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 @@ -104,12 +104,11 @@ export const getRedactOrHintOptions = ( export const getRectangleRedactOptions = ( action: 'add' | 'edit' | 'remove' = 'add', - data?: RemoveRedactionData, + redactions: AnnotationWrapper[] = [], ): DetailsRadioOption[] => { const translations = action === 'add' ? rectangleRedactTranslations : action === 'edit' ? editRectangleTranslations : removeRectangleTranslations; - const redactions = data?.redactions ?? []; - return [ + const options: DetailsRadioOption[] = [ { label: translations.onlyThisPage.label, description: translations.onlyThisPage.description, @@ -117,7 +116,10 @@ export const getRectangleRedactOptions = ( icon: PIN_ICON, value: RectangleRedactOptions.ONLY_THIS_PAGE, }, - { + ]; + const isImportedWithoutValue = redactions.some(redaction => redaction.type === 'imported_redaction' && !redaction.value); + if (!['edit', 'remove'].includes(action) || !isImportedWithoutValue) { + options.push({ label: translations.multiplePages.label, description: translations.multiplePages.description, descriptionParams: { length: redactions.length }, @@ -130,8 +132,9 @@ export const getRectangleRedactOptions = ( value: '', errorCode: 'invalidRange', }, - }, - ]; + }); + } + return options; }; export const getResizeRedactionOptions = (