rectangle/value/section for 3.x

This commit is contained in:
Timo Bejan 2021-12-14 21:03:50 +02:00
parent eac1d9f2a8
commit 82f7864a0a
8 changed files with 63 additions and 38 deletions

View File

@ -13,7 +13,6 @@ export class ManualRedactionEntryWrapper {
readonly quads: any,
readonly manualRedactionEntry: IManualRedactionEntry,
readonly type: ManualRedactionEntryType,
readonly annotationType: 'TEXT' | 'RECTANGLE' = 'TEXT',
readonly rectId?: string,
) {}
}

View File

@ -3,19 +3,37 @@
<div [translate]="title" class="dialog-header heading-l"></div>
<div class="dialog-content">
<ng-container *ngIf="data.manualRedactionEntryWrapper.annotationType === 'TEXT'">
<ng-container *ngIf="!data.manualRedactionEntryWrapper.manualRedactionEntry.rectangle">
<div class="iqser-input-group">
<label translate="manual-annotation.dialog.content.text"></label>
</div>
{{ format(data.manualRedactionEntryWrapper.manualRedactionEntry.value) }}
</ng-container>
<ng-container *ngIf="data.manualRedactionEntryWrapper.annotationType === 'RECTANGLE'">
<ng-container *ngIf="data.manualRedactionEntryWrapper.manualRedactionEntry.rectangle">
<div class="iqser-input-group">
<label translate="manual-annotation.dialog.content.rectangle"></label>
</div>
</ng-container>
<div *ngIf="!isFalsePositiveRequest && isDictionaryRequest" class="iqser-input-group required w-400">
<label translate="manual-annotation.dialog.content.dictionary"></label>
<mat-select formControlName="dictionary">
<mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger>
<mat-option
*ngFor="let dictionary of possibleDictionaries"
[matTooltip]="dictionary.description"
[value]="dictionary.type"
matTooltipPosition="after"
>
<span>
{{ dictionary.label }}
</span>
</mat-option>
</mat-select>
</div>
<div *ngIf="!isDictionaryRequest" class="iqser-input-group required w-400">
<label translate="manual-annotation.dialog.content.reason"></label>
<mat-select
@ -39,27 +57,19 @@
<input [value]="redactionForm.get('reason').value?.legalBasis" disabled type="text" />
</div>
<div [class.required]="!isDocumentAdmin" 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 *ngIf="data.manualRedactionEntryWrapper.manualRedactionEntry.rectangle" class="iqser-input-group w-400">
<label translate="manual-annotation.dialog.content.section"></label>
<input formControlName="section" name="section" type="text" />
</div>
<div *ngIf="isDictionaryRequest && !isFalsePositiveRequest" class="iqser-input-group required w-300">
<label translate="manual-annotation.dialog.content.dictionary"></label>
<div *ngIf="data.manualRedactionEntryWrapper.manualRedactionEntry.rectangle" class="iqser-input-group w-400">
<label translate="manual-annotation.dialog.content.classification"></label>
<input formControlName="classification" name="classification" type="text" />
</div>
<mat-select formControlName="dictionary">
<mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger>
<mat-option
*ngFor="let dictionary of redactionDictionaries"
[matTooltip]="dictionary.description"
[value]="dictionary.type"
matTooltipPosition="after"
>
<span>
{{ dictionary.label }}
</span>
</mat-option>
</mat-select>
<div [class.required]="!isDocumentAdmin" class="iqser-input-group w-300">
<label translate="manual-annotation.dialog.content.comment"></label>
<textarea formControlName="comment" name="comment" redactionHasScrollbar rows="4" type="text"></textarea>
</div>
</div>

View File

