From 54b59ab90c8f726abb38a42cc2ecfb2d8fe02b37 Mon Sep 17 00:00:00 2001 From: Maverick Studer Date: Wed, 20 Nov 2024 10:38:27 +0100 Subject: [PATCH] RED-10115: Refactoring of justifications --- apps/red-ui/src/app/models/file/annotation.wrapper.ts | 2 +- .../dialogs/add-hint-dialog/add-hint-dialog.component.ts | 2 +- .../change-legal-basis-dialog.component.ts | 5 +++-- .../edit-redaction-dialog.component.ts | 9 +++++---- .../force-annotation-dialog.component.ts | 5 +++-- .../rectangle-annotation-dialog.component.ts | 3 ++- .../redact-recommendation-dialog.component.ts | 1 + .../redact-text-dialog/redact-text-dialog.component.ts | 3 ++- .../src/app/modules/file-preview/utils/dialog-types.ts | 1 + .../utils/enhance-manual-redaction-request.utils.ts | 2 +- apps/red-ui/src/assets/config/config.json | 4 ++-- libs/red-domain/src/lib/files/file.model.ts | 2 +- 12 files changed, 23 insertions(+), 16 deletions(-) diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index c9e838137..de9d41047 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -378,7 +378,7 @@ export class AnnotationWrapper implements IListable { static #getShortContent(annotationWrapper: AnnotationWrapper, legalBasisList: ILegalBasis[]) { if (annotationWrapper.legalBasis) { - const lb = legalBasisList.find(lbm => lbm.reason?.toLowerCase().includes(annotationWrapper.legalBasis.toLowerCase())); + const lb = legalBasisList.find(lbm => lbm.technicalName?.toLowerCase().includes(annotationWrapper.legalBasis.toLowerCase())); if (lb) { return lb.name; } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts index 35c614eb4..ecff2af4c 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts @@ -130,7 +130,7 @@ export class AddHintDialogComponent extends IqserDialogComponent(lbm => ({ + technicalName: lbm.technicalName, legalBasis: lbm.reason, description: lbm.description, label: lbm.name, @@ -60,14 +61,14 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme .sort((a, b) => a.label.localeCompare(b.label)); this.form.patchValue({ - reason: this.legalOptions.find(option => option.legalBasis === this._data.annotations[0].legalBasis), + reason: this.legalOptions.find(option => option.technicalName === this._data.annotations[0].legalBasis), }); this.initialFormValue = this.form.getRawValue(); } save() { this._dialogRef.close({ - legalBasis: this.form.get('reason').value.legalBasis, + legalBasis: this.form.get('reason').value.technicalName, section: this.form.get('section').value, comment: this.form.get('comment').value, value: this.form.get('classification').value, 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 b90c2de37..fafa9fb64 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 @@ -177,13 +177,14 @@ export class EditRedactionDialogComponent this.#setTypes(); const data = await firstValueFrom(this._justificationsService.loadAll(this.#dossier.dossierTemplateId)); this.legalOptions = data.map(lbm => ({ + technicalName: lbm.technicalName, legalBasis: lbm.reason, description: lbm.description, label: lbm.name, })); - const reason = this.legalOptions.find(o => o.legalBasis === this.annotations[0].legalBasis); - const sameLegalBasis = this.annotations.every(annotation => annotation.legalBasis === reason?.legalBasis); + const reason = this.legalOptions.find(o => o.technicalName === this.annotations[0].legalBasis); + const sameLegalBasis = this.annotations.every(annotation => annotation.legalBasis === reason?.technicalName); this.form.patchValue({ reason: sameLegalBasis ? reason : null, }); @@ -213,12 +214,12 @@ export class EditRedactionDialogComponent save() { const value = this.form.value; const initialReason: LegalBasisOption = this.initialFormValue.reason; - const initialLegalBasis = initialReason?.legalBasis ?? ''; + const initialLegalBasis = initialReason?.technicalName ?? ''; const pageNumbers = parseSelectedPageNumbers(this.form.get('option').value?.additionalInput?.value, this.data.file); const position = parseRectanglePosition(this.annotations[0]); this.close({ - legalBasis: value.reason?.legalBasis ?? (this.isImage ? initialLegalBasis : ''), + legalBasis: value.reason?.technicalName ?? (this.isImage ? initialLegalBasis : ''), section: value.section, comment: value.comment, type: value.type, 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 7b87874ef..c27546dd0 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 @@ -110,6 +110,7 @@ export class ForceAnnotationDialogComponent const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.data.dossier.dossierTemplateId)); this.legalOptions = data.map(lbm => ({ + technicalName: lbm.technicalName, legalBasis: lbm.reason, description: lbm.description, label: lbm.name, @@ -118,7 +119,7 @@ export class ForceAnnotationDialogComponent this.legalOptions.sort((a, b) => a.label.localeCompare(b.label)); // Set pre-existing reason if it exists - const existingReason = this.legalOptions.find(option => option.legalBasis === this.data.annotations[0].legalBasis); + const existingReason = this.legalOptions.find(option => option.technicalName === this.data.annotations[0].legalBasis); if (!this.data.hint && existingReason) { this.form.patchValue({ reason: existingReason }, { emitEvent: false }); } @@ -141,7 +142,7 @@ export class ForceAnnotationDialogComponent #createForceRedactionRequest(): ILegalBasisChangeRequest { const request: ILegalBasisChangeRequest = {}; - request.legalBasis = !this.isDocumine ? this.form.get('reason').value.legalBasis : DOCUMINE_LEGAL_BASIS; + request.legalBasis = !this.isDocumine ? this.form.get('reason').value.technicalName : 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; 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 fdbc7c7ed..c18e99f7d 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 @@ -100,6 +100,7 @@ export class RectangleAnnotationDialog async ngOnInit() { const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.#dossier.dossierTemplateId)); this.legalOptions = data.map(lbm => ({ + technicalName: lbm.technicalName, legalBasis: lbm.reason, description: lbm.description, label: lbm.name, @@ -139,7 +140,7 @@ export class RectangleAnnotationDialog addRedactionRequest.type = SuperTypes.ManualRedaction; if (legalOption) { addRedactionRequest.reason = legalOption.description; - addRedactionRequest.legalBasis = legalOption.legalBasis; + addRedactionRequest.legalBasis = legalOption.technicalName; } addRedactionRequest.addToDictionary = false; 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 479dd7820..c98b44dad 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 @@ -122,6 +122,7 @@ export class RedactRecommendationDialogComponent this.#setDictionaries(); const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.#dossier.dossierTemplateId)); this.legalOptions = data.map(lbm => ({ + technicalName: lbm.technicalName, legalBasis: lbm.reason, description: lbm.description, label: lbm.name, 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 41a32a1fd..e65ef165f 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 @@ -138,13 +138,14 @@ export class RedactTextDialogComponent get applyToAll() { return this.isSystemDefault || this._userPreferences.getAddRedactionDefaultExtraOption() === 'undefined' - ? (this.data.applyToAllDossiers ?? true) + ? this.data.applyToAllDossiers ?? true : stringToBoolean(this._userPreferences.getAddRedactionDefaultExtraOption()); } async ngOnInit(): Promise { const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.#dossier.dossierTemplateId)); this.legalOptions = data.map(lbm => ({ + technicalName: lbm.technicalName, legalBasis: lbm.reason, description: lbm.description, label: lbm.name, 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 229b0639f..05b705e84 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 @@ -51,6 +51,7 @@ export interface LegalBasisOption { label?: string; legalBasis?: string; description?: string; + technicalName?: string; } export interface RedactTextData { 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 4930abc31..842f5a066 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 @@ -30,7 +30,7 @@ export const enhanceManualRedactionRequest = (addRedactionRequest: IAddRedaction const legalOption: LegalBasisOption = data.reason; if (legalOption) { addRedactionRequest.reason = legalOption.description; - addRedactionRequest.legalBasis = legalOption.legalBasis; + addRedactionRequest.legalBasis = legalOption.technicalName; } const selectedType = data.dictionaries.find(d => d.type === addRedactionRequest.type); diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index deb14e6da..202f3b9b8 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,7 +1,7 @@ { "ADMIN_CONTACT_NAME": null, "ADMIN_CONTACT_URL": null, - "API_URL": "https://dan1.iqser.cloud", + "API_URL": "https://maverick2.iqser.cloud", "APP_NAME": "RedactManager", "IS_DOCUMINE": false, "RULE_EDITOR_DEV_ONLY": false, @@ -13,7 +13,7 @@ "MAX_RETRIES_ON_SERVER_ERROR": 3, "OAUTH_CLIENT_ID": "redaction", "OAUTH_IDP_HINT": null, - "OAUTH_URL": "https://dan1.iqser.cloud/auth", + "OAUTH_URL": "https://maverick2.iqser.cloud/auth", "RECENT_PERIOD_IN_HOURS": 24, "SELECTION_MODE": "structural", "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview", diff --git a/libs/red-domain/src/lib/files/file.model.ts b/libs/red-domain/src/lib/files/file.model.ts index 49f1e5e4d..eae5d8af1 100644 --- a/libs/red-domain/src/lib/files/file.model.ts +++ b/libs/red-domain/src/lib/files/file.model.ts @@ -124,7 +124,7 @@ export class File extends Entity implements IFile { this.workflowStatus = file.workflowStatus; this.isError = this.processingStatus === ProcessingFileStatuses.ERROR; this.isUnprocessed = this.processingStatus === ProcessingFileStatuses.UNPROCESSED; - this.numberOfPages = this.isError ? 0 : (file.numberOfPages ?? 0); + this.numberOfPages = this.isError ? 0 : file.numberOfPages ?? 0; this.rulesVersion = file.rulesVersion; this.uploader = file.uploader; this.excludedPages = file.excludedPages || [];