diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.ts index 1f41643c1..df634df2e 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/force-redaction-dialog/force-annotation-dialog.component.ts @@ -145,6 +145,7 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen request.legalBasis = !this.isDocumine ? this.form.get('reason').value.legalBasis : DOCUMINE_LEGAL_BASIS; request.comment = this.form.get('comment').value; + request.reason = this.form.get('reason').value.description; request.option = this.form.get('option').value.value; return request; 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 df94ab8bb..63332bb0a 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 @@ -23,6 +23,7 @@ import { SystemDefaultOption, SystemDefaults } from '../../../account/utils/dial import { getRedactOrHintOptions } from '../../utils/dialog-options'; import { RedactOrHintOption, RedactOrHintOptions, RedactTextData, RedactTextResult, ResizeOptions } from '../../utils/dialog-types'; import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component'; +import { enhanceManualRedactionRequest, EnhanceRequestData } from '../../utils/enhance-manual-redaction-request.utils'; const MAXIMUM_TEXT_AREA_WIDTH = 421; @@ -170,8 +171,8 @@ export class RedactTextDialogComponent } save(): void { - this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); const redaction = this.data.manualRedactionEntryWrapper.manualRedactionEntry; + enhanceManualRedactionRequest(redaction, this.#enhanceRequestData); this.close({ redaction, dictionary: this.dictionaries.find(d => d.type === this.form.controls.dictionary.value), @@ -227,33 +228,6 @@ export class RedactTextDialogComponent } } - #enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) { - addRedactionRequest.type = this.form.controls.dictionary.value; - addRedactionRequest.section = null; - addRedactionRequest.value = this.form.controls.selectedText.value; - - const legalOption: LegalBasisOption = this.form.controls.reason.value; - if (legalOption) { - addRedactionRequest.reason = legalOption.description; - addRedactionRequest.legalBasis = legalOption.legalBasis; - } - - const selectedType = this.dictionaries.find(d => d.type === addRedactionRequest.type); - - if (selectedType) { - addRedactionRequest.addToDictionary = selectedType.hasDictionary; - } else { - addRedactionRequest.addToDictionary = this.dictionaryRequest && addRedactionRequest.type !== 'dossier_redaction'; - } - - if (!addRedactionRequest.reason) { - addRedactionRequest.reason = 'Dictionary Request'; - } - const commentValue = this.form.controls.comment.value; - addRedactionRequest.comment = commentValue ? { text: commentValue } : null; - addRedactionRequest.addToAllDossiers = this.data.isApprover && this.dictionaryRequest && this.#applyToAllDossiers; - } - #resetValues() { this.#applyToAllDossiers = this.applyToAll; this.options[2].extraOption.checked = this.#applyToAllDossiers; @@ -268,4 +242,17 @@ export class RedactTextDialogComponent #getOption(option: RedactOrHintOption): DetailsRadioOption { return this.options.find(o => o.value === option); } + + get #enhanceRequestData(): EnhanceRequestData { + return { + type: this.form.controls.dictionary.value, + selectedText: this.form.controls.selectedText.value, + reason: this.form.controls.reason.value, + dictionaries: this.dictionaries, + dictionaryRequest: this.dictionaryRequest, + comment: this.form.controls.comment.value, + isApprover: this.data.isApprover, + applyToAllDossiers: this.#applyToAllDossiers, + }; + } } 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 519cf8c7a..366b809f6 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 @@ -90,8 +90,15 @@ export class AnnotationActionsService { annotations[0].isIgnoredHint, ); } else { - console.log('annotation: ', annotations[0]); - obs$ = this._manualRedactionService.addAnnotation(annotations, dossierId, fileId, { + const addAnnotationRequest = annotations.map(a => ({ + comment: { text: request.comment }, + legalBasis: request.legalBasis, + reason: request.reason, + positions: a.positions, + type: a.type, + value: a.value, + })); + obs$ = this._manualRedactionService.addAnnotation(addAnnotationRequest, dossierId, fileId, { hint, bulkLocal: true, }); @@ -210,7 +217,13 @@ export class AnnotationActionsService { this.cancelResize(recommendations[0]).then(); } - const request$ = this._manualRedactionService.addRecommendation(recommendations, result.redaction, dossierId, fileId); + const request$ = this._manualRedactionService.addRecommendation( + recommendations, + result.redaction, + dossierId, + fileId, + result.bulkLocal, + ); return this.#processObsAndEmit(request$); } diff --git a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts index 630592f99..6186a2b12 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts @@ -49,7 +49,13 @@ export class ManualRedactionService extends GenericService { super(); } - addRecommendation(annotations: AnnotationWrapper[], redaction: IAddRedactionRequest, dossierId: string, fileId: string) { + addRecommendation( + annotations: AnnotationWrapper[], + redaction: IAddRedactionRequest, + dossierId: string, + fileId: string, + bulkLocal: boolean = false, + ) { const recommendations: List = annotations.map(annotation => ({ addToDictionary: redaction.addToDictionary, addToAllDossiers: redaction.addToAllDossiers, @@ -60,7 +66,7 @@ export class ManualRedactionService extends GenericService { type: redaction.type ?? annotation.type, comment: redaction.comment, })); - return this.addAnnotation(recommendations, dossierId, fileId); + return this.addAnnotation(recommendations, dossierId, fileId, { bulkLocal }); } recategorizeRedactions( diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts index 607d21538..976be8626 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts @@ -224,7 +224,6 @@ export class PdfProxyService { const selectedQuads: Record = this._pdf.documentViewer.getSelectedTextQuads(); const text = this._documentViewer.selectedText; const manualRedactionEntry = this.#getManualRedaction(selectedQuads, text, true); - console.log('manualRedactionEntry: ', manualRedactionEntry); this.redactTextRequested$.next({ manualRedactionEntry, type }); } 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 new file mode 100644 index 000000000..25291fd22 --- /dev/null +++ b/apps/red-ui/src/app/modules/file-preview/utils/enhance-manual-redaction-request.utils.ts @@ -0,0 +1,40 @@ +import { Dictionary, IAddRedactionRequest, SuperType } from '@red/domain'; +import { LegalBasisOption } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component'; + +export interface EnhanceRequestData { + readonly type: SuperType | null; + readonly selectedText: string; + readonly reason: LegalBasisOption; + readonly dictionaries: Dictionary[]; + readonly dictionaryRequest: boolean; + readonly comment: string; + readonly isApprover: boolean; + readonly applyToAllDossiers: boolean; +} + +export const enhanceManualRedactionRequest = (addRedactionRequest: IAddRedactionRequest, data: EnhanceRequestData) => { + addRedactionRequest.type = data.type; + addRedactionRequest.section = null; + addRedactionRequest.value = data.selectedText; + + const legalOption: LegalBasisOption = data.reason; + if (legalOption) { + addRedactionRequest.reason = legalOption.description; + addRedactionRequest.legalBasis = legalOption.legalBasis; + } + + const selectedType = data.dictionaries.find(d => d.type === addRedactionRequest.type); + + if (selectedType) { + addRedactionRequest.addToDictionary = selectedType.hasDictionary; + } else { + addRedactionRequest.addToDictionary = data.dictionaryRequest && addRedactionRequest.type !== 'dossier_redaction'; + } + + if (!addRedactionRequest.reason) { + addRedactionRequest.reason = 'Dictionary Request'; + } + const commentValue = data.comment; + addRedactionRequest.comment = commentValue ? { text: commentValue } : null; + addRedactionRequest.addToAllDossiers = data.isApprover && data.dictionaryRequest && data.applyToAllDossiers; +}; diff --git a/libs/red-domain/src/lib/legal-basis/legal-basis-change.request.ts b/libs/red-domain/src/lib/legal-basis/legal-basis-change.request.ts index 1f27f5418..de3e9f2e1 100644 --- a/libs/red-domain/src/lib/legal-basis/legal-basis-change.request.ts +++ b/libs/red-domain/src/lib/legal-basis/legal-basis-change.request.ts @@ -4,5 +4,6 @@ export interface ILegalBasisChangeRequest { annotationId?: string; comment?: string; legalBasis?: string; + reason?: string; option?: ForceAnnotationOption; }