RED-6774 - removed old code for annotation remove

This commit is contained in:
Valentin Mihai 2023-06-23 15:31:13 +03:00
parent 8ec9881905
commit 2a8642efbd
10 changed files with 1 additions and 277 deletions

View File

@ -150,33 +150,6 @@
icon="red:visibility"
></iqser-circle-button>
<!-- <iqser-circle-button-->
<!-- (action)="removeOrSuggestRemoveAnnotation(true)"-->
<!-- *ngIf="annotationPermissions.canRemoveOrSuggestToRemoveFromDictionary"-->
<!-- [tooltipPosition]="tooltipPosition"-->
<!-- [tooltip]="'annotation-actions.remove-annotation.remove-from-dict' | translate"-->
<!-- [type]="buttonType"-->
<!-- icon="red:remove-from-dict"-->
<!-- ></iqser-circle-button>-->
<!-- <iqser-circle-button-->
<!-- (action)="markAsFalsePositive()"-->
<!-- *ngIf="annotationPermissions.canMarkAsFalsePositive"-->
<!-- [tooltipPosition]="tooltipPosition"-->
<!-- [tooltip]="'annotation-actions.remove-annotation.false-positive' | translate"-->
<!-- [type]="buttonType"-->
<!-- icon="red:thumb-down"-->
<!-- ></iqser-circle-button>-->
<!-- <iqser-circle-button-->
<!-- (action)="removeOrSuggestRemoveAnnotation(false)"-->
<!-- *ngIf="annotationPermissions.canRemoveOrSuggestToRemoveOnlyHere"-->
<!-- [tooltipPosition]="tooltipPosition"-->
<!-- [tooltip]="'annotation-actions.remove-annotation.only-here' | translate"-->
<!-- [type]="buttonType"-->
<!-- icon="iqser:trash"-->
<!-- ></iqser-circle-button>-->
<iqser-circle-button
(action)="removeOrSuggestRemoveRedaction()"
*ngIf="annotationPermissions.canRemoveOrSuggestToRemoveRedaction"

View File

@ -75,18 +75,10 @@ export class AnnotationActionsComponent implements OnChanges {
this.#setPermissions();
}
removeOrSuggestRemoveAnnotation(removeFromDict: boolean) {
this.annotationActionsService.removeOrSuggestRemoveAnnotation(this.annotations, removeFromDict);
}
removeOrSuggestRemoveRedaction() {
this.annotationActionsService.removeOrSuggestRemoveRedaction(this.annotations[0], this.annotationPermissions);
}
markAsFalsePositive() {
this.annotationActionsService.markAsFalsePositive(this.annotations);
}
acceptRecommendation() {
return this.annotationActionsService.convertRecommendationToAnnotation(this.annotations);
}

View File

@ -1,31 +0,0 @@
<section class="dialog">
<form (submit)="save()" [formGroup]="form">
<div class="dialog-header heading-l" [translate]="'false-positive-dialog.header'"></div>
<div class="dialog-content">
<ul>
<li
*ngFor="let value of data"
[innerHTML]="'false-positive-dialog.content.body-text' | translate : { value: value.text, context: value.context }"
></li>
</ul>
<div class="iqser-input-group w-300">
<label [translate]="'false-positive-dialog.content.comment'"></label>
<textarea formControlName="comment" iqserHasScrollbar name="comment" rows="4" type="text"></textarea>
</div>
</div>
<div class="dialog-actions">
<iqser-icon-button
[disabled]="!form.valid"
[label]="'false-positive-dialog.actions.save' | translate"
[submit]="true"
[type]="iconButtonTypes.primary"
></iqser-icon-button>
<div class="all-caps-label cancel" mat-dialog-close translate="false-positive-dialog.actions.cancel"></div>
</div>
</form>
<iqser-circle-button (action)="close()" class="dialog-close" icon="iqser:close"></iqser-circle-button>
</section>

View File

@ -1,30 +0,0 @@
import { Component, Inject, OnInit } from '@angular/core';
import { BaseDialogComponent } from '@iqser/common-ui';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
export interface FalsePositiveDialogInput {
text: string;
context: string;
}
@Component({
templateUrl: './false-positive-dialog.component.html',
})
export class FalsePositiveDialogComponent extends BaseDialogComponent implements OnInit {
constructor(
protected readonly _dialogRef: MatDialogRef<FalsePositiveDialogComponent>,
@Inject(MAT_DIALOG_DATA) readonly data: FalsePositiveDialogInput[],
) {
super(_dialogRef);
}
ngOnInit() {
const controlsConfig = { comment: [null] };
this.form = this._formBuilder.group(controlsConfig);
this.initialFormValue = this.form.getRawValue();
}
save(): void {
this._dialogRef.close(this.form.getRawValue());
}
}

View File

