Showing
1 changed file
with
15 additions
and
20 deletions
@@ -269,29 +269,24 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit | @@ -269,29 +269,24 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit | ||
269 | } | 269 | } |
270 | } | 270 | } |
271 | ); | 271 | ); |
272 | - } else { | 272 | + } else if (value.entityType && value.id) { |
273 | const targetEntityType = this.checkEntityType(value.entityType); | 273 | const targetEntityType = this.checkEntityType(value.entityType); |
274 | - if (value.id) { | ||
275 | - this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true, ignoreErrors: true}).subscribe( | ||
276 | - (entity) => { | ||
277 | - this.modelValue = entity.id.id; | ||
278 | - this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false}); | ||
279 | - }, | ||
280 | - () => { | ||
281 | - this.modelValue = null; | ||
282 | - this.selectEntityFormGroup.get('entity').patchValue('', {emitEvent: false}); | ||
283 | - if (value !== null) { | ||
284 | - this.propagateChange(this.modelValue); | ||
285 | - } | 274 | + this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true, ignoreErrors: true}).subscribe( |
275 | + (entity) => { | ||
276 | + this.modelValue = entity.id.id; | ||
277 | + this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false}); | ||
278 | + }, | ||
279 | + () => { | ||
280 | + this.modelValue = null; | ||
281 | + this.selectEntityFormGroup.get('entity').patchValue('', {emitEvent: false}); | ||
282 | + if (value !== null) { | ||
283 | + this.propagateChange(this.modelValue); | ||
286 | } | 284 | } |
287 | - ); | ||
288 | - } else { | ||
289 | - this.modelValue = null; | ||
290 | - this.selectEntityFormGroup.get('entity').patchValue('', {emitEvent: false}); | ||
291 | - if (value !== null) { | ||
292 | - this.propagateChange(this.modelValue); | ||
293 | } | 285 | } |
294 | - } | 286 | + ); |
287 | + } else { | ||
288 | + this.modelValue = null; | ||
289 | + this.selectEntityFormGroup.get('entity').patchValue('', {emitEvent: false}); | ||
295 | } | 290 | } |
296 | } else { | 291 | } else { |
297 | this.modelValue = null; | 292 | this.modelValue = null; |