Browse Source

UI: Fixed process error in resource library component

pull/8562/head
Vladyslav_Prykhodko 3 years ago
parent
commit
a48416e442
  1. 12
      ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts

12
ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts

@ -130,9 +130,15 @@ export class ResourceAutocompleteComponent implements ControlValueAccessor, OnIn
if (isDefinedAndNotNull(value)) {
this.searchText = '';
if (isObject(value) && typeof value !== 'string' && (value as TbResourceId).id) {
this.resourceService.getResourceInfo(value.id, {ignoreLoading: true, ignoreErrors: true}).subscribe(resource => {
this.modelValue = resource.id;
this.resourceFormGroup.get('resource').patchValue(resource, {emitEvent: false});
this.resourceService.getResourceInfo(value.id, {ignoreLoading: true, ignoreErrors: true}).subscribe({
next: resource => {
this.modelValue = resource.id;
this.resourceFormGroup.get('resource').patchValue(resource, {emitEvent: false});
},
error: () => {
this.modelValue = '';
this.resourceFormGroup.get('resource').patchValue('');
}
});
} else {
this.modelValue = value;

Loading…
Cancel
Save