RED-5553 - entity selection if manual type is not available

This commit is contained in:
Timo Bejan 2022-11-21 11:50:21 +02:00
parent d33a09d512
commit 568a2a6ee3
4 changed files with 33 additions and 4 deletions

View File

@ -31,8 +31,12 @@
<label translate="manual-annotation.dialog.content.rectangle"></label>
</div>
<div *ngIf="!isFalsePositiveRequest && isDictionaryRequest" class="iqser-input-group required w-450">
<label translate="manual-annotation.dialog.content.dictionary"></label>
<div
*ngIf="!isFalsePositiveRequest && (isDictionaryRequest || !manualRedactionTypeExists)"
class="iqser-input-group required w-450"
>
<label translate="manual-annotation.dialog.content.dictionary" *ngIf="isDictionaryRequest"></label>
<label translate="manual-annotation.dialog.content.type" *ngIf="!isDictionaryRequest"></label>
<mat-select formControlName="dictionary">
<mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger>

View File

@ -27,6 +27,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
isFalsePositiveRequest: boolean;
isEditingSelectedText = false;
applyOnMultiplePages = false;
manualRedactionTypeExists = true;
possibleDictionaries: Dictionary[] = [];
legalOptions: LegalBasisOption[] = [];
@ -47,6 +48,8 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
this.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE';
this.isDictionaryRequest = this.data.manualRedactionEntryWrapper.type === 'DICTIONARY' || this.isFalsePositiveRequest;
this.manualRedactionTypeExists = this._dictionaryService.hasManualType(this._dossier.dossierTemplateId) && false;
this.form = this._getForm();
this.initialFormValue = this.form.getRawValue();
}
@ -72,7 +75,10 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
}
async ngOnInit() {
this.possibleDictionaries = await this._dictionaryService.getDictionariesOptions(this._dossier.dossierTemplateId, this._dossier.id);
this.possibleDictionaries = this.isDictionaryRequest
? await this._dictionaryService.getDictionariesOptions(this._dossier.dossierTemplateId, this._dossier.id)
: this._dictionaryService.getRedactionTypes(this._dossier.dossierTemplateId);
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
legalBasis: lbm.reason,
@ -145,7 +151,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
reason: this.isDictionaryRequest ? [null] : [null, Validators.required],
dictionary: this.isDictionaryRequest
? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required]
: ['manual', Validators.required],
: [this.manualRedactionTypeExists ? 'manual' : null, Validators.required],
comment: [null],
classification: ['non-readable content'],
multiplePages: '',

View File

@ -143,6 +143,24 @@ export class DictionaryService extends EntitiesService<IDictionary, Dictionary>
return throwError(() => 'Entries too short');
}
hasManualType(dossierTemplateId: string): boolean {
return !!this._dictionariesMapService.get(dossierTemplateId).find(e => e.type === 'manual');
}
getRedactionTypes(dossierTemplateId: string): Dictionary[] {
const possibleDictionaries: Dictionary[] = [];
for (const dictionary of this._dictionariesMapService.get(dossierTemplateId)) {
if (!dictionary.virtual && !dictionary.hint && !dictionary.systemManaged) {
possibleDictionaries.push(dictionary);
}
}
possibleDictionaries.sort((a, b) => a.label.localeCompare(b.label));
return possibleDictionaries;
}
async getDictionariesOptions(dossierTemplateId: string, dossierId: string): Promise<Dictionary[]> {
const possibleDictionaries: Dictionary[] = [];

View File

@ -1640,6 +1640,7 @@
"classification": "Value / Classification",
"comment": "Comment",
"dictionary": "Dictionary",
"type": "Entity",
"edit-selected-text": "Edit selected text",
"legalBasis": "Legal Basis",
"reason": "Reason",