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 1a4e8384e..d1658240f 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 @@ -105,14 +105,6 @@ 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) { @@ -164,6 +156,14 @@ export class EditRedactionDialogComponent return this.annotations.every(annotation => annotation.type === this.annotations[0].type); } + extraOptionChanged(option: DetailsRadioOption): void { + if (option.value === RectangleRedactOptions.MULTIPLE_PAGES) { + setTimeout(() => { + this.form.get('option')?.updateValueAndValidity(); + }, 0); + } + } + async ngOnInit() { this.#setTypes(); const data = await firstValueFrom(this._justificationsService.loadAll(this.#dossier.dossierTemplateId)); 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 7bbe89cdb..2427d4aa4 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 @@ -77,7 +77,7 @@ export class RectangleAnnotationDialog private readonly _toaster: Toaster, ) { super(); - this.#dossier = activeDossiersService.find(this.data.dossierId); + this.#dossier = this.activeDossiersService.find(this.data.dossierId); this.options = getRectangleRedactOptions(); @@ -85,6 +85,10 @@ export class RectangleAnnotationDialog this.initialFormValue = this.form.getRawValue(); } + get #isMultiplePages() { + return this.form.get('option').value.value === RectangleRedactOptions.MULTIPLE_PAGES; + } + extraOptionChanged(option: DetailsRadioOption): void { if (option.value === RectangleRedactOptions.MULTIPLE_PAGES) { setTimeout(() => { @@ -109,11 +113,8 @@ export class RectangleAnnotationDialog save() { this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); try { - const annotation = ( - this.form.get('option').value.value === RectangleRedactOptions.MULTIPLE_PAGES - ? this.#multiplePagesRectangle - : this.data.manualRedactionEntryWrapper - ).manualRedactionEntry; + const annotation = (this.#isMultiplePages ? this.#multiplePagesRectangle : this.data.manualRedactionEntryWrapper) + .manualRedactionEntry; super.close({ annotation, }); @@ -143,7 +144,7 @@ export class RectangleAnnotationDialog addRedactionRequest.addToDictionary = false; const commentValue = this.form.get('comment').value; - addRedactionRequest.comment = commentValue ? { text: commentValue } : null; + addRedactionRequest.comment = commentValue ? (this.#isMultiplePages ? commentValue : { text: commentValue }) : null; addRedactionRequest.section = this.form.get('section').value; addRedactionRequest.value = this.form.get('classification').value; } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component.ts index 1bca4ff37..45422d827 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component.ts @@ -102,6 +102,10 @@ export class RedactRecommendationDialogComponent this.form.controls.option.setValue(this.options[0]); } + get isBulkLocal(): boolean { + return this.form.controls.option.value.value === ResizeOptions.IN_DOCUMENT; + } + get displayedDictionaryLabel() { const dictType = this.form.controls.dictionary.value; if (dictType) { @@ -153,7 +157,7 @@ export class RedactRecommendationDialogComponent this.close({ redaction, isMulti: this.isMulti, - bulkLocal: this.form.controls.option.value.value === ResizeOptions.IN_DOCUMENT, + bulkLocal: this.isBulkLocal, }); } @@ -181,7 +185,7 @@ export class RedactRecommendationDialogComponent } const commentValue = this.form.controls.comment.value; - addRedactionRequest.comment = commentValue ? { text: commentValue } : null; + addRedactionRequest.comment = commentValue ? (this.isBulkLocal ? commentValue : { text: commentValue }) : null; addRedactionRequest.addToAllDossiers = this.data.isApprover && this.dictionaryRequest && this.#applyToAllDossiers; return addRedactionRequest; } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts index 21c95b325..be81ad416 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts @@ -10,7 +10,7 @@ import { DetailsRadioOption } from '@common-ui/inputs/details-radio/details-radi import { DetailsRadioComponent } from '@common-ui/inputs/details-radio/details-radio.component'; import { CircleButtonComponent, HasScrollbarDirective, IconButtonComponent, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; import { TranslateModule } from '@ngx-translate/core'; -import { Dictionary, IAddRedactionRequest, SuperTypes } from '@red/domain'; +import { Dictionary, SuperTypes } from '@red/domain'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { DictionaryService } from '@services/entity-services/dictionary.service'; import { JustificationsService } from '@services/entity-services/justifications.service'; @@ -116,6 +116,10 @@ export class RedactTextDialogComponent ); } + get isBulkLocal() { + return this.form.controls.option.value.value === ResizeOptions.IN_DOCUMENT; + } + get isSystemDefault(): boolean { return this._userPreferences.getAddRedactionDefaultOption() === SystemDefaultOption.SYSTEM_DEFAULT; } @@ -182,7 +186,7 @@ export class RedactTextDialogComponent this.close({ redaction, dictionary: this.dictionaries.find(d => d.type === this.form.controls.dictionary.value), - bulkLocal: this.form.controls.option.value.value === ResizeOptions.IN_DOCUMENT, + bulkLocal: this.isBulkLocal, }); } @@ -259,6 +263,7 @@ export class RedactTextDialogComponent comment: this.form.controls.comment.value, isApprover: this.data.isApprover, applyToAllDossiers: this.#applyToAllDossiers, + bulkLocal: this.isBulkLocal, }; } } 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 a42fa6d61..7ce207c0c 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 @@ -26,7 +26,6 @@ import { } from '../../components/selected-annotations-table/selected-annotations-table.component'; import { getRectangleRedactOptions, getRemoveRedactionOptions } from '../../utils/dialog-options'; import { - EditRedactionOption, RectangleRedactOption, RectangleRedactOptions, RemoveRedactionData, @@ -35,6 +34,7 @@ import { RemoveRedactionResult, ResizeOptions, } from '../../utils/dialog-types'; +import { isJustOne } from '@common-ui/utils'; import { validatePageRange } from '../../utils/form-validators'; import { parseRectanglePosition, parseSelectedPageNumbers } from '../../utils/enhance-manual-redaction-request.utils'; @@ -157,7 +157,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent< } get isBulk() { - return this.data.redactions.length > 1; + return !isJustOne(this.data.redactions); } get redactedTextsAreaHeight() { 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 ecf5b5300..d0d81ee5c 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 @@ -51,7 +51,6 @@ import { FilePreviewStateService } from './file-preview-state.service'; import { ManualRedactionService } from './manual-redaction.service'; import { SkippedService } from './skipped.service'; import { NON_READABLE_CONTENT } from '../dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component'; -import { result } from 'lodash-es'; @Injectable() export class AnnotationActionsService { @@ -86,7 +85,7 @@ export class AnnotationActionsService { const { dossierId, fileId } = this._state; const data = { dossier: this._state.dossier(), annotations, hint }; this._dialogService.openDialog('forceAnnotation', data, (request: ILegalBasisChangeRequest) => { - let obs$; + let obs$: Observable; if (request.option === ForceAnnotationOptions.ONLY_HERE) { obs$ = this._manualRedactionService.bulkForce( annotations.map(a => ({ ...request, annotationId: a.id })), @@ -158,6 +157,7 @@ export class AnnotationActionsService { rectangle: annotations[0].AREA, pageNumbers: result.pageNumbers, position: result.position, + comment: result.comment, }; } @@ -487,7 +487,9 @@ export class AnnotationActionsService { for (let i = 0; i < splitNumber; i++) { splitRequests.push(requests.slice(i * maximumNumberEntries, (i + 1) * maximumNumberEntries)); } - splitRequests.push(requests.slice(splitNumber * maximumNumberEntries, splitNumber * maximumNumberEntries + remainder)); + if (remainder) { + splitRequests.push(requests.slice(splitNumber * maximumNumberEntries, splitNumber * maximumNumberEntries + remainder)); + } const promises = []; for (const split of splitRequests) { @@ -601,12 +603,14 @@ export class AnnotationActionsService { originTypes: [redaction.entry.type], pageNumbers: dialogResult.pageNumbers, position: dialogResult.position, + comment: dialogResult.comment, }; } return { value: redaction.value, rectangle: false, + comment: dialogResult.comment, }; } 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 635549d37..bdf220456 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 @@ -12,6 +12,7 @@ export interface EnhanceRequestData { readonly comment: string; readonly isApprover: boolean; readonly applyToAllDossiers: boolean; + readonly bulkLocal: boolean; } interface MultiplePagesRectangleData { @@ -43,7 +44,7 @@ export const enhanceManualRedactionRequest = (addRedactionRequest: IAddRedaction addRedactionRequest.reason = 'Dictionary Request'; } const commentValue = data.comment; - addRedactionRequest.comment = commentValue ? { text: commentValue } : null; + addRedactionRequest.comment = commentValue ? (data.bulkLocal ? commentValue : { text: commentValue }) : null; addRedactionRequest.addToAllDossiers = data.isApprover && data.dictionaryRequest && data.applyToAllDossiers; }; diff --git a/libs/red-domain/src/lib/redaction-log/add-redaction.request.ts b/libs/red-domain/src/lib/redaction-log/add-redaction.request.ts index 2665fa420..b3af322c8 100644 --- a/libs/red-domain/src/lib/redaction-log/add-redaction.request.ts +++ b/libs/red-domain/src/lib/redaction-log/add-redaction.request.ts @@ -5,7 +5,7 @@ import { DictionaryEntryType } from './dictionary-entry-types'; export interface IAddRedactionRequest { addToDictionary?: boolean; dictionaryEntryType?: DictionaryEntryType; - comment?: { text: string }; + comment?: { text: string } | string; legalBasis?: string; positions?: List; reason?: string; diff --git a/libs/red-domain/src/lib/redaction-log/recategorization.request.ts b/libs/red-domain/src/lib/redaction-log/recategorization.request.ts index edf967fc8..9939b140a 100644 --- a/libs/red-domain/src/lib/redaction-log/recategorization.request.ts +++ b/libs/red-domain/src/lib/redaction-log/recategorization.request.ts @@ -19,4 +19,5 @@ export interface IBulkRecategorizationRequest { readonly rectangle: boolean; readonly position?: IEntityLogEntryPosition; readonly pageNumbers?: number[]; + readonly comment?: string; } diff --git a/libs/red-domain/src/lib/redaction-log/remove-redaction.request.ts b/libs/red-domain/src/lib/redaction-log/remove-redaction.request.ts index 364198733..df966c022 100644 --- a/libs/red-domain/src/lib/redaction-log/remove-redaction.request.ts +++ b/libs/red-domain/src/lib/redaction-log/remove-redaction.request.ts @@ -16,4 +16,5 @@ export interface IBulkLocalRemoveRequest { originTypes?: string[]; originLegalBases?: string[]; pageNumbers?: number[]; + comment?: string; }