|
|
|
@ -26,7 +26,7 @@ import { |
|
|
|
ViewChild |
|
|
|
} from '@angular/core'; |
|
|
|
import { MatFormFieldAppearance } from '@angular/material/form-field'; |
|
|
|
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'; |
|
|
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; |
|
|
|
import { merge, Observable, of, Subject } from 'rxjs'; |
|
|
|
import { catchError, debounceTime, map, share, switchMap, tap } from 'rxjs/operators'; |
|
|
|
import { Store } from '@ngrx/store'; |
|
|
|
@ -55,7 +55,7 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit |
|
|
|
|
|
|
|
selectEntityFormGroup: UntypedFormGroup; |
|
|
|
|
|
|
|
modelValue: string | null; |
|
|
|
modelValue: string | EntityId | null; |
|
|
|
|
|
|
|
entityTypeValue: EntityType | AliasEntityType; |
|
|
|
|
|
|
|
@ -113,6 +113,10 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit |
|
|
|
@Input() |
|
|
|
requiredText: string; |
|
|
|
|
|
|
|
@Input() |
|
|
|
@coerceBoolean() |
|
|
|
useFullEntityId: boolean; |
|
|
|
|
|
|
|
@Input() |
|
|
|
appearance: MatFormFieldAppearance = 'fill'; |
|
|
|
|
|
|
|
@ -171,7 +175,7 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit |
|
|
|
if (typeof value === 'string' || !value) { |
|
|
|
modelValue = null; |
|
|
|
} else { |
|
|
|
modelValue = value.id.id; |
|
|
|
modelValue = this.useFullEntityId ? value.id : value.id.id; |
|
|
|
} |
|
|
|
this.updateView(modelValue, value); |
|
|
|
if (value === null) { |
|
|
|
@ -307,7 +311,7 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit |
|
|
|
} catch (e) { |
|
|
|
this.propagateChange(null); |
|
|
|
} |
|
|
|
this.modelValue = entity !== null ? entity.id.id : null; |
|
|
|
this.modelValue = entity !== null ? (this.useFullEntityId ? entity.id : entity.id.id) : null; |
|
|
|
this.selectEntityFormGroup.get('entity').patchValue(entity !== null ? entity : '', {emitEvent: false}); |
|
|
|
this.entityChanged.emit(entity); |
|
|
|
} else { |
|
|
|
|