fixed .find of undefined manualRedaction

This commit is contained in:
Edi Cziszter 2022-01-30 11:08:07 +02:00
parent 1749cb20c4
commit b94884a09d
2 changed files with 11 additions and 9 deletions

View File

@ -67,6 +67,7 @@ export class AnnotationWrapper {
hasBeenForcedHint: boolean; hasBeenForcedHint: boolean;
hasBeenForcedRedaction: boolean; hasBeenForcedRedaction: boolean;
hasBeenRemovedByManualOverride: boolean; hasBeenRemovedByManualOverride: boolean;
redactionLogEntry: any;
get isChangeLogRemoved() { get isChangeLogRemoved() {
return this.changeLogType === 'REMOVED'; return this.changeLogType === 'REMOVED';
@ -232,7 +233,7 @@ export class AnnotationWrapper {
get legalBasis() { get legalBasis() {
return this.legalBasisChangeValue || this.legalBasisValue; return this.legalBasisChangeValue || this.legalBasisValue;
} }
redactionLogEntry: any;
static fromData(redactionLogEntry?: RedactionLogEntry) { static fromData(redactionLogEntry?: RedactionLogEntry) {
const annotationWrapper = new AnnotationWrapper(); const annotationWrapper = new AnnotationWrapper();
@ -257,22 +258,22 @@ export class AnnotationWrapper {
annotationWrapper.section = redactionLogEntry.section; annotationWrapper.section = redactionLogEntry.section;
annotationWrapper.reference = redactionLogEntry.reference || []; annotationWrapper.reference = redactionLogEntry.reference || [];
annotationWrapper.rectangle = redactionLogEntry.rectangle; annotationWrapper.rectangle = redactionLogEntry.rectangle;
annotationWrapper.hasBeenResized = !!redactionLogEntry.manualChanges.find( annotationWrapper.hasBeenResized = !!redactionLogEntry.manualChanges?.find(
c => c.manualRedactionType === ManualRedactionType.RESIZE && c.annotationStatus === LogEntryStatus.APPROVED, c => c.manualRedactionType === ManualRedactionType.RESIZE && c.annotationStatus === LogEntryStatus.APPROVED,
); );
annotationWrapper.hasBeenRecategorized = !!redactionLogEntry.manualChanges.find( annotationWrapper.hasBeenRecategorized = !!redactionLogEntry.manualChanges?.find(
c => c.manualRedactionType === ManualRedactionType.RECATEGORIZE && c.annotationStatus === LogEntryStatus.APPROVED, c => c.manualRedactionType === ManualRedactionType.RECATEGORIZE && c.annotationStatus === LogEntryStatus.APPROVED,
); );
annotationWrapper.hasLegalBasisChanged = !!redactionLogEntry.manualChanges.find( annotationWrapper.hasLegalBasisChanged = !!redactionLogEntry.manualChanges?.find(
c => c.manualRedactionType === ManualRedactionType.LEGAL_BASIS_CHANGE && c.annotationStatus === LogEntryStatus.APPROVED, c => c.manualRedactionType === ManualRedactionType.LEGAL_BASIS_CHANGE && c.annotationStatus === LogEntryStatus.APPROVED,
); );
annotationWrapper.hasBeenForcedHint = !!redactionLogEntry.manualChanges.find( annotationWrapper.hasBeenForcedHint = !!redactionLogEntry.manualChanges?.find(
c => c.manualRedactionType === ManualRedactionType.FORCE_HINT && c.annotationStatus === LogEntryStatus.APPROVED, c => c.manualRedactionType === ManualRedactionType.FORCE_HINT && c.annotationStatus === LogEntryStatus.APPROVED,
); );
annotationWrapper.hasBeenForcedRedaction = !!redactionLogEntry.manualChanges.find( annotationWrapper.hasBeenForcedRedaction = !!redactionLogEntry.manualChanges?.find(
c => c.manualRedactionType === ManualRedactionType.FORCE_REDACT && c.annotationStatus === LogEntryStatus.APPROVED, c => c.manualRedactionType === ManualRedactionType.FORCE_REDACT && c.annotationStatus === LogEntryStatus.APPROVED,
); );
annotationWrapper.hasBeenRemovedByManualOverride = !!redactionLogEntry.manualChanges.find( annotationWrapper.hasBeenRemovedByManualOverride = !!redactionLogEntry.manualChanges?.find(
c => c.manualRedactionType === ManualRedactionType.REMOVE_LOCALLY && c.annotationStatus === LogEntryStatus.APPROVED, c => c.manualRedactionType === ManualRedactionType.REMOVE_LOCALLY && c.annotationStatus === LogEntryStatus.APPROVED,
); );
@ -297,7 +298,7 @@ export class AnnotationWrapper {
return; return;
} }
if (redactionLogEntryWrapper.manualChanges.length) { if (redactionLogEntryWrapper.manualChanges?.length) {
const lastManualChange = redactionLogEntryWrapper.manualChanges[redactionLogEntryWrapper.manualChanges.length - 1]; const lastManualChange = redactionLogEntryWrapper.manualChanges[redactionLogEntryWrapper.manualChanges.length - 1];
annotationWrapper.pending = !lastManualChange.processed; annotationWrapper.pending = !lastManualChange.processed;
@ -375,6 +376,7 @@ export class AnnotationWrapper {
case LogEntryStatus.REQUESTED: case LogEntryStatus.REQUESTED:
return 'suggestion-add'; return 'suggestion-add';
} }
break;
case ManualRedactionType.ADD_TO_DICTIONARY: case ManualRedactionType.ADD_TO_DICTIONARY:
switch (lastManualChange.annotationStatus) { switch (lastManualChange.annotationStatus) {
case LogEntryStatus.APPROVED: case LogEntryStatus.APPROVED:

View File

@ -105,7 +105,7 @@ export class FileDataModel {
); );
if ( if (
redactionLogEntry.manualChanges.find( redactionLogEntry.manualChanges?.find(
mc => mc =>
mc.manualRedactionType === ManualRedactionType.ADD_TO_DICTIONARY && mc.manualRedactionType === ManualRedactionType.ADD_TO_DICTIONARY &&
(mc.annotationStatus === LogEntryStatus.APPROVED || mc.annotationStatus === LogEntryStatus.REQUESTED), (mc.annotationStatus === LogEntryStatus.APPROVED || mc.annotationStatus === LogEntryStatus.REQUESTED),