diff --git a/ui-ngx/src/app/modules/home/pages/admin/resource/resources-library-table-config.resolve.ts b/ui-ngx/src/app/modules/home/pages/admin/resource/resources-library-table-config.resolve.ts index 1e7eef1c41..148a47feac 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/resource/resources-library-table-config.resolve.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/resource/resources-library-table-config.resolve.ts @@ -22,7 +22,7 @@ import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; import { Resolve, Router } from '@angular/router'; -import { Resource, ResourceInfo, ResourceTypeTranslationMap } from '@shared/models/resource.models'; +import { Resource, ResourceInfo, ResourceType, ResourceTypeTranslationMap } from '@shared/models/resource.models'; import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared/models/entity-type.models'; import { NULL_UUID } from '@shared/models/id/has-uuid'; import { DatePipe } from '@angular/common'; @@ -150,6 +150,9 @@ export class ResourcesLibraryTableConfigResolver implements Resolve impleme updateForm(entity: Resource): void { const { resourceType, fileName, title, data } = entity; - this.updateTableReadonlyConfig(); + this.entityForm.patchValue({ resourceType, fileName, title, data }); + } - if (this.isEdit) { + override updateFormState(): void { + super.updateFormState(); + if (this.isEdit && this.entityForm) { this.entityForm.get('resourceType').disable({ emitEvent: false }); - if (resourceType !== ResourceType.JS_MODULE) { + if (this.entityForm.get('resourceType').value !== ResourceType.JS_MODULE) { this.entityForm.get('fileName').disable({ emitEvent: false }); } } - - this.entityForm.patchValue({ resourceType, fileName, title, data }); } prepareFormValue(formValue: Resource): Resource { @@ -138,11 +139,6 @@ export class ResourcesLibraryComponent extends EntityComponent impleme })); } - private updateTableReadonlyConfig(): void { - this.entitiesTableConfigValue.detailsReadonly = () => - this.resourceType.LWM2M_MODEL === this.entityForm.get('resourceType').value; - } - private observeResourceTypeChange(): void { this.entityForm.get('resourceType').valueChanges.pipe( startWith(ResourceType.JS_MODULE),