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 f6ebdd5f3..8714d1fe9 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -9,8 +9,10 @@ import { Dictionary, Earmark, EntityTypes, + EntryState, EntryStates, FalsePositiveSuperTypes, + IEntityLog, IEntityLogEntry, ILegalBasis, IPoint, @@ -65,6 +67,7 @@ export class AnnotationWrapper implements IListable { isRemoved = false; isRemovedLocally = false; lastManualChange: ManualRedactionType; + oldState: EntryState; get isRuleBased() { return this.engines.includes(LogEntryEngines.RULE); @@ -209,6 +212,7 @@ export class AnnotationWrapper implements IListable { static fromData( logEntry: IEntityLogEntry, + allLogEntries: IEntityLogEntry[], dictionary: Dictionary, changeLogType: ChangeType, legalBasisList: ILegalBasis[], @@ -268,7 +272,13 @@ export class AnnotationWrapper implements IListable { const lastRelevantManualChange = logEntry.manualChanges?.at(-1); annotationWrapper.lastManualChange = lastRelevantManualChange?.manualRedactionType; - annotationWrapper.pending = lastRelevantManualChange && !lastRelevantManualChange.processed; + annotationWrapper.pending = logEntry.state === EntryStates.PENDING; + if (annotationWrapper.pending) { + const removedEntry = allLogEntries.find( + (e: IEntityLogEntry) => e.id === annotationWrapper.id && e.state === EntryStates.REMOVED, + ); + logEntry.oldState = removedEntry?.state; + } annotationWrapper.superType = SuperTypeMapper[logEntry.entryType][logEntry.state](logEntry); annotationWrapper.superTypeLabel = annotationTypesTranslations[annotationWrapper.superType]; diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html index 99c2ed520..50a482417 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html @@ -10,7 +10,7 @@
{{ annotation.superTypeLabel | translate }}   - + {{ 'annotation.pending' | translate }}
diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.ts index f62a1a538..322593075 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.ts @@ -18,17 +18,4 @@ export class AnnotationCardComponent { @Input() isSelected = false; constructor(readonly multiSelectService: MultiSelectService) {} - - get pending() { - return ( - this.annotation.pending && - ((this.annotation.isModifyDictionary && - !this.annotation.isRemovedLocally && - !this.annotation.hasBeenForcedHint && - this.annotation.lastManualChange !== ManualRedactionTypes.LEGAL_BASIS_CHANGE && - this.annotation.lastManualChange !== ManualRedactionTypes.RESIZE_LOCALLY) || - this.annotation.type === ImageCategory.SIGNATURE || - this.annotation.IMAGE_HINT) - ); - } } diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-details/annotation-details.component.scss b/apps/red-ui/src/app/modules/file-preview/components/annotation-details/annotation-details.component.scss index 1110e38ca..8a2928722 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-details/annotation-details.component.scss +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-details/annotation-details.component.scss @@ -6,7 +6,6 @@ } .popover { - width: 260px; padding: 10px; border-radius: 3px; background-color: var(--iqser-grey-1); 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 2bf2a4e8a..6bc632504 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 @@ -226,6 +226,7 @@ export class FileDataService extends EntitiesService; +interface ResolveTypeOptions { + hint: boolean; + pending: boolean; +} + function wrongSuperTypeHandler(): never | undefined { return undefined; } -function resolveRedactionType(entry: IEntityLogEntry, hint = false) { - const redaction = hint ? SuperTypes.Hint : SuperTypes.Redaction; - const manualRedaction = hint ? SuperTypes.ManualHint : SuperTypes.ManualRedaction; +function resolveRedactionType(entry: IEntityLogEntry, options?: Partial) { + if (options?.pending && entry.oldState) { + return SuperTypeMapper[entry.entryType][entry.oldState](entry); + } - const manualChanges = entry.manualChanges; - const hasEngines = entry.engines.length; - const lastRelevantManualChange = manualChanges?.at(-1); - if (!!lastRelevantManualChange && !hasEngines) { - const pending = lastRelevantManualChange && !lastRelevantManualChange.processed; - if (pending && entry.dictionaryEntry) { - return redaction; - } - return manualRedaction; + const redaction = options?.hint ? SuperTypes.Hint : SuperTypes.Redaction; + const manualRedaction = options?.hint ? SuperTypes.ManualHint : SuperTypes.ManualRedaction; + + if (!entry.engines.length) { + return options?.pending && entry.dictionaryEntry ? redaction : manualRedaction; } return redaction; } @@ -44,48 +46,56 @@ export const SuperTypeMapper: Record SuperTypes.Skipped, [EntryStates.IGNORED]: () => SuperTypes.Skipped, [EntryStates.REMOVED]: wrongSuperTypeHandler, + [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), }, [EntityTypes.HINT]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, - [EntryStates.SKIPPED]: entry => resolveRedactionType(entry, true), + [EntryStates.SKIPPED]: entry => resolveRedactionType(entry, { hint: true }), [EntryStates.IGNORED]: () => SuperTypes.IgnoredHint, [EntryStates.REMOVED]: wrongSuperTypeHandler, + [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), }, [EntityTypes.FALSE_POSITIVE]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: wrongSuperTypeHandler, [EntryStates.IGNORED]: wrongSuperTypeHandler, [EntryStates.REMOVED]: wrongSuperTypeHandler, + [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), }, [EntityTypes.RECOMMENDATION]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: () => SuperTypes.Recommendation, [EntryStates.IGNORED]: wrongSuperTypeHandler, [EntryStates.REMOVED]: wrongSuperTypeHandler, + [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), }, [EntityTypes.FALSE_RECOMMENDATION]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: wrongSuperTypeHandler, [EntryStates.IGNORED]: wrongSuperTypeHandler, [EntryStates.REMOVED]: wrongSuperTypeHandler, + [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), }, [EntityTypes.AREA]: { [EntryStates.APPLIED]: () => SuperTypes.Redaction, [EntryStates.SKIPPED]: wrongSuperTypeHandler, [EntryStates.IGNORED]: wrongSuperTypeHandler, [EntryStates.REMOVED]: wrongSuperTypeHandler, + [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), }, [EntityTypes.IMAGE]: { [EntryStates.APPLIED]: () => SuperTypes.Redaction, [EntryStates.SKIPPED]: () => SuperTypes.Skipped, [EntryStates.IGNORED]: () => SuperTypes.Skipped, [EntryStates.REMOVED]: wrongSuperTypeHandler, + [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), }, [EntityTypes.IMAGE_HINT]: { [EntryStates.APPLIED]: wrongSuperTypeHandler, [EntryStates.SKIPPED]: () => SuperTypes.Hint, [EntryStates.IGNORED]: () => SuperTypes.IgnoredHint, [EntryStates.REMOVED]: wrongSuperTypeHandler, + [EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }), }, }; diff --git a/libs/red-domain/src/lib/redaction-log/entity-log-entry.ts b/libs/red-domain/src/lib/redaction-log/entity-log-entry.ts index 21d94933f..2efa68491 100644 --- a/libs/red-domain/src/lib/redaction-log/entity-log-entry.ts +++ b/libs/red-domain/src/lib/redaction-log/entity-log-entry.ts @@ -14,6 +14,7 @@ export interface IEntityLogEntry extends ITrackable { type: string; entryType: EntityType; state: EntryState; + oldState?: EntryState; value: string; reason: string; matchedRule: string; diff --git a/libs/red-domain/src/lib/redaction-log/entity-states.ts b/libs/red-domain/src/lib/redaction-log/entity-states.ts index 2507f1bdb..60725eef0 100644 --- a/libs/red-domain/src/lib/redaction-log/entity-states.ts +++ b/libs/red-domain/src/lib/redaction-log/entity-states.ts @@ -3,6 +3,7 @@ export const EntryStates = { SKIPPED: 'SKIPPED', IGNORED: 'IGNORED', REMOVED: 'REMOVED', + PENDING: 'PENDING', } as const; export type EntryState = (typeof EntryStates)[keyof typeof EntryStates];