From 4a30d9b3f3aba0568c92729dad5c8f3b17290be5 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Wed, 10 Nov 2021 09:25:17 +0200 Subject: [PATCH] rework annotation types --- .../src/app/models/file/annotation.wrapper.ts | 26 ++++++++++------- .../file/redaction-log-entry.wrapper.ts | 2 +- .../type-filter/type-filter.component.ts | 9 +----- .../red-ui/src/app/state/app-state.service.ts | 28 +++++++++---------- .../annotation-types-translations.ts | 3 +- .../app/utils/sorters/super-type-sorter.ts | 3 +- apps/red-ui/src/assets/i18n/de.json | 3 -- apps/red-ui/src/assets/i18n/en.json | 3 +- 8 files changed, 34 insertions(+), 43 deletions(-) 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 81603ade5..214119cb4 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -5,13 +5,13 @@ import { IComment, IPoint, IRectangle } from '@red/domain'; export type AnnotationSuperType = | 'add-dictionary' - | 'remove-dictionary' | 'remove-only-here' | 'change-legal-basis' | 'suggestion-change-legal-basis' | 'suggestion-recategorize-image' | 'suggestion-add-dictionary' | 'suggestion-force-redaction' + | 'suggestion-resize' | 'suggestion-remove-dictionary' | 'suggestion-add' | 'suggestion-remove' @@ -20,7 +20,6 @@ export type AnnotationSuperType = | 'manual-redaction' | 'recommendation' | 'hint' - | 'pending-analysis' | 'declined-suggestion'; export class AnnotationWrapper { @@ -122,13 +121,7 @@ export class AnnotationWrapper { } get isReadyForAnalysis() { - return ( - this.superType === 'add-dictionary' || - this.superType === 'remove-dictionary' || - this.superType === 'remove-only-here' || - this.superType === 'pending-analysis' || - this.superType === 'change-legal-basis' - ); + return this.superType === 'add-dictionary' || this.superType === 'remove-only-here' || this.superType === 'change-legal-basis'; } get isApproved() { @@ -246,6 +239,13 @@ export class AnnotationWrapper { return; } + if (redactionLogEntryWrapper.manualRedactionType === 'RESIZE') { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-resize'; + return; + } + } + if (redactionLogEntryWrapper.manualRedactionType === 'FORCE_REDACT') { annotationWrapper.force = true; @@ -371,7 +371,13 @@ export class AnnotationWrapper { if (redactionLogEntryWrapper.status === 'APPROVED') { if (redactionLogEntryWrapper.dictionaryEntry) { annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' ? 'add-dictionary' : 'remove-dictionary'; + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'add-dictionary' + : annotationWrapper.redaction + ? 'redaction' + : annotationWrapper.hint + ? 'hint' + : 'skipped'; } else { annotationWrapper.superType = redactionLogEntryWrapper.manualRedactionType === 'ADD' ? 'manual-redaction' : 'remove-only-here'; 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 251b5bd77..72a70f608 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 @@ -17,7 +17,7 @@ export interface RedactionLogEntryWrapper { id?: string; legalBasis?: string; manual?: boolean; - manualRedactionType?: 'ADD' | 'REMOVE' | 'UNDO' | 'LEGAL_BASIS_CHANGE' | 'FORCE_REDACT' | 'RECATEGORIZE'; + manualRedactionType?: 'ADD' | 'REMOVE' | 'LEGAL_BASIS_CHANGE' | 'FORCE_REDACT' | 'RECATEGORIZE' | 'RESIZE'; matchedRule?: number; positions?: Array; reason?: string; diff --git a/apps/red-ui/src/app/modules/shared/components/type-filter/type-filter.component.ts b/apps/red-ui/src/app/modules/shared/components/type-filter/type-filter.component.ts index 7f1510892..b4b93f47b 100644 --- a/apps/red-ui/src/app/modules/shared/components/type-filter/type-filter.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/type-filter/type-filter.component.ts @@ -20,14 +20,7 @@ export class TypeFilterComponent implements OnInit { 'suggestion-remove-dictionary', 'suggestion-add-dictionary', ]; - private _needsAnalysisKeys = [ - 'add-dictionary', - 'remove-dictionary', - 'remove-only-here', - 'pending-analysis', - 'change-legal-basis', - 'analysis', - ]; + private _needsAnalysisKeys = ['add-dictionary', 'remove-only-here', 'change-legal-basis', 'analysis']; constructor(private readonly _appStateService: AppStateService) {} 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 95323132d..fa713d60c 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -338,6 +338,7 @@ export class AppStateService { }, true, ); + // dictionary actions dictionaryData['add-dictionary'] = new Dictionary( { @@ -346,13 +347,7 @@ export class AppStateService { }, true, ); - dictionaryData['remove-dictionary'] = new Dictionary( - { - hexColor: colors.analysisColor || FALLBACK_COLOR, - type: 'remove-dictionary', - }, - true, - ); + dictionaryData['remove-only-here'] = new Dictionary( { hexColor: colors.analysisColor || FALLBACK_COLOR, @@ -376,6 +371,7 @@ export class AppStateService { }, true, ); + // add suggestions dictionaryData['suggestion-change-legal-basis'] = new Dictionary( { @@ -384,6 +380,7 @@ export class AppStateService { }, true, ); + dictionaryData['suggestion-recategorize-image'] = new Dictionary( { hexColor: colors.requestAdd || FALLBACK_COLOR, @@ -391,6 +388,7 @@ export class AppStateService { }, true, ); + dictionaryData['suggestion-add-dictionary'] = new Dictionary( { hexColor: colors.dictionaryRequestColor || FALLBACK_COLOR, @@ -399,6 +397,14 @@ export class AppStateService { true, ); + dictionaryData['suggestion-resize'] = new Dictionary( + { + hexColor: colors.dictionaryRequestColor || FALLBACK_COLOR, + type: 'suggestion-resize', + }, + true, + ); + dictionaryData['suggestion-remove'] = new Dictionary( { hexColor: colors.requestRemove || FALLBACK_COLOR, @@ -447,14 +453,6 @@ export class AppStateService { true, ); - dictionaryData['pending-analysis'] = new Dictionary( - { - hexColor: colors.analysisColor || FALLBACK_COLOR, - type: 'analysis', - }, - true, - ); - dictionaryData['change-legal-basis'] = new Dictionary( { hexColor: colors.analysisColor || FALLBACK_COLOR, diff --git a/apps/red-ui/src/app/translations/annotation-types-translations.ts b/apps/red-ui/src/app/translations/annotation-types-translations.ts index a65bb59f3..3ef4a04c2 100644 --- a/apps/red-ui/src/app/translations/annotation-types-translations.ts +++ b/apps/red-ui/src/app/translations/annotation-types-translations.ts @@ -7,10 +7,8 @@ export const annotationTypesTranslations: { [key in AnnotationSuperType]: string 'declined-suggestion': _('annotation-type.declined-suggestion'), hint: _('annotation-type.hint'), 'manual-redaction': _('annotation-type.manual-redaction'), - 'pending-analysis': _('annotation-type.pending-analysis'), recommendation: _('annotation-type.recommendation'), redaction: _('annotation-type.redaction'), - 'remove-dictionary': _('annotation-type.remove-dictionary'), 'remove-only-here': _('annotation-type.remove-only-here'), skipped: _('annotation-type.skipped'), 'suggestion-add': _('annotation-type.suggestion-add'), @@ -20,4 +18,5 @@ export const annotationTypesTranslations: { [key in AnnotationSuperType]: string 'suggestion-force-redaction': _('annotation-type.suggestion-force-redaction'), 'suggestion-remove': _('annotation-type.suggestion-remove'), 'suggestion-remove-dictionary': _('annotation-type.suggestion-remove-dictionary'), + 'suggestion-resize': _('annotation-type.suggestion-resize'), } as const; diff --git a/apps/red-ui/src/app/utils/sorters/super-type-sorter.ts b/apps/red-ui/src/app/utils/sorters/super-type-sorter.ts index 87793d0dc..23e30bb4e 100644 --- a/apps/red-ui/src/app/utils/sorters/super-type-sorter.ts +++ b/apps/red-ui/src/app/utils/sorters/super-type-sorter.ts @@ -4,10 +4,9 @@ export const SuperTypeSorter: { [key in AnnotationSuperType]: number } = { 'suggestion-change-legal-basis': 14, 'suggestion-force-redaction': 15, 'suggestion-recategorize-image': 16, + 'suggestion-resize': 18, recommendation: 7, 'add-dictionary': 2, - 'remove-dictionary': 3, - 'pending-analysis': 4, 'change-legal-basis': 5, 'remove-only-here': 6, 'suggestion-add-dictionary': 12, diff --git a/apps/red-ui/src/assets/i18n/de.json b/apps/red-ui/src/assets/i18n/de.json index 5cc369317..a35b78738 100644 --- a/apps/red-ui/src/assets/i18n/de.json +++ b/apps/red-ui/src/assets/i18n/de.json @@ -278,10 +278,8 @@ "declined-suggestion": "Abgelehnter Vorschlag", "hint": "Hinweis", "manual-redaction": "Manuelle Schwärzung", - "pending-analysis": "Reanalyse ausstehend", "recommendation": "Empfehlung", "redaction": "Schwärzung", - "remove-dictionary": "Ausstehende Löschung aus dem Wörterbuch", "remove-only-here": "Ausstehende Löschung (nur hier)", "skipped": "Übersprungen", "suggestion-add": "Vorschlag für Schwärzung", @@ -1792,7 +1790,6 @@ "redactions": "Schwärzungs-Wörterbücher" }, "OCR_PROCESSING": "OCR-Analyse", - "pending-analysis": "Reanalyse ausstehend", "PROCESSING": "Wird analysiert", "report": { "action": { diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index d5758f534..f8ec73164 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -263,15 +263,14 @@ "rule": "Redaction based on rule {rule}" }, "annotation-type": { + "suggestion-resize": "Suggested Resize", "add-dictionary": "Pending add to dictionary", "change-legal-basis": "Pending Change of Legal Basis", "declined-suggestion": "Declined Suggestion", "hint": "Hint", "manual-redaction": "Manual Redaction", - "pending-analysis": "Pending Re-Analysis", "recommendation": "Recommendation", "redaction": "Redaction", - "remove-dictionary": "Pending remove from dictionary", "remove-only-here": "Pending removal ( only here )", "skipped": "Skipped", "suggestion-add": "Suggested redaction",