diff --git a/apps/red-ui/src/app/components/notifications/notifications.component.scss b/apps/red-ui/src/app/components/notifications/notifications.component.scss index 57b77036c..1b1824665 100644 --- a/apps/red-ui/src/app/components/notifications/notifications.component.scss +++ b/apps/red-ui/src/app/components/notifications/notifications.component.scss @@ -22,7 +22,7 @@ } .mat-mdc-menu-item.notification { - padding: 8px 26px 10px 8px; + padding: 8px 26px 10px 8px !important; margin: 2px 0 0 0; height: fit-content; position: relative; diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.ts b/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.ts index e98c1333c..d131faa9d 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.ts +++ b/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.ts @@ -147,6 +147,7 @@ export class FileAttributeComponent extends BaseFormComponent implements OnDestr handleClick($event: MouseEvent) { $event.stopPropagation(); + $event.preventDefault(); } ngOnDestroy() { @@ -154,6 +155,7 @@ export class FileAttributeComponent extends BaseFormComponent implements OnDestr } handleFieldClick($event: MouseEvent) { + $event.preventDefault(); if (!this.fileNameColumn) { this.editFileAttribute($event); } 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 9703a5007..05dc746f7 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 @@ -37,8 +37,8 @@ import { 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'; import { formStatusToSignal, formValueToSignal, isJustOne } from '@common-ui/utils'; +import { parseRectanglePosition, parseSelectedPageNumbers, prefillPageRange } from '../../utils/enhance-manual-redaction-request.utils'; interface TypeSelectOptions { type: string; @@ -105,6 +105,20 @@ export class EditRedactionDialogComponent readonly reasonStatus = formStatusToSignal(this.form.controls.reason); readonly reasonValue = formValueToSignal(this.form.controls.reason); readonly sectionValue = formValueToSignal(this.form.controls.section); + constructor( + private readonly _justificationsService: JustificationsService, + private readonly _dictionaryService: DictionaryService, + ) { + super(); + + if (this.allRectangles) { + prefillPageRange( + this.data.annotations[0], + this.data.allFileAnnotations, + this.options as DetailsRadioOption[], + ); + } + } readonly displayedDictionaryLabel = computed(() => { const selectedDictionaryType = this.dictionaryType(); 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 01620c0be..cb101f75d 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 @@ -34,7 +34,7 @@ import { } from '../../utils/dialog-types'; import { formValueToSignal, isJustOne } from '@common-ui/utils'; import { validatePageRange } from '../../utils/form-validators'; -import { parseRectanglePosition, parseSelectedPageNumbers } from '../../utils/enhance-manual-redaction-request.utils'; +import { parseRectanglePosition, parseSelectedPageNumbers, prefillPageRange } from '../../utils/enhance-manual-redaction-request.utils'; @Component({ templateUrl: './remove-redaction-dialog.component.html', @@ -145,6 +145,14 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< private readonly _userPreferences: UserPreferenceService, ) { super(); + + if (this.#allRectangles) { + prefillPageRange( + this.data.redactions[0], + this.data.allFileRedactions, + this.options as DetailsRadioOption[], + ); + } } get #defaultOption() { 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 04bae147e..c513b2089 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 @@ -95,7 +95,7 @@ export class AnnotationActionsService { ); } else { const addAnnotationRequest = annotations.map(a => ({ - comment: { text: request.comment }, + comment: request.comment, legalBasis: request.legalBasis, reason: request.reason, positions: a.positions, @@ -113,9 +113,11 @@ export class AnnotationActionsService { async editRedaction(annotations: AnnotationWrapper[]) { const { dossierId, file } = this._state; + const allFileAnnotations = this._fileDataService.annotations(); const includeUnprocessed = annotations.every(annotation => this.#includeUnprocessed(annotation, true)); const data = { annotations, + allFileAnnotations, dossierId, file: file(), }; @@ -184,9 +186,11 @@ export class AnnotationActionsService { const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId); const isApprover = this._permissionsService.isApprover(this._state.dossier()); const { file } = this._state; + const allFileRedactions = this._fileDataService.annotations(); const data = { redactions, + allFileRedactions, file: file(), dossier: this._state.dossier(), falsePositiveContext: redactions.map(r => this.#getFalsePositiveText(r)), diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts index 00131bcda..e0f84cba2 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts @@ -64,6 +64,7 @@ export interface RedactTextData { export interface EditRedactionData { annotations: AnnotationWrapper[]; + allFileAnnotations?: AnnotationWrapper[]; dossierId: string; file: File; isApprover?: boolean; @@ -135,6 +136,7 @@ export interface RemoveRedactionPermissions { export interface RemoveRedactionData { redactions: AnnotationWrapper[]; + allFileRedactions?: AnnotationWrapper[]; dossier: Dossier; file?: File; falsePositiveContext: string[]; diff --git a/apps/red-ui/src/app/modules/file-preview/utils/enhance-manual-redaction-request.utils.ts b/apps/red-ui/src/app/modules/file-preview/utils/enhance-manual-redaction-request.utils.ts index 3a28bf209..17e16a046 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/enhance-manual-redaction-request.utils.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/enhance-manual-redaction-request.utils.ts @@ -1,7 +1,8 @@ import { Dictionary, File, IAddRedactionRequest, IEntityLogEntryPosition, SuperType } from '@red/domain'; import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper'; -import { LegalBasisOption } from './dialog-types'; +import { LegalBasisOption, RectangleRedactOption, RectangleRedactOptions } from './dialog-types'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { DetailsRadioOption } from '@common-ui/inputs/details-radio/details-radio-option'; export interface EnhanceRequestData { readonly type: SuperType | null; @@ -79,3 +80,60 @@ export const parseRectanglePosition = (annotation: AnnotationWrapper) => { pageNumber: position.page, } as IEntityLogEntryPosition; }; + +export const prefillPageRange = ( + annotation: AnnotationWrapper, + allFileAnnotations: AnnotationWrapper[], + options: DetailsRadioOption[], +) => { + const option = options.find(o => o.value === RectangleRedactOptions.MULTIPLE_PAGES); + const pages = extractPages(annotation, allFileAnnotations); + option.additionalInput.value = toRangeString(pages); +}; + +const extractPages = (annotation: AnnotationWrapper, allFileAnnotations: AnnotationWrapper[]): number[] => { + return allFileAnnotations.reduce((pages, a) => { + const position = a.positions[0]; + const annotationPosition = annotation.positions[0]; + if ( + position.height === annotationPosition.height && + position.width === annotationPosition.width && + position.topLeft.x === annotationPosition.topLeft.x && + position.topLeft.y === annotationPosition.topLeft.y + ) { + pages.push(position.page); + } + return pages; + }, []); +}; + +const toRangeString = (pages: number[]): string => { + if (pages.length === 0) { + return ''; + } + + let ranges = []; + let start = pages[0]; + let end = pages[0]; + + for (let i = 1; i < pages.length; i++) { + if (pages[i] === end + 1) { + end = pages[i]; + } else { + if (start === end) { + ranges.push(`${start}`); + } else { + ranges.push(`${start}-${end}`); + } + start = end = pages[i]; + } + } + + if (start === end) { + ranges.push(`${start}`); + } else { + ranges.push(`${start}-${end}`); + } + + return ranges.join(','); +}; diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 000d06045..52216ce23 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -2134,7 +2134,7 @@ "type": "Typ", "type-placeholder": "Typ auswählen...", "unchanged": "Ungeändert", - "value": "" + "value": "Wert" }, "title": "Text schwärzen" } diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index 228da81eb..08266540c 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -2134,7 +2134,7 @@ "type": "Type", "type-placeholder": "Select type...", "unchanged": "", - "value": "" + "value": "Wert" }, "title": "Redact text" } diff --git a/libs/common-ui b/libs/common-ui index 3f214d972..f36b1fa8e 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 3f214d9726e17cd204acae8a4ef95749260b3c9a +Subproject commit f36b1fa8e276c83fe1edaef1e453a37a41b58b79