UI: Entity autocomplete error handling
This commit is contained in:
parent
1e079457c7
commit
eb4334937c
@ -228,18 +228,32 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
|
|||||||
if (value != null) {
|
if (value != null) {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
const targetEntityType = this.checkEntityType(this.entityTypeValue);
|
const targetEntityType = this.checkEntityType(this.entityTypeValue);
|
||||||
this.entityService.getEntity(targetEntityType, value, {ignoreLoading: true}).subscribe(
|
this.entityService.getEntity(targetEntityType, value, {ignoreLoading: true, ignoreErrors: true}).subscribe(
|
||||||
(entity) => {
|
(entity) => {
|
||||||
this.modelValue = entity.id.id;
|
this.modelValue = entity.id.id;
|
||||||
this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false});
|
this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false});
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.modelValue = null;
|
||||||
|
this.selectEntityFormGroup.get('entity').patchValue(null, {emitEvent: false});
|
||||||
|
if (value !== null) {
|
||||||
|
this.propagateChange(this.modelValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const targetEntityType = this.checkEntityType(value.entityType);
|
const targetEntityType = this.checkEntityType(value.entityType);
|
||||||
this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true}).subscribe(
|
this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true, ignoreErrors: true}).subscribe(
|
||||||
(entity) => {
|
(entity) => {
|
||||||
this.modelValue = entity.id.id;
|
this.modelValue = entity.id.id;
|
||||||
this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false});
|
this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false});
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.modelValue = null;
|
||||||
|
this.selectEntityFormGroup.get('entity').patchValue(null, {emitEvent: false});
|
||||||
|
if (value !== null) {
|
||||||
|
this.propagateChange(this.modelValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user