RED-10332 - fixed dictionary dropdown that did not update when another dossier template was selected
This commit is contained in:
parent
d673348def
commit
e9bd45c7cc
@ -3,16 +3,12 @@ import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
effect,
|
||||
EventEmitter,
|
||||
input,
|
||||
Input,
|
||||
model,
|
||||
OnChanges,
|
||||
OnInit,
|
||||
output,
|
||||
Output,
|
||||
signal,
|
||||
SimpleChanges,
|
||||
untracked,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { CircleButtonComponent, IconButtonComponent, IconButtonTypes, LoadingService } from '@iqser/common-ui';
|
||||
@ -203,7 +199,7 @@ export class DictionaryManagerComponent implements OnInit {
|
||||
|
||||
get #templatesWithCurrentEntityType() {
|
||||
return this._dossierTemplatesService.all.filter(t =>
|
||||
this._dictionaryService.hasType(t.dossierTemplateId, this.selectedDictionaryType()),
|
||||
this._dictionaryService.hasType(t.dossierTemplateId, untracked(this.selectedDictionaryType)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -236,53 +232,57 @@ export class DictionaryManagerComponent implements OnInit {
|
||||
}
|
||||
|
||||
async #onDossierChanged(dossierTemplateId: string, dossierId?: string) {
|
||||
const selectedDictionaryByType = untracked(this.selectedDictionaryType);
|
||||
const activeEntryType = untracked(this.activeEntryType);
|
||||
let dictionary: IDictionary;
|
||||
if (dossierId === 'template') {
|
||||
dictionary = await this._dictionaryService.getForType(dossierTemplateId, this.selectedDictionaryType());
|
||||
dictionary = await this._dictionaryService.getForType(dossierTemplateId, selectedDictionaryByType);
|
||||
} else {
|
||||
if (dossierId) {
|
||||
dictionary = (
|
||||
await firstValueFrom(
|
||||
this._dictionaryService.loadDictionaryEntriesByType([this.selectedDictionaryType()], dossierTemplateId, dossierId),
|
||||
this._dictionaryService.loadDictionaryEntriesByType([selectedDictionaryByType], dossierTemplateId, dossierId),
|
||||
).catch(() => {
|
||||
return [{ entries: [COMPARE_ENTRIES_ERROR], type: '' }];
|
||||
})
|
||||
)[0];
|
||||
} else {
|
||||
dictionary = this.selectedDictionaryType()
|
||||
? await this._dictionaryService.getForType(this.currentDossierTemplateId(), this.selectedDictionaryType())
|
||||
dictionary = selectedDictionaryByType
|
||||
? await this._dictionaryService.getForType(this.currentDossierTemplateId(), selectedDictionaryByType)
|
||||
: { entries: [COMPARE_ENTRIES_ERROR], type: '' };
|
||||
}
|
||||
}
|
||||
|
||||
const activeEntries =
|
||||
this.activeEntryType() === DictionaryEntryTypes.ENTRY || this.hint()
|
||||
activeEntryType === DictionaryEntryTypes.ENTRY || this.hint()
|
||||
? [...dictionary.entries]
|
||||
: this.activeEntryType() === DictionaryEntryTypes.FALSE_POSITIVE
|
||||
: activeEntryType === DictionaryEntryTypes.FALSE_POSITIVE
|
||||
? [...dictionary.falsePositiveEntries]
|
||||
: [...dictionary.falseRecommendationEntries];
|
||||
return activeEntries.join('\n');
|
||||
}
|
||||
|
||||
#updateDropdownsOptions(updateSelectedDossierTemplate = true) {
|
||||
const currentDossierTemplateId = untracked(this.currentDossierTemplateId);
|
||||
const currentDossierId = untracked(this.currentDossierId);
|
||||
if (updateSelectedDossierTemplate) {
|
||||
this.currentDossierTemplateId.set(this.initialDossierTemplateId ?? this.currentDossierTemplateId());
|
||||
this.currentDossierTemplateId.set(this.initialDossierTemplateId ?? currentDossierTemplateId);
|
||||
this.dossierTemplates = this.currentDossierTemplateId
|
||||
? this.#templatesWithCurrentEntityType
|
||||
: this._dossierTemplatesService.all;
|
||||
if (!this.currentDossierTemplateId) {
|
||||
this.dossierTemplates = [this.selectDossierTemplate, ...this.dossierTemplates];
|
||||
}
|
||||
this.selectedDossierTemplate = this.dossierTemplates.find(t => t.id === this.currentDossierTemplateId());
|
||||
this.selectedDossierTemplate = this.dossierTemplates.find(t => t.id === currentDossierTemplateId);
|
||||
}
|
||||
this.dossiers = this._activeDossiersService.all.filter(
|
||||
d => d.dossierTemplateId === this.currentDossierTemplateId() && d.id !== this.currentDossierId(),
|
||||
d => d.dossierTemplateId === currentDossierTemplateId && d.id !== currentDossierId,
|
||||
);
|
||||
const templateDictionary = {
|
||||
id: 'template',
|
||||
dossierId: 'template',
|
||||
dossierName: 'Template Dictionary',
|
||||
dossierTemplateId: this.currentDossierTemplateId(),
|
||||
dossierTemplateId: currentDossierTemplateId,
|
||||
} as Dossier;
|
||||
this.dossiers.push(templateDictionary);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user