diff --git a/src/app/components/attachments/attachments.component.ts b/src/app/components/attachments/attachments.component.ts index aac26ae8..f16d53c3 100644 --- a/src/app/components/attachments/attachments.component.ts +++ b/src/app/components/attachments/attachments.component.ts @@ -55,7 +55,12 @@ export class AttachmentsComponent implements OnInit { this.resourceService .getResources('attachments') - .then((resources) => (this.resources = resources)) + .then( + (resources) => + (this.resources = resources.filter( + (tool) => !Resource.isMetaTool(tool), + )), + ) .catch(this.handleError.bind(this)) .then(() => (this.loading = false)); } diff --git a/src/app/components/edit-resource/abstract-edit-resource.component.ts b/src/app/components/edit-resource/abstract-edit-resource.component.ts index a72a69b8..991f3ca9 100644 --- a/src/app/components/edit-resource/abstract-edit-resource.component.ts +++ b/src/app/components/edit-resource/abstract-edit-resource.component.ts @@ -6,6 +6,7 @@ import { System } from '../../models/system'; import { SystemService } from '../../service/system.service'; import { ResourceTypeService } from '../../service/resource-type.service'; import { AceEditorDirective } from 'ng2-ace-editor'; +import { ResourceService } from '../../service/resource/resource.service'; export abstract class AbstractEditResourceComponent implements OnDestroy { saving = false; @@ -14,12 +15,14 @@ export abstract class AbstractEditResourceComponent implements OnDestroy { @ViewChild(AceEditorDirective) editor; @Input() resource: Resource = new Resource(); + metatools: Resource[]; resourceTypes: ResourceType[]; systems: System[]; protected constructor( protected systemService: SystemService, protected resourceTypeService: ResourceTypeService, + protected resourceService: ResourceService, protected activeModal: NgbActiveModal, ) {} @@ -39,6 +42,10 @@ export abstract class AbstractEditResourceComponent implements OnDestroy { systemsCallback.call(); } }); + + this.resourceService.getResources().then((tools) => { + this.metatools = tools.filter((tool) => Resource.isMetaTool(tool)); + }); } ngOnDestroy(): void { @@ -51,6 +58,14 @@ export abstract class AbstractEditResourceComponent implements OnDestroy { this.activeModal.dismiss('dismissed'); } + isMetaTool(): boolean { + return Resource.isMetaTool(this.resource); + } + + compareTools(o1: any, o2: any): boolean { + return o1 && o2 && o1.id === o2.id; + } + protected handleError(message): void { this.saving = false; this.errorMessage = message; diff --git a/src/app/components/edit-resource/create-resource/create-resource.component.ts b/src/app/components/edit-resource/create-resource/create-resource.component.ts index 6d1a0b3e..5f478f9c 100644 --- a/src/app/components/edit-resource/create-resource/create-resource.component.ts +++ b/src/app/components/edit-resource/create-resource/create-resource.component.ts @@ -20,12 +20,12 @@ export class CreateResourceComponent systems: System[]; constructor( - private resourceService: ResourceService, + resourceService: ResourceService, systemService: SystemService, resourceTypeService: ResourceTypeService, activeModal: NgbActiveModal, ) { - super(systemService, resourceTypeService, activeModal); + super(systemService, resourceTypeService, resourceService, activeModal); } ngOnInit(): void { diff --git a/src/app/components/edit-resource/edit-resource.component.html b/src/app/components/edit-resource/edit-resource.component.html index 3f1b9b6c..06e508a6 100644 --- a/src/app/components/edit-resource/edit-resource.component.html +++ b/src/app/components/edit-resource/edit-resource.component.html @@ -29,7 +29,7 @@
-
+
-
+
+ + +
+
+ + +
+
-
+
-
- - -
-
+
@@ -137,7 +155,7 @@
-
+
Hidden
+
+
+ + +
-
+