fixed dictionary grouping

This commit is contained in:
Timo Bejan 2020-11-06 21:42:36 +02:00
parent b6d8f343e6
commit 7c8c3cb18f
3 changed files with 40 additions and 14 deletions

View File

@ -23,14 +23,34 @@
<div class="red-input-group">
<label translate="manual-redaction.dialog.content.dictionary"></label>
<mat-select formControlName="dictionary">
<mat-select formControlName="dictionary" *ngIf="!isDictionaryRequest">
<mat-option
*ngFor="let dictionary of dictionaryOptions"
*ngFor="let dictionary of redactionDictionaries"
[value]="dictionary.type"
>
{{ dictionary.label }}
</mat-option>
</mat-select>
<mat-select formControlName="dictionary" *ngIf="isDictionaryRequest">
<mat-optgroup [label]="'group.redactions' | translate">
<mat-option
*ngFor="let dictionary of redactionDictionaries"
[value]="dictionary.type"
>
{{ dictionary.label }}
</mat-option>
</mat-optgroup>
<mat-optgroup [label]="'group.hints' | translate">
<mat-option
*ngFor="let dictionary of hintDictionaries"
[value]="dictionary.type"
>
{{ dictionary.label }}
</mat-option>
</mat-optgroup>
</mat-select>
</div>
</div>

View File

@ -16,10 +16,13 @@ import { ManualAnnotationResponse } from '../../screens/file/model/manual-annota
styleUrls: ['./manual-annotation-dialog.component.scss']
})
export class ManualAnnotationDialogComponent implements OnInit {
dictionaryOptions: TypeValue[] = [];
redactionForm: FormGroup;
isDocumentAdmin: boolean;
isDictionaryRequest: boolean;
redactionDictionaries: TypeValue[] = [];
hintDictionaries: TypeValue[] = [];
constructor(
private readonly _appStateService: AppStateService,
private readonly _userService: UserService,
@ -34,11 +37,10 @@ export class ManualAnnotationDialogComponent implements OnInit {
async ngOnInit() {
this.isDocumentAdmin = this._appStateService.isActiveProjectOwnerAndManager;
const commentField = this.isDocumentAdmin ? [null] : [null, Validators.required];
this.isDictionaryRequest = this.manualRedactionEntryWrapper.type === 'DICTIONARY';
this.redactionForm = this._formBuilder.group({
reason:
this.manualRedactionEntryWrapper.type === 'DICTIONARY'
? null
: [null, Validators.required],
reason: this.isDictionaryRequest ? null : [null, Validators.required],
dictionary: [null, Validators.required],
comment: commentField
});
@ -46,11 +48,11 @@ export class ManualAnnotationDialogComponent implements OnInit {
for (const key of Object.keys(this._appStateService.dictionaryData)) {
const dictionaryData = this._appStateService.dictionaryData[key];
if (!dictionaryData.virtual) {
if (this.manualRedactionEntryWrapper.type === 'DICTIONARY') {
this.dictionaryOptions.push(dictionaryData);
if (dictionaryData.hint) {
this.hintDictionaries.push(dictionaryData);
}
if (!dictionaryData.hint && this.manualRedactionEntryWrapper.type === 'REDACTION') {
this.dictionaryOptions.push(dictionaryData);
if (!dictionaryData.hint) {
this.redactionDictionaries.push(dictionaryData);
}
}
}
@ -59,7 +61,7 @@ export class ManualAnnotationDialogComponent implements OnInit {
handleAddRedaction() {
this._enhanceManualRedaction(this.manualRedactionEntryWrapper.manualRedactionEntry);
if (this.manualRedactionEntryWrapper.type === 'DICTIONARY') {
if (this.isDictionaryRequest) {
this._manualAnnotationService
.makeDictionaryEntry(this.manualRedactionEntryWrapper.manualRedactionEntry)
.subscribe(
@ -99,7 +101,7 @@ export class ManualAnnotationDialogComponent implements OnInit {
addRedactionRequest.reason = this.redactionForm.get('reason').value;
// todo fix this in backend
if (!addRedactionRequest.reason) {
addRedactionRequest.reason = 'ADD_TO_DICTIONARY_REQUEST';
addRedactionRequest.reason = '-';
}
const commentValue = this.redactionForm.get('comment').value;
addRedactionRequest.comment = commentValue ? { text: commentValue } : null;

View File

@ -332,5 +332,9 @@
"number-of-analyses": "Number of analyses",
"custom": "Custom"
},
"readonly-pill": "Readonly"
"readonly-pill": "Readonly",
"group": {
"redactions": "Redaction Dictionaries",
"hints": "Hint Dictionaries"
}
}