@ -1,49 +0,0 @@
<section class="dialog">
<div [innerHTML]="_headerTitle" class="dialog-header heading-l"></div>
<form (submit)="save()" [formGroup]="form">
<div class="dialog-content">
<span [innerHTML]="_contentTitle"></span>
<div *ngIf="data.removeFromDictionary" class="content-wrapper">
<table class="default-table">
<thead>
<tr>
<th>{{ 'remove-annotations-dialog.dictionary' | translate }}</th>
<th>{{ 'remove-annotations-dialog.value' | translate }}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let annotation of data.annotationsToRemove">
<td>{{ annotation.type }}</td>
<td>{{ annotation.value }}</td>
</tr>
</tbody>
</table>
</div>
<ul *ngIf="!data.removeFromDictionary">
<li *ngFor="let annotation of data.annotationsToRemove">
{{ printable(annotation) }}
</li>
</ul>
<div class="iqser-input-group w-300">
<label [translate]="'manual-annotation.dialog.content.comment'"></label>
<textarea formControlName="comment" iqserHasScrollbar name="comment" rows="4" type="text"></textarea>
</div>
</div>
<div class="dialog-actions">
<iqser-icon-button
[disabled]="disabled"
[label]="'remove-annotations-dialog.confirm' | translate"
[submit]="true"
[type]="iconButtonTypes.primary"
></iqser-icon-button>
<div [translate]="'remove-annotations-dialog.cancel'" class="all-caps-label cancel" mat-dialog-close></div>
</div>
</form>
<iqser-circle-button (action)="close()" class="dialog-close" icon="iqser:close"></iqser-circle-button>
</section>

View File

@ -1,21 +0,0 @@
.content-wrapper {
padding-top: 20px;
padding-bottom: 8px;
}
ul {
li {
padding-top: 4px;
}
}
.default-table {
border-collapse: collapse;
th,
td {
padding: 8px;
text-align: left;
border: 1px solid var(--iqser-separator);
}
}

View File

@ -1,55 +0,0 @@
import { Component, Inject } from '@angular/core';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { TranslateService } from '@ngx-translate/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { BaseDialogComponent, humanize } from '@iqser/common-ui';
import { Dossier } from '@red/domain';
export interface RemoveAnnotationsDialogInput {
annotationsToRemove: AnnotationWrapper[];
removeFromDictionary: boolean;
hint: boolean;
dossier: Dossier;
}
@Component({
templateUrl: './remove-annotations-dialog.component.html',
styleUrls: ['./remove-annotations-dialog.component.scss'],
})
export class RemoveAnnotationsDialogComponent extends BaseDialogComponent {
protected readonly _headerTitle = this.data.removeFromDictionary
? this._translateService.instant('remove-annotations-dialog.remove-from-dictionary.title', { hint: this.data.hint })
: this._translateService.instant('remove-annotations-dialog.remove-only-here.title', { hint: this.data.hint });
protected readonly _contentTitle = this.data.removeFromDictionary
? this._translateService.instant('remove-annotations-dialog.remove-from-dictionary.question', { hint: this.data.hint })
: this._translateService.instant('remove-annotations-dialog.remove-only-here.question', { hint: this.data.hint });
constructor(
private readonly _translateService: TranslateService,
protected readonly _dialogRef: MatDialogRef<RemoveAnnotationsDialogComponent>,
@Inject(MAT_DIALOG_DATA) readonly data: RemoveAnnotationsDialogInput,
) {
super(_dialogRef);
this.form = this._formBuilder.group({
comment: [null],
});
this.initialFormValue = this.form.getRawValue();
}
get disabled(): boolean {
return !this.valid;
}
save() {
this._dialogRef.close({ comment: this.form.getRawValue().comment });
}
printable(annotation: AnnotationWrapper) {
if (annotation.isImage) {
return this._translateService.instant('remove-annotations-dialog.image-type', {
typeLabel: humanize(annotation.type),
});
}
return annotation.value;
}
}

View File

