From 629597b751bb562cb2ae8b8db859ce9e9dc6b39b Mon Sep 17 00:00:00 2001 From: Timo Date: Tue, 29 Jun 2021 10:04:02 +0300 Subject: [PATCH] legal basis change model classes --- .../app/models/file/annotation.permissions.ts | 2 +- .../src/app/models/file/annotation.wrapper.ts | 19 ++++++++++-- .../src/app/models/file/file-data.model.ts | 23 +++++++++++++++ .../file/redaction-log-entry.wrapper.ts | 5 +++- .../red-ui/src/app/state/app-state.service.ts | 9 ++++++ .../src/lib/model/manualLegalBasisChange.ts | 29 +++++++++++++++++++ .../src/lib/model/manualRedactions.ts | 2 ++ libs/red-ui-http/src/lib/model/models.ts | 1 + 8 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 libs/red-ui-http/src/lib/model/manualLegalBasisChange.ts diff --git a/apps/red-ui/src/app/models/file/annotation.permissions.ts b/apps/red-ui/src/app/models/file/annotation.permissions.ts index 91077d613..4d350e883 100644 --- a/apps/red-ui/src/app/models/file/annotation.permissions.ts +++ b/apps/red-ui/src/app/models/file/annotation.permissions.ts @@ -1,7 +1,7 @@ import { UserWrapper } from '@services/user.service'; import { AnnotationWrapper } from './annotation.wrapper'; -export class AnnotationPermissions { +export class AnnotationPerimssions { canUndo: boolean; canAcceptRecommendation: boolean; 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 3d399c31e..a133eb48a 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -6,6 +6,7 @@ export class AnnotationWrapper { | 'add-dictionary' | 'remove-dictionary' | 'remove-only-here' + | 'suggestion-change-legal-basis' | 'suggestion-add-dictionary' | 'suggestion-force-redaction' | 'suggestion-remove-dictionary' @@ -55,6 +56,7 @@ export class AnnotationWrapper { this.superType === 'suggestion-add-dictionary' || this.superType === 'suggestion-force-redaction' || this.superType === 'suggestion-remove-dictionary' || + this.superType === 'suggestion-change-legal-basis' || this.superType === 'suggestion-add' || this.superType === 'suggestion-remove' || this.superType === 'skipped' || @@ -155,7 +157,11 @@ export class AnnotationWrapper { } get isSuggestion() { - return this.isSuggestionAdd || this.isSuggestionRemove; + return this.isSuggestionAdd || this.isSuggestionRemove || this.isSuggestionChangeLegalBasis; + } + + get isSuggestionChangeLegalBasis() { + return this.superType === 'suggestion-change-legal-basis'; } get isSuggestionAdd() { @@ -245,6 +251,13 @@ export class AnnotationWrapper { annotationWrapper: AnnotationWrapper, redactionLogEntryWrapper: RedactionLogEntryWrapper ) { + if ( + redactionLogEntryWrapper.legalBasisChangeValue && + redactionLogEntryWrapper.status === 'REQUESTED' + ) { + annotationWrapper.superType = 'suggestion-change-legal-basis'; + } + if (redactionLogEntryWrapper.recommendation) { if (redactionLogEntryWrapper.redacted) { annotationWrapper.superType = 'recommendation'; @@ -356,7 +369,9 @@ export class AnnotationWrapper { if (entry.reason) { content += entry.reason + '\n\n'; } - if (entry.legalBasis) { + if (entry.legalBasisChangeValue) { + content += 'Legal basis:' + entry.legalBasis + '\n\n'; + } else if (entry.legalBasis) { content += 'Legal basis:' + entry.legalBasis + '\n\n'; } if (entry.section) { diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index 94e88ef02..1986cdca3 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -225,6 +225,29 @@ export class FileDataModel { } }); + this.manualRedactions.legalBasisChanges?.forEach(legalBasisChange => { + const relevantRedactionLogEntry = result.find(r => r.id === legalBasisChange.id); + + if (!relevantRedactionLogEntry) { + // idRemove for something that doesn't exist - skip + return; + } else { + relevantRedactionLogEntry.legalBasisChangeValue = legalBasisChange.legalBasis; + + // if statuses differ + if (relevantRedactionLogEntry.status !== legalBasisChange.status) { + relevantRedactionLogEntry.actionPendingReanalysis = true; + relevantRedactionLogEntry.status = legalBasisChange.status; + } + + if (this._hasAlreadyBeenProcessed(legalBasisChange)) { + if (legalBasisChange.status === 'DECLINED') { + relevantRedactionLogEntry.status = null; + } + } + } + }); + result.forEach(redactionLogEntry => { if (redactionLogEntry.manual) { if (redactionLogEntry.manualRedactionType === 'ADD') { diff --git a/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts b/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts index 105363453..128555460 100644 --- a/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts +++ b/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts @@ -1,4 +1,4 @@ -import { Comment, Rectangle } from '@redaction/red-ui-http'; +import { Comment, Rectangle, RedactionLogEntry } from '@redaction/red-ui-http'; export interface RedactionLogEntryWrapper { color?: Array; @@ -34,4 +34,7 @@ export interface RedactionLogEntryWrapper { isChangeLogEntry?: boolean; changeLogType?: 'ADDED' | 'REMOVED'; + + recategorizationType?: string; + legalBasisChangeValue?: string; } diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index 793c2c303..45a9a0fe9 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -559,6 +559,15 @@ export class AppStateService { null, true ); + // add suggestions + dictionaryData['suggestion-change-legal-basis'] = new TypeValueWrapper( + { + hexColor: colors.requestAdd, + type: 'suggestion-change-legal-basis' + }, + null, + true + ); dictionaryData['suggestion-add-dictionary'] = new TypeValueWrapper( { hexColor: colors.dictionaryRequestColor, diff --git a/libs/red-ui-http/src/lib/model/manualLegalBasisChange.ts b/libs/red-ui-http/src/lib/model/manualLegalBasisChange.ts new file mode 100644 index 000000000..f5b7bfe08 --- /dev/null +++ b/libs/red-ui-http/src/lib/model/manualLegalBasisChange.ts @@ -0,0 +1,29 @@ +/** + * API Documentation for Redaction Gateway + * Description for redaction + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +export interface ManualLegalBasisChange { + id?: string; + legalBasis?: string; + processedDate?: string; + requestDate?: string; + status?: ManualLegalBasisChange.StatusEnum; + user?: string; +} + +export namespace ManualLegalBasisChange { + export type StatusEnum = 'APPROVED' | 'DECLINED' | 'REQUESTED'; + export const StatusEnum = { + APPROVED: 'APPROVED' as StatusEnum, + DECLINED: 'DECLINED' as StatusEnum, + REQUESTED: 'REQUESTED' as StatusEnum + }; +} diff --git a/libs/red-ui-http/src/lib/model/manualRedactions.ts b/libs/red-ui-http/src/lib/model/manualRedactions.ts index b2bb862eb..9807ac2e3 100644 --- a/libs/red-ui-http/src/lib/model/manualRedactions.ts +++ b/libs/red-ui-http/src/lib/model/manualRedactions.ts @@ -14,6 +14,7 @@ import { IdRemoval } from './idRemoval'; import { ManualForceRedaction } from './manualForceRedaction'; import { ManualImageRecategorization } from './manualImageRecategorization'; import { ManualRedactionEntry } from './manualRedactionEntry'; +import { ManualLegalBasisChange } from './manualLegalBasisChange'; export interface ManualRedactions { comments?: { [key: string]: Array }; @@ -21,4 +22,5 @@ export interface ManualRedactions { forceRedactions?: Array; idsToRemove?: Array; imageRecategorization?: Array; + legalBasisChanges?: Array; } diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index 84f194d26..234aa0a5c 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -75,3 +75,4 @@ export * from './viewedPagesRequest'; export * from './watermarkModelReq'; export * from './watermarkModelRes'; export * from './legalBasisChangeRequest'; +export * from './manualLegalBasisChange';