Fix RED-3477: accept/reject force hint suggestions

This commit is contained in:
Dan Percic 2022-03-02 13:02:34 +02:00
parent 628ee4d84c
commit f1ffd330d2
4 changed files with 87 additions and 75 deletions

View File

@ -2,28 +2,17 @@ import { annotationTypesTranslations } from '../../translations/annotation-types
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { IComment, IManualChange, ImportedRedaction, IPoint, IRectangle, LogEntryStatus, ManualRedactionType } from '@red/domain';
import { RedactionLogEntry } from '@models/file/redaction-log.entry';
export type AnnotationSuperType =
| 'text-highlight'
| 'suggestion-change-legal-basis'
| 'suggestion-recategorize-image'
| 'suggestion-add-dictionary'
| 'suggestion-force-redaction'
| 'suggestion-force-hint'
| 'suggestion-resize'
| 'suggestion-remove-dictionary'
| 'suggestion-add'
| 'suggestion-remove'
| 'ignored-hint'
| 'skipped'
| 'redaction'
| 'manual-redaction'
| 'recommendation'
| 'hint'
| 'declined-suggestion';
import {
FalsePositiveSuperTypes,
LowLevelFilterTypes,
SuggestionAddSuperTypes,
SuggestionsSuperTypes,
SuperType,
SuperTypes,
} from '@models/file/super-types';
export class AnnotationWrapper {
superType: AnnotationSuperType;
superType: SuperType;
typeValue: string;
recategorizationType: string;
@ -88,7 +77,7 @@ export class AnnotationWrapper {
}
get canBeMarkedAsFalsePositive() {
return (this.isRecommendation || this.superType === 'redaction') && !this.isImage;
return (this.isRecommendation || this.superType === SuperTypes.Redaction) && !this.isImage;
}
get isSuperTypeBasedColor() {
@ -96,7 +85,7 @@ export class AnnotationWrapper {
}
get isSkipped() {
return this.superType === 'skipped';
return this.superType === SuperTypes.Skipped;
}
get isImage() {
@ -112,13 +101,7 @@ export class AnnotationWrapper {
}
get topLevelFilter() {
return (
this.superType !== 'hint' &&
this.superType !== 'redaction' &&
this.superType !== 'recommendation' &&
this.superType !== 'ignored-hint' &&
this.superType !== 'skipped'
);
return !LowLevelFilterTypes[this.superType];
}
get filterKey() {
@ -129,26 +112,12 @@ export class AnnotationWrapper {
return this.topLevelFilter ? this.superType : this.superType + this.type;
}
get isManuallySkipped() {
return this.isSkipped && this.manual;
}
get isFalsePositive() {
return (
this.type?.toLowerCase() === 'false_positive' &&
(this.superType === 'skipped' ||
this.superType === 'hint' ||
this.superType === 'ignored-hint' ||
this.superType === 'redaction')
);
}
get isManualRedaction() {
return this.superType === 'manual-redaction';
return this.type?.toLowerCase() === 'false_positive' && !!FalsePositiveSuperTypes[this.superType];
}
get isDeclinedSuggestion() {
return this.superType === 'declined-suggestion';
return this.superType === SuperTypes.DeclinedSuggestion;
}
get isApproved() {
@ -156,53 +125,39 @@ export class AnnotationWrapper {
}
get isHint() {
return this.superType === 'hint';
return this.superType === SuperTypes.Hint;
}
get isHighlight() {
return this.superType === 'text-highlight';
return this.superType === SuperTypes.TextHighlight;
}
get isIgnoredHint() {
return this.superType === 'ignored-hint';
return this.superType === SuperTypes.IgnoredHint;
}
get isRedacted() {
return this.superType === 'redaction' || this.superType === 'manual-redaction';
return this.superType === SuperTypes.Redaction || this.superType === SuperTypes.ManualRedaction;
}
get isSuggestion() {
return (
this.isSuggestionAdd ||
this.isSuggestionRemove ||
this.isSuggestionChangeLegalBasis ||
this.isSuggestionRecategorizeImage ||
this.isSuggestionResize
);
return !!SuggestionsSuperTypes[this.superType];
}
get isSuggestionResize() {
return this.superType === 'suggestion-resize';
return this.superType === SuperTypes.SuggestionResize;
}
get isSuggestionRecategorizeImage() {
return this.superType === 'suggestion-recategorize-image';
}
get isSuggestionChangeLegalBasis() {
return this.superType === 'suggestion-change-legal-basis';
return this.superType === SuperTypes.SuggestionRecategorizeImage;
}
get isSuggestionAdd() {
return (
this.superType === 'suggestion-add' ||
this.superType === 'suggestion-add-dictionary' ||
this.superType === 'suggestion-force-redaction'
);
return !!SuggestionAddSuperTypes[this.superType];
}
get isSuggestionRemove() {
return this.superType === 'suggestion-remove' || this.superType === 'suggestion-remove-dictionary';
return this.superType === SuperTypes.SuggestionRemove || this.superType === SuperTypes.SuggestionRemoveDictionary;
}
get isModifyDictionary() {
@ -221,11 +176,11 @@ export class AnnotationWrapper {
}
get isConvertedRecommendation() {
return this.isRecommendation && this.superType === 'suggestion-add-dictionary';
return this.isRecommendation && this.superType === SuperTypes.SuggestionAddDictionary;
}
get isRecommendation() {
return this.superType === 'recommendation';
return this.superType === SuperTypes.Recommendation;
}
get id() {
@ -402,7 +357,7 @@ export class AnnotationWrapper {
redactionLogEntry: RedactionLogEntry,
lastManualChange: IManualChange,
isHintDictionary: boolean,
): AnnotationSuperType {
): SuperType {
switch (lastManualChange.manualRedactionType) {
case ManualRedactionType.ADD_LOCALLY:
switch (lastManualChange.annotationStatus) {

View File

@ -0,0 +1,57 @@
import { ValuesOf } from '@iqser/common-ui';
export const SuperTypes = {
TextHighlight: 'text-highlight',
SuggestionChangeLegalBasis: 'suggestion-change-legal-basis',
SuggestionRecategorizeImage: 'suggestion-recategorize-image',
SuggestionAddDictionary: 'suggestion-add-dictionary',
SuggestionForceRedaction: 'suggestion-force-redaction',
SuggestionForceHint: 'suggestion-force-hint',
SuggestionResize: 'suggestion-resize',
SuggestionRemoveDictionary: 'suggestion-remove-dictionary',
SuggestionAdd: 'suggestion-add',
SuggestionRemove: 'suggestion-remove',
IgnoredHint: 'ignored-hint',
Skipped: 'skipped',
Redaction: 'redaction',
ManualRedaction: 'manual-redaction',
Recommendation: 'recommendation',
Hint: 'hint',
DeclinedSuggestion: 'declined-suggestion',
} as const;
export type SuperType = ValuesOf<typeof SuperTypes>;
export const LowLevelFilterTypes = {
[SuperTypes.Hint]: true,
[SuperTypes.Redaction]: true,
[SuperTypes.Recommendation]: true,
[SuperTypes.IgnoredHint]: true,
[SuperTypes.Skipped]: true,
} as const;
export const FalsePositiveSuperTypes = {
[SuperTypes.Hint]: true,
[SuperTypes.Redaction]: true,
[SuperTypes.IgnoredHint]: true,
[SuperTypes.Skipped]: true,
} as const;
export const SuggestionAddSuperTypes = {
[SuperTypes.SuggestionAdd]: true,
[SuperTypes.SuggestionAddDictionary]: true,
[SuperTypes.SuggestionForceRedaction]: true,
[SuperTypes.SuggestionForceHint]: true,
} as const;
export const SuggestionsSuperTypes = {
[SuperTypes.SuggestionAdd]: true,
[SuperTypes.SuggestionAddDictionary]: true,
[SuperTypes.SuggestionForceRedaction]: true,
[SuperTypes.SuggestionForceHint]: true,
[SuperTypes.SuggestionChangeLegalBasis]: true,
[SuperTypes.SuggestionRecategorizeImage]: true,
[SuperTypes.SuggestionRemove]: true,
[SuperTypes.SuggestionRemoveDictionary]: true,
[SuperTypes.SuggestionResize]: true,
} as const;

View File

@ -1,7 +1,7 @@
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { AnnotationSuperType } from '@models/file/annotation.wrapper';
import { SuperType } from '@models/file/super-types';
export const annotationTypesTranslations: { [key in AnnotationSuperType]: string } = {
export const annotationTypesTranslations: { [key in SuperType]: string } = {
'text-highlight': _('annotation-type.text-highlight'),
'declined-suggestion': _('annotation-type.declined-suggestion'),
hint: _('annotation-type.hint'),

View File

@ -1,6 +1,6 @@
import { AnnotationSuperType } from '../../models/file/annotation.wrapper';
import { SuperType } from '../../models/file/super-types';
export const SuperTypeSorter: { [key in AnnotationSuperType]: number } = {
export const SuperTypeSorter: { [key in SuperType]: number } = {
'text-highlight': 100,
'suggestion-change-legal-basis': 14,
'suggestion-force-redaction': 15,