@ -28,7 +28,7 @@ export class ManualAnnotationDialogComponent implements OnInit {
isDictionaryRequest: boolean;
isFalsePositiveRequest: boolean;
redactionDictionaries: Dictionary[] = [];
possibleDictionaries: Dictionary[] = [];
legalOptions: LegalBasisOption[] = [];
private readonly _dossier: Dossier;
@ -51,7 +51,7 @@ export class ManualAnnotationDialogComponent implements OnInit {
this.redactionForm = this._getForm();
this.redactionDictionaries = this._redactionDictionaries;
this.possibleDictionaries = this._possibleDictionaries;
}
get title() {
@ -61,24 +61,25 @@ export class ManualAnnotationDialogComponent implements OnInit {
get displayedDictionaryLabel() {
const dictType = this.redactionForm.get('dictionary').value;
if (dictType) {
return this.redactionDictionaries.find(d => d.type === dictType).label;
return this.possibleDictionaries.find(d => d.type === dictType).label;
}
return null;
}
private get _redactionDictionaries(): Dictionary[] {
const redactionDictionaries: Dictionary[] = [];
private get _possibleDictionaries(): Dictionary[] {
const possibleDictionaries: Dictionary[] = [];
const dossier = this._dossier;
for (const key of Object.keys(this._appStateService.dictionaryData[dossier.dossierTemplateId])) {
const dictionaryData = this._appStateService.getDictionary(key, dossier.dossierTemplateId);
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
redactionDictionaries.push(dictionaryData);
possibleDictionaries.push(dictionaryData);
}
}
redactionDictionaries.sort((a, b) => a.label.localeCompare(b.label));
return redactionDictionaries;
possibleDictionaries.sort((a, b) => a.label.localeCompare(b.label));
return possibleDictionaries;
}
async ngOnInit() {
@ -111,11 +112,13 @@ export class ManualAnnotationDialogComponent implements OnInit {
private _getForm(): FormGroup {
return this._formBuilder.group({
section: [null],
reason: this.isDictionaryRequest ? [null] : [null, Validators.required],
dictionary: this.isDictionaryRequest
? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required]
: ['manual', Validators.required],
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
classification: ['non-readable content'],
});
}
@ -133,5 +136,9 @@ export class ManualAnnotationDialogComponent implements OnInit {
}
const commentValue = this.redactionForm.get('comment').value;
addRedactionRequest.comment = commentValue ? { text: commentValue } : null;
addRedactionRequest.section = this.redactionForm.get('section').value;
addRedactionRequest.value = addRedactionRequest.rectangle
? this.redactionForm.get('classification').value
: addRedactionRequest.value;
}
}

View File

@ -495,12 +495,10 @@ export class PdfViewerComponent implements OnInit, OnChanges {
const activeAnnotation = this.annotationManager.getSelectedAnnotations()[0];
const activePage = activeAnnotation.getPageNumber();
const quads = [this._annotationDrawService.annotationToQuads(activeAnnotation, this.instance)];
const manualRedaction = this._getManualRedaction({ [activePage]: quads }, 'Rectangle');
const manualRedaction = this._getManualRedaction({ [activePage]: quads });
this._cleanUpSelectionAndButtonState();
this.manualAnnotationRequested.emit(
new ManualRedactionEntryWrapper(quads, manualRedaction, 'REDACTION', 'RECTANGLE', activeAnnotation.Id),
);
this.manualAnnotationRequested.emit(new ManualRedactionEntryWrapper(quads, manualRedaction, 'REDACTION', activeAnnotation.Id));
}
private _cleanUpSelectionAndButtonState() {
@ -619,7 +617,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
private _getManualRedaction(
quads: Readonly<Record<string, Core.Math.Quad[]>>,
text: string,
text?: string,
convertQuads = false,
): IManualRedactionEntry {
const entry: IManualRedactionEntry = { positions: [] };
@ -633,6 +631,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
}
entry.value = text;
entry.rectangle = !text;
return entry;
}

View File

@ -88,10 +88,17 @@ export class AnnotationActionsService {
'changeLegalBasis',
$event,
{ annotations, dossier: this._dossier(file) },
(data: { comment: string; legalBasis: string }) => {
(data: { comment: string; legalBasis: string; section: string; value: string }) => {
annotations.forEach(annotation => {
this._processObsAndEmit(
this._manualAnnotationService.changeLegalBasis(annotation.annotationId, file, data.legalBasis, data.comment),
this._manualAnnotationService.changeLegalBasis(
annotation.annotationId,
file,
data.section,
data.value,
data.legalBasis,
data.comment,
),
annotation,
annotationsChanged,
);

View File

@ -102,11 +102,11 @@ export class ManualAnnotationService extends GenericService<IManualAddResponse>
}
// /manualRedaction/request/legalBasis
changeLegalBasis(annotationId: string, file: File, legalBasis: string, comment?: string) {
changeLegalBasis(annotationId: string, file: File, section: string, value: string, legalBasis: string, comment?: string) {
const mode: AnnotationActionMode = this._permissionsService.isApprover(this._dossier(file))
? 'change-legal-basis'
: 'request-change-legal-basis';
return this._makeRequest(mode, file, { annotationId, legalBasis, comment });
return this._makeRequest(mode, file, { annotationId, legalBasis, comment, section, value });
}
// this wraps

View File

@ -10,4 +10,6 @@ export interface IAddRedactionRequest {
reason?: string;
type?: string;
value?: string;
section?: string;
rectangle?: boolean;
}

View File

@ -16,4 +16,5 @@ export interface IManualRedactionEntry {
type?: string;
user?: string;
value?: string;
rectangle?: boolean;
}