From 3f963107da0454183e89dda9dc868b44ba6ea433 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 31 Jul 2023 16:34:03 +0300 Subject: [PATCH] UI: Refactoring --- .../components/entity/entity-select.component.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.ts b/ui-ngx/src/app/shared/components/entity/entity-select.component.ts index 6e235a2dad..5190f486ad 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.ts @@ -121,10 +121,17 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte } writeValue(value: EntityId | null): void { - this.modelValue = { - entityType: value?.entityType ? value.entityType : this.defaultEntityType, - id: value?.id ? value.id : null - }; + if (value != null) { + this.modelValue = { + entityType: value.entityType, + id: value.id !== NULL_UUID ? value.id : null + }; + } else { + this.modelValue = { + entityType: value?.entityType ? value.entityType : this.defaultEntityType, + id: null + }; + } this.entitySelectFormGroup.get('entityType').patchValue(this.modelValue.entityType, {emitEvent: false}); this.entitySelectFormGroup.get('entityId').patchValue(this.modelValue.id, {emitEvent: false}); }