Commit 1d2918f0a134f0dcd525c2581ad8afe1ac26e6ac

Authored by Igor Kulikov
1 parent 43d221e5

Minor improvements

... ... @@ -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 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 291 } else {
297 292 this.modelValue = null;
... ...