From 11e6c292b17f5aefc745948d93e9464d4a86bf5c Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Mon, 25 Apr 2022 10:33:06 +0300 Subject: [PATCH] RED-3343 - replace reason legacy with sourceId --- .../app/models/file/redaction-log.entry.ts | 2 + .../services/annotation-actions.service.ts | 2 +- .../services/file-data.service.ts | 44 ++++--------------- .../services/manual-redaction.service.ts | 3 +- libs/common-ui | 2 +- .../lib/redaction-log/redaction-log-entry.ts | 1 + 6 files changed, 14 insertions(+), 40 deletions(-) diff --git a/apps/red-ui/src/app/models/file/redaction-log.entry.ts b/apps/red-ui/src/app/models/file/redaction-log.entry.ts index e0b358d78..361d1e347 100644 --- a/apps/red-ui/src/app/models/file/redaction-log.entry.ts +++ b/apps/red-ui/src/app/models/file/redaction-log.entry.ts @@ -29,6 +29,7 @@ export class RedactionLogEntry implements IRedactionLogEntry { readonly textBefore?: string; readonly type?: string; readonly value?: string; + readonly sourceId?: string; reason?: string; @@ -69,5 +70,6 @@ export class RedactionLogEntry implements IRedactionLogEntry { this.type = redactionLogEntry.type; this.value = redactionLogEntry.value; this.imported = redactionLogEntry.imported; + this.sourceId = redactionLogEntry.sourceId; } } 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 2758d5147..ecfa0dd0d 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 @@ -446,7 +446,7 @@ export class AnnotationActionsService { $event?.stopPropagation(); const requests: List = annotations.map(annotation => ({ - reason: annotation.id, + sourceId: annotation.id, value: this._getFalsePositiveText(annotation), type: annotation.type, positions: annotation.positions, diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts index 72562c3cf..668ec4252 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts @@ -1,14 +1,4 @@ -import { - ChangeType, - File, - IRedactionLog, - IRedactionLogEntry, - IViewedPage, - LogEntryStatus, - ManualRedactionType, - ViewMode, - ViewModes, -} from '@red/domain'; +import { ChangeType, File, IRedactionLog, IRedactionLogEntry, IViewedPage, ViewMode, ViewModes } from '@red/domain'; import { AnnotationWrapper } from '../../../models/file/annotation.wrapper'; import { BehaviorSubject, firstValueFrom, iif, Observable, Subject } from 'rxjs'; import { RedactionLogEntry } from '../../../models/file/redaction-log.entry'; @@ -179,7 +169,7 @@ export class FileDataService extends EntitiesService { #convertData(redactionLog: IRedactionLog, file: File): RedactionLogEntry[] { let result: RedactionLogEntry[] = []; - const reasonAnnotationIds: { [key: string]: RedactionLogEntry[] } = {}; + const sourceIdAnnotationIds: { [key: string]: RedactionLogEntry[] } = {}; const dictionaries = this._dictionariesMapService.get(this._state.dossierTemplateId); redactionLog.redactionLogEntry?.forEach(redactionLogEntry => { @@ -199,36 +189,18 @@ export class FileDataService extends EntitiesService { !!dictionary?.hint, ); - if ( - redactionLogEntry.manualChanges?.find( - mc => - mc.manualRedactionType === ManualRedactionType.ADD_TO_DICTIONARY && - (mc.annotationStatus === LogEntryStatus.APPROVED || mc.annotationStatus === LogEntryStatus.REQUESTED), - ) - ) { - // for dictionary entries -> I.E accepted recommendations or false positives, - // check reason - if (!reasonAnnotationIds[redactionLogEntry.reason]) { - reasonAnnotationIds[redactionLogEntry.reason] = [redactionLogEntryWrapper]; - } else { - reasonAnnotationIds[redactionLogEntry.reason].push(redactionLogEntryWrapper); + if (redactionLogEntry.sourceId) { + if (!sourceIdAnnotationIds[redactionLogEntry.sourceId]) { + sourceIdAnnotationIds[redactionLogEntry.sourceId] = []; } + sourceIdAnnotationIds[redactionLogEntry.sourceId].push(redactionLogEntryWrapper); } result.push(redactionLogEntryWrapper); }); - const reasonKeys = Object.keys(reasonAnnotationIds); - result = result.filter(r => { - const matched = reasonKeys.indexOf(r.id) >= 0; - if (matched) { - reasonAnnotationIds[r.id].forEach(value => { - value.reason = null; - }); - } - return !matched; - }); - + const sourceKeys = Object.keys(sourceIdAnnotationIds); + result = result.filter(r => !sourceKeys.includes(r.id)); result = result.filter(r => !r.hidden); return result; 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 23d07b31b..db02425c3 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 @@ -66,8 +66,7 @@ export class ManualRedactionService extends GenericService { addRecommendation(annotations: AnnotationWrapper[], dossierId: string, fileId: string, comment = { text: 'Accepted Recommendation' }) { const recommendations: List = annotations.map(annotation => ({ addToDictionary: true, - // set the ID as reason, so we can hide the suggestion - reason: annotation.annotationId, + sourceId: annotation.annotationId, value: annotation.value, positions: annotation.positions, type: annotation.recommendationType, diff --git a/libs/common-ui b/libs/common-ui index fd9d62241..d8c2a342b 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit fd9d622413547de842439e8d91ee4316f2facff1 +Subproject commit d8c2a342baa6acb330132c44000562bdd823f620 diff --git a/libs/red-domain/src/lib/redaction-log/redaction-log-entry.ts b/libs/red-domain/src/lib/redaction-log/redaction-log-entry.ts index 04774547b..24a55fdef 100644 --- a/libs/red-domain/src/lib/redaction-log/redaction-log-entry.ts +++ b/libs/red-domain/src/lib/redaction-log/redaction-log-entry.ts @@ -34,4 +34,5 @@ export interface IRedactionLogEntry { textBefore?: string; type?: string; value?: string; + sourceId?: string; }