Browse Source

UI: Refactoring

pull/8965/head
Artem Dzhereleiko 3 years ago
parent
commit
bc43a39643
  1. 20
      ui-ngx/src/app/shared/components/entity/entity-select.component.ts

20
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) {

Loading…
Cancel
Save