RED-7619 remove other useless stuff

This commit is contained in:
Dan Percic 2023-10-26 12:47:12 +03:00
parent 871f0feac1
commit d31d57a2ca
19 changed files with 77 additions and 121 deletions

View File

@ -24,7 +24,7 @@ import {
SuperType,
SuperTypes,
} from '@red/domain';
import { annotationTypesTranslations, SuggestionAddFalsePositive } from '@translations/annotation-types-translations';
import { annotationTypesTranslations } from '@translations/annotation-types-translations';
import { chronologicallyBy, timestampOf } from '../../modules/file-preview/services/file-data.service';
export class AnnotationWrapper implements IListable {
@ -32,7 +32,6 @@ export class AnnotationWrapper implements IListable {
superType: SuperType;
typeValue: string;
recategorizationType: string;
color: string;
entity: Dictionary;
comments: IComment[] = [];
@ -43,19 +42,20 @@ export class AnnotationWrapper implements IListable {
value: string;
typeLabel: string;
pageNumber: number;
hint: boolean;
redaction: boolean;
HINT = false;
redaction = false;
status: string;
dictionaryOperation: boolean;
dictionaryOperation = false;
positions: IRectangle[];
recommendationType: string;
legalBasisValue: string;
rectangle?: boolean;
// AREA === rectangle
AREA = false;
section?: string;
reference: string[];
imported?: boolean;
image?: boolean;
manual?: boolean;
imported = false;
IMAGE = false;
manual = false;
pending = false;
hintDictionary = false;
textAfter?: string;
@ -106,11 +106,7 @@ export class AnnotationWrapper implements IListable {
}
get isImage() {
return this.type?.toLowerCase() === 'image' || this.image;
}
get isNotSignatureImage() {
return this.isImage && this.recategorizationType === 'signature';
return this.type?.toLowerCase() === 'image' || this.IMAGE;
}
get isOCR() {
@ -118,7 +114,7 @@ export class AnnotationWrapper implements IListable {
}
get type() {
return this.recategorizationType || this.typeValue;
return this.typeValue;
}
get topLevelFilter() {
@ -243,7 +239,7 @@ export class AnnotationWrapper implements IListable {
annotationWrapper.changeLogType = changeLogType;
annotationWrapper.legalBasisList = legalBasisList;
annotationWrapper.redaction = logEntry.entryType === EntryTypes.ENTITY;
annotationWrapper.hint = logEntry.entryType === EntryTypes.HINT;
annotationWrapper.HINT = logEntry.entryType === EntryTypes.HINT;
annotationWrapper.typeValue = logEntry.type;
annotationWrapper.value = logEntry.value;
annotationWrapper.firstTopLeftPoint = { x: logEntry.positions[0].rectangle[0], y: logEntry.positions[0].rectangle[1] };
@ -257,7 +253,7 @@ export class AnnotationWrapper implements IListable {
annotationWrapper.textBefore = logEntry.textBefore;
annotationWrapper.textAfter = logEntry.textAfter;
annotationWrapper.dictionaryOperation = logEntry.dictionaryEntry;
annotationWrapper.image = logEntry.entryType === EntryTypes.IMAGE;
annotationWrapper.IMAGE = logEntry.entryType === EntryTypes.IMAGE;
annotationWrapper.imported = logEntry.imported;
annotationWrapper.legalBasisValue = logEntry.legalBasis;
annotationWrapper.comments = []; //logEntry.comments || [];
@ -265,7 +261,7 @@ export class AnnotationWrapper implements IListable {
annotationWrapper.engines = logEntry.engines;
annotationWrapper.section = logEntry.section;
annotationWrapper.reference = logEntry.reference || [];
annotationWrapper.rectangle = logEntry.entryType === EntryTypes.AREA;
annotationWrapper.AREA = logEntry.entryType === EntryTypes.AREA;
annotationWrapper.hintDictionary = hintDictionary;
annotationWrapper.hasBeenResized = !!logEntry.manualChanges?.find(
c => c.manualRedactionType === ManualRedactionTypes.RESIZE && c.annotationStatus === LogEntryStatuses.APPROVED,
@ -289,7 +285,7 @@ export class AnnotationWrapper implements IListable {
this.#createContent(annotationWrapper, logEntry, isDocumine);
this.#setSuperType(annotationWrapper, logEntry);
this.#handleRecommendations(annotationWrapper, logEntry);
annotationWrapper.typeLabel = this.#getTypeLabel(logEntry, annotationWrapper);
annotationWrapper.typeLabel = this.#getTypeLabel(annotationWrapper);
const entity = dictionaries.find(d => d.type === annotationWrapper.typeValue);
annotationWrapper.entity = entity?.virtual ? null : entity;
@ -300,10 +296,7 @@ export class AnnotationWrapper implements IListable {
return annotationWrapper;
}
static #getTypeLabel(logEntry: IEntityLogEntry, annotation: AnnotationWrapper): string {
if (logEntry.reason?.toLowerCase() === 'false positive') {
return annotationTypesTranslations[SuggestionAddFalsePositive];
}
static #getTypeLabel(annotation: AnnotationWrapper): string {
if (annotation.superType === SuperTypes.ManualRedaction && annotation.hintDictionary) {
return _('annotation-type.manual-hint');
}
@ -408,17 +401,9 @@ export class AnnotationWrapper implements IListable {
static #selectSuperType(logEntry: IEntityLogEntry, lastManualChange: IManualChange, isHintDictionary: boolean): SuperType {
switch (lastManualChange.manualRedactionType) {
case ManualRedactionTypes.ADD_LOCALLY:
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
return SuperTypes.ManualRedaction;
}
break;
return SuperTypes.ManualRedaction;
case ManualRedactionTypes.ADD_TO_DICTIONARY:
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
return isHintDictionary ? SuperTypes.Hint : SuperTypes.Redaction;
}
break;
return isHintDictionary ? SuperTypes.Hint : SuperTypes.Redaction;
case ManualRedactionTypes.REMOVE_LOCALLY:
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
@ -446,11 +431,7 @@ export class AnnotationWrapper implements IListable {
return SuperTypes.Redaction;
}
}
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
case LogEntryStatuses.DECLINED:
return SuperTypes.Redaction;
}
return SuperTypes.Redaction;
}
if (lastManualChange.processed) {
@ -462,12 +443,7 @@ export class AnnotationWrapper implements IListable {
}
}
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
case LogEntryStatuses.DECLINED:
return isHintDictionary ? SuperTypes.Hint : SuperTypes.Skipped;
}
break;
return isHintDictionary ? SuperTypes.Hint : SuperTypes.Skipped;
case ManualRedactionTypes.FORCE_REDACT:
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
@ -485,50 +461,34 @@ export class AnnotationWrapper implements IListable {
}
break;
case ManualRedactionTypes.RECATEGORIZE:
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
case LogEntryStatuses.DECLINED: {
if (logEntry.entryType === EntryTypes.RECOMMENDATION) {
return SuperTypes.Recommendation;
}
if (logEntry.entryType === EntryTypes.ENTITY) {
return SuperTypes.Redaction;
}
if (logEntry.entryType === EntryTypes.HINT) {
return SuperTypes.Hint;
}
return isHintDictionary ? SuperTypes.IgnoredHint : SuperTypes.Skipped;
}
if (logEntry.entryType === EntryTypes.RECOMMENDATION) {
return SuperTypes.Recommendation;
}
break;
if (logEntry.entryType === EntryTypes.ENTITY) {
return SuperTypes.Redaction;
}
if (logEntry.entryType === EntryTypes.HINT) {
return SuperTypes.Hint;
}
return isHintDictionary ? SuperTypes.IgnoredHint : SuperTypes.Skipped;
case ManualRedactionTypes.LEGAL_BASIS_CHANGE:
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
case LogEntryStatuses.DECLINED:
return logEntry.type === SuperTypes.ManualRedaction ? SuperTypes.ManualRedaction : SuperTypes.Redaction;
}
break;
return logEntry.type === SuperTypes.ManualRedaction ? SuperTypes.ManualRedaction : SuperTypes.Redaction;
case ManualRedactionTypes.RESIZE:
switch (lastManualChange.annotationStatus) {
case LogEntryStatuses.APPROVED:
case LogEntryStatuses.DECLINED:
if (logEntry.entryType === EntryTypes.RECOMMENDATION) {
return SuperTypes.Recommendation;
}
if (logEntry.entryType === EntryTypes.ENTITY) {
return logEntry.type === SuperTypes.ManualRedaction ? SuperTypes.ManualRedaction : SuperTypes.Redaction;
}
if (logEntry.entryType === EntryTypes.HINT) {
return SuperTypes.Hint;
}
return isHintDictionary ? SuperTypes.IgnoredHint : SuperTypes.Skipped;
if (logEntry.entryType === EntryTypes.RECOMMENDATION) {
return SuperTypes.Recommendation;
}
break;
if (logEntry.entryType === EntryTypes.ENTITY) {
return logEntry.type === SuperTypes.ManualRedaction ? SuperTypes.ManualRedaction : SuperTypes.Redaction;
}
if (logEntry.entryType === EntryTypes.HINT) {
return SuperTypes.Hint;
}
return isHintDictionary ? SuperTypes.IgnoredHint : SuperTypes.Skipped;
}
}
}

View File

@ -20,7 +20,7 @@
<span>{{ annotation.descriptor | translate }}</span
>:
</strong>
{{ annotation.recategorizationType ?? annotation.entity.label }}
{{ annotation.entity.label }}
</div>
<div

View File

@ -1,11 +1,11 @@
import { Component, inject, Input, OnChanges } from '@angular/core';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { KeysOf } from '@iqser/common-ui/lib/utils';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { ListItem } from '@models/file/list-item';
import { TranslateService } from '@ngx-translate/core';
import { annotationChangesTranslations } from '@translations/annotation-changes-translations';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { ListItem } from '@models/file/list-item';
import { MultiSelectService } from '../../services/multi-select.service';
import { KeysOf } from '@iqser/common-ui/lib/utils';
interface Engine {
readonly icon: string;
@ -73,7 +73,7 @@ export class AnnotationDetailsComponent implements OnChanges {
icon: 'red:dictionary',
description: _('annotation-engines.dictionary'),
show: isBasedOn(annotation, Engines.DICTIONARY),
translateParams: { isHint: annotation.hint },
translateParams: { isHint: annotation.HINT },
},
{
icon: 'red:ai',

View File

@ -1,10 +1,10 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { UntypedFormGroup, Validators } from '@angular/forms';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { Dossier } from '@red/domain';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { BaseDialogComponent } from '@iqser/common-ui';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { Dossier } from '@red/domain';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { firstValueFrom } from 'rxjs';
export interface LegalBasisOption {
@ -29,7 +29,7 @@ export class ChangeLegalBasisDialogComponent extends BaseDialogComponent impleme
}
get allRectangles(): boolean {
return this._data.annotations.reduce((acc, a) => acc && a.rectangle, true);
return this._data.annotations.reduce((acc, a) => acc && a.AREA, true);
}
async ngOnInit() {

View File

@ -1,11 +1,11 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
import { IconButtonTypes, IqserDialogComponent, IqserPermissionsService } from '@iqser/common-ui';
import { Dictionary, Dossier, SuperTypes } from '@red/domain';
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
import { Roles } from '@users/roles';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
import { DictionaryService } from '@services/entity-services/dictionary.service';
import { JustificationsService } from '@services/entity-services/justifications.service';
import { Roles } from '@users/roles';
import { EditRedactionData, EditRedactResult } from '../../../utils/dialog-types';
@Component({
@ -16,12 +16,12 @@ export class EditAnnotationDialogComponent
extends IqserDialogComponent<EditAnnotationDialogComponent, EditRedactionData, EditRedactResult>
implements OnInit
{
readonly #dossier: Dossier;
readonly roles = Roles;
readonly iconButtonTypes = IconButtonTypes;
readonly redactedTexts: string[];
dictionaries: Dictionary[] = [];
form: UntypedFormGroup;
readonly #dossier: Dossier;
constructor(
private readonly _justificationsService: JustificationsService,
@ -79,6 +79,6 @@ export class EditAnnotationDialogComponent
}
#allRectangles() {
return this.data.annotations.reduce((acc, a) => acc && a.rectangle, true);
return this.data.annotations.reduce((acc, a) => acc && a.AREA, true);
}
}

View File

@ -27,7 +27,7 @@ export class EditRedactionDialogComponent
readonly isImage: boolean;
readonly isManualRedaction: boolean;
readonly isHint: boolean;
readonly allRectangles = this.data.annotations.reduce((acc, a) => acc && a.rectangle, true);
readonly allRectangles = this.data.annotations.reduce((acc, a) => acc && a.AREA, true);
readonly showExtras: boolean;
options: DetailsRadioOption<RedactOrHintOption>[] | undefined;
legalOptions: LegalBasisOption[] = [];

View File

@ -15,18 +15,18 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
RemoveRedactionData,
RemoveRedactionResult
> {
#applyToAllDossiers: boolean;
readonly iconButtonTypes = IconButtonTypes;
readonly options: DetailsRadioOption<RemoveRedactionOption>[];
readonly recommendation;
readonly hint: boolean;
readonly redactedTexts: string[];
form!: UntypedFormGroup;
#applyToAllDossiers: boolean;
constructor(private readonly _formBuilder: FormBuilder) {
super();
this.recommendation = this.data.redactions[0].isRecommendation;
this.hint = this.data.redactions[0].hint;
this.hint = this.data.redactions[0].HINT;
this.options = getRemoveRedactionOptions(this.data);
this.redactedTexts = this.data.redactions.map(annotation => annotation.value);
this.form = this.#getForm();

View File

@ -1,12 +1,12 @@
<section class="dialog">
<form (submit)="save()" [formGroup]="form">
<div
[innerHTML]="'resize-redaction.dialog.header' | translate: { type: redaction.hint ? 'hint' : 'redaction' }"
[innerHTML]="'resize-redaction.dialog.header' | translate: { type: redaction.HINT ? 'hint' : 'redaction' }"
class="dialog-header heading-l"
></div>
<div class="dialog-content redaction">
<ng-container *ngIf="!redaction.isImage && !redaction.rectangle">
<ng-container *ngIf="!redaction.isImage && !redaction.AREA">
<div class="iqser-input-group w-450">
<label [translate]="'resize-redaction.dialog.content.original-text'" class="selected-text"></label>
<span>{{ redaction.value }}</span>

View File

@ -208,7 +208,7 @@ export class AnnotationActionsService {
resize(annotationWrapper: AnnotationWrapper) {
this._annotationManager.resizingAnnotationId = annotationWrapper.id;
if (annotationWrapper.rectangle || annotationWrapper.imported || annotationWrapper.isImage) {
if (annotationWrapper.AREA || annotationWrapper.imported || annotationWrapper.isImage) {
this._annotationManager.delete(annotationWrapper);
const rectangleAnnotation = this.#generateRectangle(annotationWrapper);
return this._annotationManager.add(rectangleAnnotation);
@ -236,7 +236,7 @@ export class AnnotationActionsService {
const dossier = this._state.dossier();
const isImageText = annotation.isImage ? 'Image' : textAndPositions.text;
const text = annotation.rectangle ? annotation.value : isImageText;
const text = annotation.AREA ? annotation.value : isImageText;
const isApprover = this._permissionsService.isApprover(dossier);
const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId);

View File

@ -344,7 +344,7 @@ export class PdfProxyService {
}
if (
(wrapper.rectangle || wrapper.isImage || wrapper.imported) &&
(wrapper.AREA || wrapper.isImage || wrapper.imported) &&
annotation.ToolName !== AnnotationToolNames.AnnotationCreateRectangle
) {
return;

View File

@ -159,7 +159,7 @@ export const getRemoveRedactionOptions = (
description: isBulk ? translations.ONLY_HERE.descriptionBulk : translations.ONLY_HERE.description,
descriptionParams: {
value: redactions[0].value,
type: redactions[0].hint ? 'hint' : redactions[0].type,
type: redactions[0].HINT ? 'hint' : redactions[0].type,
},
icon: PIN_ICON,
value: RemoveRedactionOptions.ONLY_HERE,
@ -169,7 +169,7 @@ export const getRemoveRedactionOptions = (
options.push({
label: isBulk ? translations.IN_DOSSIER.labelBulk : translations.IN_DOSSIER.label,
description: isBulk ? translations.IN_DOSSIER.descriptionBulk : translations.IN_DOSSIER.description,
descriptionParams: { value: redactions[0].value, type: redactions[0].hint ? 'hint' : redactions[0].type },
descriptionParams: { value: redactions[0].value, type: redactions[0].HINT ? 'hint' : redactions[0].type },
icon: FOLDER_ICON,
value: RemoveRedactionOptions.IN_DOSSIER,
extraOption: !isDocumine

View File

@ -165,7 +165,6 @@ export class AnnotationDrawService {
annotation.setCustomData('redact-manager', 'true');
annotation.setCustomData('redaction', String(annotationWrapper.previewAnnotation));
annotation.setCustomData('skipped', String(annotationWrapper.isSkipped));
annotation.setCustomData('notSignatureImage', String(annotationWrapper.isNotSignatureImage));
annotation.setCustomData('changeLog', String(annotationWrapper.isChangeLogEntry));
annotation.setCustomData('changeLogRemoved', String(annotationWrapper.isChangeLogRemoved));
annotation.setCustomData('opacity', String(annotation.Opacity));

View File

@ -1,9 +1,7 @@
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { SuperType, SuperTypes } from '@red/domain';
export const SuggestionAddFalsePositive = 'suggestion-add-false-positive' as const;
type TranslationKey = SuperType & typeof SuggestionAddFalsePositive;
type TranslationKey = SuperType;
export const annotationTypesTranslations: Record<TranslationKey, string> = {
[SuperTypes.TextHighlight]: _('annotation-type.text-highlight'),
@ -13,5 +11,4 @@ export const annotationTypesTranslations: Record<TranslationKey, string> = {
[SuperTypes.Recommendation]: _('annotation-type.recommendation'),
[SuperTypes.Redaction]: _('annotation-type.redaction'),
[SuperTypes.Skipped]: _('annotation-type.skipped'),
[SuggestionAddFalsePositive]: _('annotation-type.suggestion-add-false-positive'),
} as const;

View File

@ -370,7 +370,6 @@
"recommendation": "Empfehlung",
"redaction": "Schwärzung",
"skipped": "Übersprungen",
"suggestion-add-false-positive": "Suggested add to false positive",
"text-highlight": "Earmark"
},
"annotation": {

View File

@ -370,7 +370,6 @@
"recommendation": "Recommendation",
"redaction": "Redaction",
"skipped": "Skipped",
"suggestion-add-false-positive": "Suggested add to false positive",
"text-highlight": "Earmark"
},
"annotation": {

View File

@ -370,7 +370,6 @@
"recommendation": "Empfehlung",
"redaction": "Schwärzung",
"skipped": "Übersprungen",
"suggestion-add-false-positive": "",
"text-highlight": ""
},
"annotation": {

View File

@ -370,7 +370,6 @@
"recommendation": "Recommendation",
"redaction": "Annotation",
"skipped": "Skipped",
"suggestion-add-false-positive": "Suggested add to false positive",
"text-highlight": "Earmark"
},
"annotation": {

View File

@ -1,7 +1,7 @@
import { Entity } from '@iqser/common-ui';
import { IDictionary } from './dictionary';
import { DICTIONARY_TYPE_KEY_MAP, DictionaryType } from '../redaction-log';
import { List } from '@iqser/common-ui/lib/utils';
import { DICTIONARY_TYPE_KEY_MAP, DictionaryType } from '../redaction-log';
import { IDictionary } from './dictionary';
export class Dictionary extends Entity<IDictionary> implements IDictionary {
readonly addToDictionaryAction: boolean;
@ -24,7 +24,10 @@ export class Dictionary extends Entity<IDictionary> implements IDictionary {
falsePositiveEntries: List;
falseRecommendationEntries: List;
constructor(entity: IDictionary, readonly virtual = false) {
constructor(
entity: IDictionary,
readonly virtual = false,
) {
super(entity);
this.addToDictionaryAction = !!entity.addToDictionaryAction;
this.caseInsensitive = !!entity.caseInsensitive;

View File

@ -6,6 +6,7 @@ export const EntryTypes = {
FALSE_RECOMMENDATION: 'FALSE_RECOMMENDATION',
AREA: 'AREA',
IMAGE: 'IMAGE',
IMAGE_HINT: 'IMAGE_HINT',
} as const;
export type EntryType = (typeof EntryTypes)[keyof typeof EntryTypes];