From c913b08b53b863e5c7d249ebfc5cf61ece5880e8 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Thu, 20 Jul 2023 15:13:11 +0300 Subject: [PATCH 1/5] UI: Fixed entity select component --- .../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 ccc4a0a079..9427c2ff73 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 @@ -125,16 +125,23 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte if (value.id === NULL_UUID) { value.id = null; } + if (value.entityType === AliasEntityType.CURRENT_TENANT + || value.entityType === AliasEntityType.CURRENT_USER + || value.entityType === AliasEntityType.CURRENT_USER_OWNER) { + value.id = NULL_UUID; + } else if (value.entityType === AliasEntityType.CURRENT_CUSTOMER && !value.id) { + this.modelValue.id = NULL_UUID; + } this.modelValue = value; - this.entitySelectFormGroup.get('entityType').patchValue(value.entityType, {emitEvent: true}); - this.entitySelectFormGroup.get('entityId').patchValue(value, {emitEvent: true}); + this.entitySelectFormGroup.get('entityType').patchValue(value.entityType, {emitEvent: false}); + this.entitySelectFormGroup.get('entityId').patchValue(value, {emitEvent: false}); } else { this.modelValue = { entityType: this.defaultEntityType, id: null }; - this.entitySelectFormGroup.get('entityType').patchValue(this.defaultEntityType, {emitEvent: true}); - this.entitySelectFormGroup.get('entityId').patchValue(null, {emitEvent: true}); + this.entitySelectFormGroup.get('entityType').patchValue(this.defaultEntityType, {emitEvent: false}); + this.entitySelectFormGroup.get('entityId').patchValue(null, {emitEvent: false}); } } From d52b67cc1b6c569fea2aa6f046971345fbb6a10b Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Fri, 21 Jul 2023 16:29:04 +0300 Subject: [PATCH 2/5] UI: Refactoring --- .../components/entity/entity-select.component.ts | 12 ------------ 1 file changed, 12 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 9427c2ff73..93452e4620 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 @@ -122,16 +122,6 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte writeValue(value: EntityId | null): void { if (value != null) { - if (value.id === NULL_UUID) { - value.id = null; - } - if (value.entityType === AliasEntityType.CURRENT_TENANT - || value.entityType === AliasEntityType.CURRENT_USER - || value.entityType === AliasEntityType.CURRENT_USER_OWNER) { - value.id = NULL_UUID; - } else if (value.entityType === AliasEntityType.CURRENT_CUSTOMER && !value.id) { - this.modelValue.id = NULL_UUID; - } this.modelValue = value; this.entitySelectFormGroup.get('entityType').patchValue(value.entityType, {emitEvent: false}); this.entitySelectFormGroup.get('entityId').patchValue(value, {emitEvent: false}); @@ -156,8 +146,6 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte || this.modelValue.entityType === AliasEntityType.CURRENT_USER || this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER) { this.modelValue.id = NULL_UUID; - } else if (this.modelValue.entityType === AliasEntityType.CURRENT_CUSTOMER && !this.modelValue.id) { - this.modelValue.id = NULL_UUID; } if (this.modelValue.entityType && this.modelValue.id) { From bc43a39643448132ec65f0a35a875a269ea85900 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 31 Jul 2023 16:05:27 +0300 Subject: [PATCH 3/5] UI: Refactoring --- .../entity/entity-select.component.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 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 93452e4620..6e235a2dad 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,18 +121,12 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte } writeValue(value: EntityId | null): void { - if (value != null) { - this.modelValue = value; - this.entitySelectFormGroup.get('entityType').patchValue(value.entityType, {emitEvent: false}); - this.entitySelectFormGroup.get('entityId').patchValue(value, {emitEvent: false}); - } else { - this.modelValue = { - entityType: this.defaultEntityType, - id: null - }; - this.entitySelectFormGroup.get('entityType').patchValue(this.defaultEntityType, {emitEvent: false}); - this.entitySelectFormGroup.get('entityId').patchValue(null, {emitEvent: false}); - } + this.modelValue = { + entityType: value?.entityType ? value.entityType : this.defaultEntityType, + id: value?.id ? value.id : null + }; + this.entitySelectFormGroup.get('entityType').patchValue(this.modelValue.entityType, {emitEvent: false}); + this.entitySelectFormGroup.get('entityId').patchValue(this.modelValue.id, {emitEvent: false}); } updateView(entityType: EntityType | AliasEntityType | null, entityId: string | null) { @@ -146,6 +140,8 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte || this.modelValue.entityType === AliasEntityType.CURRENT_USER || this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER) { this.modelValue.id = NULL_UUID; + } else if (this.modelValue.entityType === AliasEntityType.CURRENT_CUSTOMER && !this.modelValue.id) { + this.modelValue.id = NULL_UUID; } if (this.modelValue.entityType && this.modelValue.id) { From 3f963107da0454183e89dda9dc868b44ba6ea433 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 31 Jul 2023 16:34:03 +0300 Subject: [PATCH 4/5] 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}); } From 6cee9caad73e7ce1d26b6887d70f9d54616ab1a5 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 31 Jul 2023 17:01:41 +0300 Subject: [PATCH 5/5] UI: Refactoring --- .../src/app/shared/components/entity/entity-select.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5190f486ad..4874c6c186 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 @@ -128,7 +128,7 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte }; } else { this.modelValue = { - entityType: value?.entityType ? value.entityType : this.defaultEntityType, + entityType: this.defaultEntityType, id: null }; }