Commit eb4334937c9247ed0afb9600813c6e959a14344d

Authored by Igor Kulikov
1 parent 1e079457

UI: Entity autocomplete error handling

... ... @@ -228,18 +228,32 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
228 228 if (value != null) {
229 229 if (typeof value === 'string') {
230 230 const targetEntityType = this.checkEntityType(this.entityTypeValue);
231   - this.entityService.getEntity(targetEntityType, value, {ignoreLoading: true}).subscribe(
  231 + this.entityService.getEntity(targetEntityType, value, {ignoreLoading: true, ignoreErrors: true}).subscribe(
232 232 (entity) => {
233 233 this.modelValue = entity.id.id;
234 234 this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false});
  235 + },
  236 + () => {
  237 + this.modelValue = null;
  238 + this.selectEntityFormGroup.get('entity').patchValue(null, {emitEvent: false});
  239 + if (value !== null) {
  240 + this.propagateChange(this.modelValue);
  241 + }
235 242 }
236 243 );
237 244 } else {
238 245 const targetEntityType = this.checkEntityType(value.entityType);
239   - this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true}).subscribe(
  246 + this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true, ignoreErrors: true}).subscribe(
240 247 (entity) => {
241 248 this.modelValue = entity.id.id;
242 249 this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false});
  250 + },
  251 + () => {
  252 + this.modelValue = null;
  253 + this.selectEntityFormGroup.get('entity').patchValue(null, {emitEvent: false});
  254 + if (value !== null) {
  255 + this.propagateChange(this.modelValue);
  256 + }
243 257 }
244 258 );
245 259 }
... ...