Browse Source

Merge pull request #14120 from ArtemDzhereleiko/AD/bug-fix/resources-general

General resources show resources type on add dialog
pull/14130/head
Vladyslav Prykhodko 8 months ago
committed by GitHub
parent
commit
395f262573
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 20
      ui-ngx/src/app/modules/home/components/resources/resources-library.component.html
  2. 4
      ui-ngx/src/app/modules/home/components/resources/resources-library.component.ts
  3. 2
      ui-ngx/src/app/modules/home/pages/admin/resource/resources-library-table-config.resolve.ts

20
ui-ngx/src/app/modules/home/components/resources/resources-library.component.html

@ -30,7 +30,7 @@
</button>
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'delete')"
(click)="onEntityAction($event, 'deleteResource')"
[class.!hidden]="hideDelete() || isEdit">
{{ 'resource.delete' | translate }}
</button>
@ -48,16 +48,14 @@
<div class="mat-padding flex flex-col">
<form [formGroup]="entityForm">
<fieldset [disabled]="(isLoading$ | async) || !isEdit">
@if (resourceTypes.length > 1) {
<mat-form-field class="mat-block">
<mat-label translate>resource.resource-type</mat-label>
<mat-select formControlName="resourceType" required>
<mat-option *ngFor="let resourceType of resourceTypes" [value]="resourceType">
{{ resourceTypesTranslationMap.get(resourceType) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
}
<mat-form-field class="mat-block">
<mat-label translate>resource.resource-type</mat-label>
<mat-select formControlName="resourceType" required>
<mat-option *ngFor="let resourceType of resourceTypes" [value]="resourceType">
{{ resourceTypesTranslationMap.get(resourceType) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="mat-block" *ngIf="entityForm.get('resourceType').value !== resourceType.LWM2M_MODEL || !isAdd">
<mat-label translate>resource.title</mat-label>
<input matInput formControlName="title" required>

4
ui-ngx/src/app/modules/home/components/resources/resources-library.component.ts

@ -112,6 +112,10 @@ export class ResourcesLibraryComponent extends EntityComponent<Resource> impleme
if (this.isEdit && this.entityForm && !this.isAdd) {
this.entityForm.get('resourceType').disable({ emitEvent: false });
this.entityForm.get('fileName').disable({ emitEvent: false });
this.entityForm.get('data').disable({ emitEvent: false });
}
if (this.isAdd && this.resourceTypes.length === 1) {
this.entityForm.get('resourceType').disable({ emitEvent: false });
}
}

2
ui-ngx/src/app/modules/home/pages/admin/resource/resources-library-table-config.resolve.ts

@ -173,7 +173,7 @@ export class ResourcesLibraryTableConfigResolver {
case 'downloadResource':
this.downloadResource(action.event, action.entity);
return true;
case 'deleteLibrary':
case 'deleteResource':
this.deleteResource(action.event, action.entity);
}
return false;

Loading…
Cancel
Save