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 a1f9c2ce9..55bfda05b 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
@@ -18,6 +18,7 @@
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 8f3a13cb2..1a4e8384e 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
@@ -25,10 +25,19 @@ import {
SelectedAnnotationsTableComponent,
ValueColumn,
} from '../../components/selected-annotations-table/selected-annotations-table.component';
-import { getEditRedactionOptions } from '../../utils/dialog-options';
-import { EditRedactionData, EditRedactionOption, EditRedactResult, LegalBasisOption } from '../../utils/dialog-types';
+import { getEditRedactionOptions, getRectangleRedactOptions } from '../../utils/dialog-options';
+import {
+ EditRedactionData,
+ EditRedactionOption,
+ EditRedactResult,
+ LegalBasisOption,
+ RectangleRedactOption,
+ RectangleRedactOptions,
+} from '../../utils/dialog-types';
import { DetailsRadioComponent } from '@common-ui/inputs/details-radio/details-radio.component';
import { DetailsRadioOption } from '@common-ui/inputs/details-radio/details-radio-option';
+import { validatePageRange } from '../../utils/form-validators';
+import { parseRectanglePosition, parseSelectedPageNumbers } from '../../utils/enhance-manual-redaction-request.utils';
interface TypeSelectOptions {
type: string;
@@ -79,7 +88,7 @@ export class EditRedactionDialogComponent
{ label: redaction.value, bold: true },
{ label: redaction.typeLabel },
]);
- options = getEditRedactionOptions();
+ options = this.allRectangles ? getRectangleRedactOptions('edit') : getEditRedactionOptions();
legalOptions: LegalBasisOption[] = [];
dictionaries: Dictionary[] = [];
typeSelectOptions: TypeSelectOptions[] = [];
@@ -96,6 +105,14 @@ export class EditRedactionDialogComponent
super();
}
+ extraOptionChanged(option: DetailsRadioOption): void {
+ if (option.value === RectangleRedactOptions.MULTIPLE_PAGES) {
+ setTimeout(() => {
+ this.form.get('option')?.updateValueAndValidity();
+ }, 0);
+ }
+ }
+
get displayedDictionaryLabel() {
const selectedDictionaryType = this.form.controls.type.value;
if (selectedDictionaryType) {
@@ -188,6 +205,13 @@ export class EditRedactionDialogComponent
const value = this.form.value;
const initialReason: LegalBasisOption = this.initialFormValue.reason;
const initialLegalBasis = initialReason?.legalBasis ?? '';
+ const pageNumbers = parseSelectedPageNumbers(
+ this.form.get('option').value.additionalInput?.value,
+ this.data.file,
+ this.data.annotations[0],
+ );
+ const position = parseRectanglePosition(this.annotations[0]);
+
this.close({
legalBasis: value.reason?.legalBasis ?? (this.isImage ? initialLegalBasis : ''),
section: value.section,
@@ -195,6 +219,8 @@ export class EditRedactionDialogComponent
type: value.type,
value: this.allRectangles ? value.value : null,
option: value.option.value,
+ position,
+ pageNumbers,
});
}
@@ -229,7 +255,7 @@ export class EditRedactionDialogComponent
disabled: this.isImported,
}),
section: new FormControl({ value: sameSection ? this.annotations[0].section : null, disabled: this.isImported }),
- option: new FormControl>(this.options[0]),
+ option: new FormControl>(this.options[0], validatePageRange()),
value: new FormControl(this.allRectangles ? this.annotations[0].value : null),
});
}
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.ts
index 4e565ff06..7bbe89cdb 100644
--- a/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.ts
+++ b/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.ts
@@ -9,8 +9,7 @@ import {
IqserDialogComponent,
Toaster,
} from '@iqser/common-ui';
-import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper';
-import { Dossier, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain';
+import { Dossier, IAddRedactionRequest, SuperTypes } from '@red/domain';
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { Roles } from '@users/roles';
@@ -23,21 +22,17 @@ import { MatOption, MatSelect, MatSelectTrigger } from '@angular/material/select
import { MatTooltip } from '@angular/material/tooltip';
import { MatCheckbox } from '@angular/material/checkbox';
import { DetailsRadioOption } from '@common-ui/inputs/details-radio/details-radio-option';
-import { LegalBasisOption, RectangleRedactOption, RectangleRedactOptions } from '../../utils/dialog-types';
+import {
+ LegalBasisOption,
+ RectangleDialogData,
+ RectangleDialogResult,
+ RectangleRedactOption,
+ RectangleRedactOptions,
+} from '../../utils/dialog-types';
import { getRectangleRedactOptions } from '../../utils/dialog-options';
import { DetailsRadioComponent } from '@common-ui/inputs/details-radio/details-radio.component';
import { SystemDefaults } from '../../../account/utils/dialog-defaults';
import { validatePageRange } from '../../utils/form-validators';
-import { getMultiplePagesRectangle } from '../../utils/enhance-manual-redaction-request.utils';
-
-interface RectangleDialogData {
- dossierId: string;
- manualRedactionEntryWrapper: ManualRedactionEntryWrapper;
- file: File;
-}
-export interface RectangleDialogResult {
- annotation: IManualRedactionEntry;
-}
export const NON_READABLE_CONTENT = 'non-readable content';
@@ -116,7 +111,7 @@ export class RectangleAnnotationDialog
try {
const annotation = (
this.form.get('option').value.value === RectangleRedactOptions.MULTIPLE_PAGES
- ? getMultiplePagesRectangle(this.#multiplePagesRectangleData)
+ ? this.#multiplePagesRectangle
: this.data.manualRedactionEntryWrapper
).manualRedactionEntry;
super.close({
@@ -127,14 +122,6 @@ export class RectangleAnnotationDialog
}
}
- get #multiplePagesRectangleData() {
- return {
- manualRedactionEntryWrapper: this.data.manualRedactionEntryWrapper,
- pages: this.form.get('option').value.additionalInput.value,
- file: this.data.file,
- };
- }
-
#getForm() {
return this._formBuilder.group({
selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value,
@@ -165,6 +152,34 @@ export class RectangleAnnotationDialog
return this.options.find(o => o.value === option);
}
+ get #multiplePagesRectangle() {
+ const value: string = this.form.get('option').value.additionalInput.value.replace(/[^0-9-,]/g, '');
+ const entry = { ...this.data.manualRedactionEntryWrapper.manualRedactionEntry, pageNumbers: [] };
+ const wrapper = {
+ ...this.data.manualRedactionEntryWrapper,
+ manualRedactionEntry: entry,
+ };
+
+ value.split(',').forEach(range => {
+ const splitted = range.split('-');
+ const startPage = parseInt(splitted[0], 10);
+ const endPage = splitted.length > 1 ? parseInt(splitted[1], 10) : startPage;
+ if (!startPage || !endPage || startPage > this.data.file.numberOfPages || endPage > this.data.file.numberOfPages) {
+ throw new Error();
+ }
+
+ for (let page = startPage; page <= endPage; page++) {
+ if (page === wrapper.manualRedactionEntry.positions[0].page) {
+ continue;
+ }
+
+ wrapper.manualRedactionEntry.pageNumbers.push(page);
+ }
+ });
+
+ return wrapper;
+ }
+
#selectReason() {
if (this.legalOptions.length === 1) {
this.form.get('reason').setValue(this.legalOptions[0]);
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.html
index 67b718ed6..af6631396 100644
--- a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.html
+++ b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.html
@@ -14,7 +14,11 @@
>
-
+