From de3ae0dcf13fe00edf5930f35bf8c497e4631c96 Mon Sep 17 00:00:00 2001 From: argirok Date: Thu, 9 Jun 2022 17:58:12 +0300 Subject: [PATCH] Entities autocomplete: show selected value if the service doesn't return --- .../entitiesAutoComplete/entitiesAutoComplete.component.ts | 6 ++++++ utils/staticAutoComplete/staticAutoComplete.component.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts b/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts index b28eb483..c7c73243 100644 --- a/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts +++ b/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts @@ -5,6 +5,7 @@ import {Observable, Subject} from 'rxjs'; import {EntitiesSearchService} from './entitySearch.service'; import{EnvProperties} from '../properties/env-properties'; import {StringUtils} from "../string-utils.class"; +import {AutoCompleteValue} from "../../searchPages/searchUtils/searchHelperClasses.class"; //Usage example @@ -279,6 +280,11 @@ export class EntitiesAutocompleteComponent { err => { //console.log("An error occured")); this.handleError("Error getting results of type: "+this.entityType+" with id: "+this.selectedValue, err); + this.selected.push( {label:this.selectedValue, id :this.selectedValue}); + this.updateValueLabel.emit({ + value:this.showItem(this.selected[0]) + }); + this.showInput = false; } ); } diff --git a/utils/staticAutoComplete/staticAutoComplete.component.ts b/utils/staticAutoComplete/staticAutoComplete.component.ts index 7857d5f5..5ec85e3c 100644 --- a/utils/staticAutoComplete/staticAutoComplete.component.ts +++ b/utils/staticAutoComplete/staticAutoComplete.component.ts @@ -279,7 +279,7 @@ export class StaticAutoCompleteComponent implements OnChanges{ } private getSelectedNameFromGivenId(){ if(this.list == null || this.list.length == 0 ){ - this.selected.push({label: this.selectedValue, value: this.selectedValue}); + this.selected.push({label: this.selectedValue, id: this.selectedValue}); this.showInput = false; this.updateValueLabel.emit({ value:this.showItem(this.selected[0])