Commit d4535e317caeb29946aa16c8dc2607e01e39c6ed

Authored by Igor Kulikov
Committed by GitHub
2 parents 501a99da 02932ce2

Merge pull request #3588 from vvlladd28/bug/entity-select/alias-type

UI: Fixed null id in entity-select component
@@ -97,10 +97,6 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte @@ -97,10 +97,6 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte
97 ngOnInit() { 97 ngOnInit() {
98 this.entitySelectFormGroup.get('entityType').valueChanges.subscribe( 98 this.entitySelectFormGroup.get('entityType').valueChanges.subscribe(
99 (value) => { 99 (value) => {
100 - if(value === AliasEntityType.CURRENT_TENANT || value === AliasEntityType.CURRENT_USER ||  
101 - value === AliasEntityType.CURRENT_USER_OWNER) {  
102 - this.modelValue.id = NULL_UUID;  
103 - }  
104 this.updateView(value, this.modelValue.id); 100 this.updateView(value, this.modelValue.id);
105 } 101 }
106 ); 102 );
@@ -140,20 +136,23 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte @@ -140,20 +136,23 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte
140 } 136 }
141 137
142 updateView(entityType: EntityType | AliasEntityType | null, entityId: string | null) { 138 updateView(entityType: EntityType | AliasEntityType | null, entityId: string | null) {
143 - if (this.modelValue.entityType !== entityType ||  
144 - this.modelValue.id !== entityId) {  
145 - this.modelValue = {  
146 - entityType,  
147 - id: this.modelValue.entityType !== entityType ? null : entityId  
148 - };  
149 - if (this.modelValue.entityType && (this.modelValue.id ||  
150 - this.modelValue.entityType === AliasEntityType.CURRENT_TENANT ||  
151 - this.modelValue.entityType === AliasEntityType.CURRENT_USER ||  
152 - this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER)) {  
153 - this.propagateChange(this.modelValue);  
154 - } else {  
155 - this.propagateChange(null);  
156 - } 139 + if (this.modelValue.entityType !== entityType || this.modelValue.id !== entityId) {
  140 + this.modelValue = {
  141 + entityType,
  142 + id: this.modelValue.entityType !== entityType ? null : entityId
  143 + };
  144 +
  145 + if (this.modelValue.entityType === AliasEntityType.CURRENT_TENANT
  146 + || this.modelValue.entityType === AliasEntityType.CURRENT_USER
  147 + || this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER) {
  148 + this.modelValue.id = NULL_UUID;
  149 + }
  150 +
  151 + if (this.modelValue.entityType && this.modelValue.id) {
  152 + this.propagateChange(this.modelValue);
  153 + } else {
  154 + this.propagateChange(null);
  155 + }
157 } 156 }
158 } 157 }
159 } 158 }