@ -45,7 +45,6 @@ import { HighlightsSeparatorComponent } from './components/highlights-separator/
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
import { ManualAnnotationDialogComponent } from './dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
import { ForceAnnotationDialogComponent } from './dialogs/force-redaction-dialog/force-annotation-dialog.component';
import { RemoveAnnotationsDialogComponent } from './dialogs/remove-annotations-dialog/remove-annotations-dialog.component';
import { ResizeAnnotationDialogComponent } from './dialogs/resize-annotation-dialog/resize-annotation-dialog.component';
import { ChangeLegalBasisDialogComponent } from './dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
import { RecategorizeImageDialogComponent } from './dialogs/recategorize-image-dialog/recategorize-image-dialog.component';
@ -64,7 +63,6 @@ import { SuggestionsService } from './services/suggestions.service';
import { PagesComponent } from './components/pages/pages.component';
import { SharedModule } from '@shared/shared.module';
import { SharedDossiersModule } from '../shared-dossiers/shared-dossiers.module';
import { FalsePositiveDialogComponent } from './dialogs/false-positive-dialog/false-positive-dialog.component';
import { RedactTextDialogComponent } from './dialogs/redact-text-dialog/redact-text-dialog.component';
import { RemoveRedactionDialogComponent } from './dialogs/remove-redaction-dialog/remove-redaction-dialog.component';
@ -81,7 +79,6 @@ const routes: IqserRoutes = [
const dialogs = [
ManualAnnotationDialogComponent,
ForceAnnotationDialogComponent,
RemoveAnnotationsDialogComponent,
ResizeAnnotationDialogComponent,
ChangeLegalBasisDialogComponent,
RecategorizeImageDialogComponent,
@ -90,7 +87,6 @@ const dialogs = [
DocumentInfoDialogComponent,
ImportRedactionsDialogComponent,
RssDialogComponent,
FalsePositiveDialogComponent,
RedactTextDialogComponent,
RemoveRedactionDialogComponent,
];

View File

@ -119,26 +119,6 @@ export class AnnotationActionsService {
);
}
removeOrSuggestRemoveAnnotation(annotations: AnnotationWrapper[], removeFromDictionary: boolean) {
const data = {
annotationsToRemove: annotations,
removeFromDictionary,
dossier: this._state.dossier(),
hint: annotations[0].hintDictionary,
};
const { dossierId, fileId } = this._state;
this._dialogService.openDialog('removeAnnotations', data, (result: { comment: string }) => {
const body = annotations.map(annotation => ({
annotationId: annotation.id,
removeFromDictionary,
comment: result.comment,
}));
this.#processObsAndEmit(
this._manualRedactionService.removeOrSuggestRemove(body, dossierId, fileId, removeFromDictionary, annotations[0].isHint),
).then();
});
}
async removeOrSuggestRemoveRedaction(redaction: AnnotationWrapper, permissions) {
const removePermissions: RemoveRedactionPermissions = {
canRemoveOrSuggestToRemoveOnlyHere: permissions.canRemoveOrSuggestToRemoveOnlyHere,
@ -274,27 +254,6 @@ export class AnnotationActionsService {
await this._fileDataService.annotationsChanged();
}
markAsFalsePositive(annotations: AnnotationWrapper[]) {
const data = annotations.map(annotation => ({ text: annotation.value, context: this._getFalsePositiveText(annotation) }));
this._dialogService.openDialog('falsePositive', data, (result: { comment: string }) => {
const requests: List<IAddRedactionRequest> = annotations.map(annotation => ({
sourceId: annotation.id,
value: this._getFalsePositiveText(annotation),
type: annotation.type,
positions: annotation.positions,
addToDictionary: true,
reason: 'False Positive',
dictionaryEntryType: annotation.isRecommendation
? DictionaryEntryTypes.FALSE_RECOMMENDATION
: DictionaryEntryTypes.FALSE_POSITIVE,
comment: result.comment ? { text: result.comment } : null,
}));
const { dossierId, fileId } = this._state;
this.#processObsAndEmit(this._manualRedactionService.addAnnotation(requests, dossierId, fileId)).then();
});
}
#generateRectangle(annotationWrapper: AnnotationWrapper) {
const annotation = this._pdf.rectangle();
const pageHeight = this._documentViewer.getHeight(annotationWrapper.pageNumber);

View File

@ -1,6 +1,5 @@
import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { RemoveAnnotationsDialogComponent } from '../dialogs/remove-annotations-dialog/remove-annotations-dialog.component';
import { ForceAnnotationDialogComponent } from '../dialogs/force-redaction-dialog/force-annotation-dialog.component';
import { DocumentInfoDialogComponent } from '../dialogs/document-info-dialog/document-info-dialog.component';
import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
@ -10,7 +9,6 @@ import { ConfirmationDialogComponent, DialogConfig, DialogService } from '@iqser
import { ResizeAnnotationDialogComponent } from '../dialogs/resize-annotation-dialog/resize-annotation-dialog.component';
import { HighlightActionDialogComponent } from '../dialogs/highlight-action-dialog/highlight-action-dialog.component';
import { RssDialogComponent } from '../dialogs/rss-dialog/rss-dialog.component';
import { FalsePositiveDialogComponent } from '../dialogs/false-positive-dialog/false-positive-dialog.component';
type DialogType =
| 'confirm'
@ -18,12 +16,10 @@ type DialogType =
| 'rss'
| 'recategorizeImage'
| 'changeLegalBasis'
| 'removeAnnotations'
| 'resizeAnnotation'
| 'forceAnnotation'
| 'manualAnnotation'
| 'highlightAction'
| 'falsePositive';
| 'highlightAction';
@Injectable()
export class FilePreviewDialogService extends DialogService<DialogType> {
@ -42,9 +38,6 @@ export class FilePreviewDialogService extends DialogService<DialogType> {
changeLegalBasis: {
component: ChangeLegalBasisDialogComponent,
},
removeAnnotations: {
component: RemoveAnnotationsDialogComponent,
},
resizeAnnotation: {
component: ResizeAnnotationDialogComponent,
},
@ -62,9 +55,6 @@ export class FilePreviewDialogService extends DialogService<DialogType> {
component: RssDialogComponent,
dialogConfig: { width: '90vw' },
},
falsePositive: {
component: FalsePositiveDialogComponent,
},
};
constructor(protected readonly _dialog: MatDialog) {