RED-7774: Dict label getter into observable
This commit is contained in:
parent
51628e517e
commit
f0655902a5
@ -86,7 +86,7 @@
|
|||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select [placeholder]="'redact-text.dialog.content.type-placeholder' | translate" formControlName="dictionary">
|
<mat-select [placeholder]="'redact-text.dialog.content.type-placeholder' | translate" formControlName="dictionary">
|
||||||
<mat-select-trigger>{{ displayedDictionaryLabel }}</mat-select-trigger>
|
<mat-select-trigger>{{ displayedDictionaryLabel$ | async }}</mat-select-trigger>
|
||||||
<mat-option
|
<mat-option
|
||||||
(click)="typeChanged()"
|
(click)="typeChanged()"
|
||||||
*ngFor="let dictionary of dictionaries"
|
*ngFor="let dictionary of dictionaries"
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import { DictionaryService } from '@services/entity-services/dictionary.service'
|
|||||||
import { JustificationsService } from '@services/entity-services/justifications.service';
|
import { JustificationsService } from '@services/entity-services/justifications.service';
|
||||||
import { Roles } from '@users/roles';
|
import { Roles } from '@users/roles';
|
||||||
import { calcTextWidthInPixels } from '@utils/functions';
|
import { calcTextWidthInPixels } from '@utils/functions';
|
||||||
import { firstValueFrom } from 'rxjs';
|
import { firstValueFrom, Observable } from 'rxjs';
|
||||||
import { tap } from 'rxjs/operators';
|
import { map, tap } from 'rxjs/operators';
|
||||||
import { getRedactOrHintOptions, RedactOrHintOption, RedactOrHintOptions } from '../../utils/dialog-options';
|
import { getRedactOrHintOptions, RedactOrHintOption, RedactOrHintOptions } from '../../utils/dialog-options';
|
||||||
import { RedactTextData, RedactTextResult } from '../../utils/dialog-types';
|
import { RedactTextData, RedactTextResult } from '../../utils/dialog-types';
|
||||||
import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component';
|
import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component';
|
||||||
@ -35,25 +35,11 @@ export class RedactTextDialogComponent
|
|||||||
modifiedText = this.initialText;
|
modifiedText = this.initialText;
|
||||||
selectedTextRows = 1;
|
selectedTextRows = 1;
|
||||||
readonly options: DetailsRadioOption<RedactOrHintOption>[];
|
readonly options: DetailsRadioOption<RedactOrHintOption>[];
|
||||||
|
readonly displayedDictionaryLabel$: Observable<string>;
|
||||||
readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId);
|
readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId);
|
||||||
readonly #manualRedactionTypeExists = inject(DictionaryService).hasManualType(this.#dossier.dossierTemplateId);
|
readonly #manualRedactionTypeExists = inject(DictionaryService).hasManualType(this.#dossier.dossierTemplateId);
|
||||||
#applyToAllDossiers = this.data.applyToAllDossiers ?? true;
|
#applyToAllDossiers = this.data.applyToAllDossiers ?? true;
|
||||||
|
|
||||||
get displayedDictionaryLabel() {
|
|
||||||
const dictType = this.form.controls.dictionary.value;
|
|
||||||
if (dictType) {
|
|
||||||
return this.dictionaries.find(d => d.type === dictType)?.label ?? null;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
get disabled() {
|
|
||||||
if (this.dictionaryRequest) {
|
|
||||||
return !this.form.controls.dictionary.value;
|
|
||||||
}
|
|
||||||
return !this.form.controls.dictionary.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _justificationsService: JustificationsService,
|
private readonly _justificationsService: JustificationsService,
|
||||||
private readonly _dictionaryService: DictionaryService,
|
private readonly _dictionaryService: DictionaryService,
|
||||||
@ -82,6 +68,10 @@ export class RedactTextDialogComponent
|
|||||||
takeUntilDestroyed(),
|
takeUntilDestroyed(),
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
|
this.displayedDictionaryLabel$ = this.form.controls.dictionary.valueChanges.pipe(
|
||||||
|
map(dictionary => this.dictionaries.find(d => d.type === dictionary)?.label ?? null),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user