RED-10332 - Dossier Template not changeable when comparing dossier dictionaries in Edit dossier modal
This commit is contained in:
parent
9f1f654521
commit
6619b9f4de
@ -78,7 +78,7 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
@ViewChild(EditorComponent) readonly editor: EditorComponent;
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
dossiers: Dossier[];
|
||||
dossierTemplates: DossierTemplate[] = this.dossierTemplatesService.all;
|
||||
dossierTemplates: DossierTemplate[];
|
||||
diffEditorText = '';
|
||||
showDiffEditor = false;
|
||||
selectDossier = { dossierName: _('dictionary-overview.compare.select-dossier') } as Dossier;
|
||||
@ -91,7 +91,7 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
protected readonly _isSearchOpen = signal(false);
|
||||
protected initialDossierTemplateId: string;
|
||||
readonly #currentTab = window.location.href.split('/').pop();
|
||||
#dossierTemplate = this.dossierTemplatesService.all[0];
|
||||
#dossierTemplate;
|
||||
#dossier = this.selectDossier;
|
||||
#dictionary = this.selectDictionary;
|
||||
|
||||
@ -100,8 +100,8 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
private readonly _dictionariesMapService: DictionariesMapService,
|
||||
private readonly _activeDossiersService: ActiveDossiersService,
|
||||
private readonly _changeRef: ChangeDetectorRef,
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
protected readonly _loadingService: LoadingService,
|
||||
readonly dossierTemplatesService: DossierTemplatesService,
|
||||
) {}
|
||||
|
||||
get selectedDossierTemplate() {
|
||||
@ -150,7 +150,6 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
if (dictionary.type) {
|
||||
this.selectedDictionaryType = dictionary.type;
|
||||
this.#dictionary = dictionary;
|
||||
console.log(dictionary);
|
||||
this.#onDossierChanged(this.#dossier.dossierTemplateId).then(entries => this.#updateDiffEditorText(entries));
|
||||
}
|
||||
}
|
||||
@ -181,12 +180,16 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
get #templatesWithCurrentEntityType() {
|
||||
return this.dossierTemplatesService.all.filter(t =>
|
||||
return this._dossierTemplatesService.all.filter(t =>
|
||||
this._dictionaryService.hasType(t.dossierTemplateId, this.selectedDictionaryType),
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
async ngOnInit() {
|
||||
await firstValueFrom(this._dossierTemplatesService.loadAll());
|
||||
this.dossierTemplates = this._dossierTemplatesService.all;
|
||||
await firstValueFrom(this._dictionaryService.loadDictionaryDataForDossierTemplates(this.dossierTemplates.map(t => t.id)));
|
||||
this.#dossierTemplate = this._dossierTemplatesService.all[0];
|
||||
this.initialDossierTemplateId = this.currentDossierTemplateId;
|
||||
this.#updateDropdownsOptions();
|
||||
}
|
||||
@ -255,7 +258,9 @@ export class DictionaryManagerComponent implements OnChanges, OnInit {
|
||||
#updateDropdownsOptions(updateSelectedDossierTemplate = true) {
|
||||
if (updateSelectedDossierTemplate) {
|
||||
this.currentDossierTemplateId = this.initialDossierTemplateId ?? this.currentDossierTemplateId;
|
||||
this.dossierTemplates = this.currentDossierTemplateId ? this.#templatesWithCurrentEntityType : this.dossierTemplatesService.all;
|
||||
this.dossierTemplates = this.currentDossierTemplateId
|
||||
? this.#templatesWithCurrentEntityType
|
||||
: this._dossierTemplatesService.all;
|
||||
if (!this.currentDossierTemplateId) {
|
||||
this.dossierTemplates = [this.selectDossierTemplate, ...this.dossierTemplates];
|
||||
}
|
||||
|
||||
@ -224,6 +224,14 @@ export class DictionaryService extends EntitiesService<IDictionary, Dictionary>
|
||||
);
|
||||
}
|
||||
|
||||
loadDictionaryDataForDossierTemplates(dossierTemplateIds: string[]): Observable<Dictionary[]> {
|
||||
const requests$ = [];
|
||||
for (const id of dossierTemplateIds) {
|
||||
requests$.push(this.loadDictionaryDataForDossierTemplate(id));
|
||||
}
|
||||
return forkJoin(requests$);
|
||||
}
|
||||
|
||||
loadDictionaryDataForDossier(dossierTemplateId: string, dossierId: string): Observable<Dictionary[]> {
|
||||
return this.getAllDictionaries(dossierTemplateId, false, dossierId).pipe(
|
||||
tap(dictionaries => this._dictionariesMapService.set(dossierId, dictionaries)),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user