RED-3343 - replace reason legacy with sourceId

This commit is contained in:
Timo Bejan 2022-04-25 10:33:06 +03:00
parent 1df0ced12d
commit 11e6c292b1
6 changed files with 14 additions and 40 deletions

View File

@ -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;
}
}

View File

@ -446,7 +446,7 @@ export class AnnotationActionsService {
$event?.stopPropagation();
const requests: List<IAddRedactionRequest> = annotations.map(annotation => ({
reason: annotation.id,
sourceId: annotation.id,
value: this._getFalsePositiveText(annotation),
type: annotation.type,
positions: annotation.positions,

View File

@ -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<AnnotationWrapper> {
#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<AnnotationWrapper> {
!!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;

View File

@ -66,8 +66,7 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
addRecommendation(annotations: AnnotationWrapper[], dossierId: string, fileId: string, comment = { text: 'Accepted Recommendation' }) {
const recommendations: List<IAddRedactionRequest> = 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,

@ -1 +1 @@
Subproject commit fd9d622413547de842439e8d91ee4316f2facff1
Subproject commit d8c2a342baa6acb330132c44000562bdd823f620

View File

@ -34,4 +34,5 @@ export interface IRedactionLogEntry {
textBefore?: string;
type?: string;
value?: string;
sourceId?: string;
}