From e9bd45c7cc3a36ce61d59cf6f761fb2a81beaabd Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Wed, 13 Nov 2024 09:34:05 +0200 Subject: [PATCH] RED-10332 - fixed dictionary dropdown that did not update when another dossier template was selected --- .../dictionary-manager.component.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts index de73ae43b..b041d7a02 100644 --- a/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/dictionary-manager/dictionary-manager.component.ts @@ -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); }