False Positive Manual

This commit is contained in:
Timo 2020-12-15 14:27:05 +02:00
parent ff73074694
commit 59f61982cf
6 changed files with 49 additions and 25 deletions

View File

@ -35,7 +35,7 @@
<textarea #textarea [class.has-scrollbar]="hasScrollbar" class="w-300" formControlName="comment" name="comment" type="text" rows="4"></textarea>
</div>
<div class="red-input-group required" *ngIf="isDictionaryRequest">
<div class="red-input-group required" *ngIf="isDictionaryRequest && !isFalsePositiveRequest">
<label translate="manual-annotation.dialog.content.dictionary"></label>
<mat-select formControlName="dictionary">

View File

@ -23,12 +23,12 @@ export interface LegalBasisOption {
})
export class ManualAnnotationDialogComponent implements OnInit {
redactionForm: FormGroup;
isDocumentAdmin: boolean;
isDictionaryRequest: boolean;
redactionDictionaries: TypeValue[] = [];
hintDictionaries: TypeValue[] = [];
isFalsePositiveRequest: boolean;
redactionDictionaries: TypeValue[] = [];
legalOptions: LegalBasisOption[] = [];
@ViewChild('textarea') private _textarea: ElementRef;
@ -59,19 +59,20 @@ export class ManualAnnotationDialogComponent implements OnInit {
this.isDocumentAdmin = this._permissionsService.isManagerAndOwner();
this.isDictionaryRequest = this.manualRedactionEntryWrapper.type === 'DICTIONARY';
this.isFalsePositiveRequest = this.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE';
this.isDictionaryRequest = this.manualRedactionEntryWrapper.type === 'DICTIONARY' || this.isFalsePositiveRequest;
this.redactionForm = this._formBuilder.group({
reason: this.isDictionaryRequest ? [null] : [null, Validators.required],
dictionary: this.isDictionaryRequest ? [null, Validators.required] : ['manual', Validators.required],
dictionary: this.isDictionaryRequest
? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required]
: ['manual', Validators.required],
comment: this.isDocumentAdmin ? [null] : [null, Validators.required]
});
for (const key of Object.keys(this._appStateService.dictionaryData)) {
const dictionaryData = this._appStateService.dictionaryData[key];
if (!dictionaryData.virtual && !(dictionaryData.type.indexOf('recommendation_') === 0)) {
if (dictionaryData.hint) {
this.hintDictionaries.push(dictionaryData);
}
if (!dictionaryData.hint && dictionaryData.type !== 'manual') {
this.redactionDictionaries.push(dictionaryData);
}

View File

@ -4,7 +4,7 @@ export class ManualRedactionEntryWrapper {
constructor(
public readonly quads: any,
public readonly manualRedactionEntry: ManualRedactionEntry,
public readonly type: 'DICTIONARY' | 'REDACTION',
public readonly type: 'DICTIONARY' | 'REDACTION' | 'FALSE_POSITIVE',
public readonly annotationType: 'TEXT' | 'RECTANGLE' = 'TEXT'
) {}
}

View File

@ -129,9 +129,9 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
instance.docViewer.on('textSelected', (quads, selectedText, pageNumber) => {
this._selectedText = selectedText;
if (selectedText.length > 2 && this.canPerformActions) {
this.instance.enableElements(['add-dictionary']);
this.instance.enableElements(['add-dictionary', 'add-false-positive']);
} else {
this.instance.disableElements(['add-dictionary']);
this.instance.disableElements(['add-dictionary', 'add-false-positive']);
}
});
@ -237,6 +237,20 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
}, 250);
}
});
this.instance.textPopup.add(<any>{
type: 'actionButton',
dataElement: 'add-false-positive',
img: '/assets/icons/general/pdftron-action-false-positive.svg',
title: this._translateService.instant(this._manualAnnotationService.getTitle('FALSE_POSITIVE')),
onClick: () => {
const selectedQuads = this.instance.docViewer.getSelectedTextQuads();
const text = this.instance.docViewer.getSelectedText();
const mre = this._getManualRedactionEntry(selectedQuads, text);
this.manualAnnotationRequested.emit(new ManualRedactionEntryWrapper(this.instance.docViewer.getSelectedTextQuads(), mre, 'FALSE_POSITIVE'));
}
});
this.instance.textPopup.add(<any>{
type: 'actionButton',
dataElement: 'add-dictionary',
@ -249,6 +263,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
this.manualAnnotationRequested.emit(new ManualRedactionEntryWrapper(this.instance.docViewer.getSelectedTextQuads(), mre, 'DICTIONARY'));
}
});
this.instance.textPopup.add(<any>{
type: 'actionButton',
dataElement: 'add-redaction',
@ -266,12 +281,12 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
private _handleCustomActions() {
if (this.canPerformActions) {
this.instance.enableElements(['add-redaction', 'add-rectangle', 'shapeToolGroupButton']);
this.instance.enableElements(['add-redaction', 'add-rectangle', 'add-false-positive', 'shapeToolGroupButton']);
if (this._selectedText.length > 2) {
this.instance.enableElements(['add-dictionary']);
this.instance.enableElements(['add-dictionary', 'add-false-positive']);
}
} else {
this.instance.disableElements(['add-redaction', 'add-dictionary', 'add-rectangle', 'shapeToolGroupButton']);
this.instance.disableElements(['add-redaction', 'add-dictionary', 'add-false-positive', 'add-rectangle', 'shapeToolGroupButton']);
}
}

View File

@ -203,18 +203,24 @@ export class ManualAnnotationService {
});
}
getTitle(type: 'DICTIONARY' | 'REDACTION') {
getTitle(type: 'DICTIONARY' | 'REDACTION' | 'FALSE_POSITIVE') {
if (this._permissionsService.isManagerAndOwner()) {
if (type === 'DICTIONARY') {
return 'manual-annotation.dialog.header.dictionary';
} else {
return 'manual-annotation.dialog.header.redaction';
switch (type) {
case 'DICTIONARY':
return 'manual-annotation.dialog.header.dictionary';
case 'FALSE_POSITIVE':
return 'manual-annotation.dialog.header.false-positive';
case 'REDACTION':
return 'manual-annotation.dialog.header.redaction';
}
} else {
if (type === 'DICTIONARY') {
return 'manual-annotation.dialog.header.request-dictionary';
} else {
return 'manual-annotation.dialog.header.request-redaction';
switch (type) {
case 'DICTIONARY':
return 'manual-annotation.dialog.header.request-dictionary';
case 'FALSE_POSITIVE':
return 'manual-annotation.dialog.header.request-false-positive';
case 'REDACTION':
return 'manual-annotation.dialog.header.request-redaction';
}
}
}

View File

@ -463,7 +463,9 @@
"dictionary": "Add to dictionary",
"redaction": "Manual Redaction",
"request-dictionary": "Request add to dictionary",
"request-redaction": "Request Redaction"
"request-redaction": "Request Redaction",
"false-positive": "Set false positive",
"request-false-positive": "Request false positive"
},
"add-redaction": {
"success": "Redaction suggestion added!",