Browse Source

revert changes for tb-entity-autocomplete

pull/14399/head
Maksym Tsymbarov 10 months ago
parent
commit
0750728bab
  1. 1
      ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-notification-dialog.component.html
  2. 41
      ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts

1
ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-notification-dialog.component.html

@ -105,7 +105,6 @@
<ng-container *ngSwitchCase="notificationTargetConfigType.CUSTOMER_USERS"> <ng-container *ngSwitchCase="notificationTargetConfigType.CUSTOMER_USERS">
<tb-entity-autocomplete <tb-entity-autocomplete
required required
syncIdsWithDB
formControlName="customerId" formControlName="customerId"
[entityType]="entityType.CUSTOMER"> [entityType]="entityType.CUSTOMER">
</tb-entity-autocomplete> </tb-entity-autocomplete>

41
ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts

@ -138,11 +138,6 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
@coerceArray() @coerceArray()
additionalClasses: Array<string>; additionalClasses: Array<string>;
@Input()
@coerceBoolean()
syncIdsWithDB = false;
@Output() @Output()
entityChanged = new EventEmitter<BaseData<EntityId>>(); entityChanged = new EventEmitter<BaseData<EntityId>>();
@ -365,38 +360,12 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
try { try {
entity = await firstValueFrom(this.entityService.getEntity(targetEntityType, id, {ignoreLoading: true, ignoreErrors: true})); entity = await firstValueFrom(this.entityService.getEntity(targetEntityType, id, {ignoreLoading: true, ignoreErrors: true}));
} catch (e) { } catch (e) {
if (this.syncIdsWithDB) { this.propagateChange(null);
this.modelValue = null;
this.entityURL = '';
this.selectEntityFormGroup.get('entity').patchValue('', {emitEvent: false});
this.entityChanged.emit(null);
this.propagateChange(null);
this.dirty = true;
return;
} else {
this.propagateChange(null);
}
}
if (entity !== null) {
this.modelValue = this.useFullEntityId ? entity.id : entity.id.id;
this.entityURL = getEntityDetailsPageURL(entity.id.id, targetEntityType);
this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false});
this.entityChanged.emit(entity);
} else {
if (this.syncIdsWithDB) {
this.modelValue = null;
this.entityURL = '';
this.selectEntityFormGroup.get('entity').patchValue('', {emitEvent: false});
this.entityChanged.emit(null);
this.propagateChange(null);
} else {
this.modelValue = null;
this.entityURL = '';
this.selectEntityFormGroup.get('entity').patchValue('', {emitEvent: false});
this.entityChanged.emit(null);
}
} }
this.modelValue = entity !== null ? (this.useFullEntityId ? entity.id : entity.id.id) : null;
this.entityURL = !entity ? '' : getEntityDetailsPageURL(entity.id.id, targetEntityType);
this.selectEntityFormGroup.get('entity').patchValue(entity !== null ? entity : '', {emitEvent: false});
this.entityChanged.emit(entity);
} else { } else {
this.modelValue = null; this.modelValue = null;
this.entityURL = ''; this.entityURL = '';

Loading…
Cancel
Save