Skip to content

Commit 7c824bf

Browse files
authored
fix(link-value): loop through all ontologies of a project to create list of resource classes (#766)
1 parent 9c83b7e commit 7c824bf

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎src/app/workspace/resource/operations/create-link-resource/create-link-resource.component.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,14 @@ export class CreateLinkResourceComponent implements OnInit {
127127
case 'audio':
128128
this.propertiesObj[Constants.HasAudioFileValue] = [this.fileValue];
129129
break;
130+
case 'movingImage':
131+
this.propertiesObj[Constants.HasMovingImageFileValue] = [this.fileValue];
132+
break;
130133
case 'archive':
131134
this.propertiesObj[Constants.HasArchiveFileValue] = [this.fileValue];
135+
break;
136+
case 'text':
137+
this.propertiesObj[Constants.HasTextFileValue] = [this.fileValue];
132138
}
133139
}
134140

‎src/app/workspace/resource/values/link-value/link-value.component.ts‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { AbstractControl, FormBuilder, FormControl, FormGroup } from '@angular/f
1414
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
1515
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
1616
import {
17+
Constants,
1718
CreateLinkValue,
1819
KnoraApiConnection,
1920
ReadLinkValue,
@@ -142,8 +143,19 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On
142143
);
143144

144145
this._dspApiConnection.v2.ontologyCache.getOntology(this.currentOntoIri).subscribe(
145-
(onto: Map<string, ReadOntology>) => {
146-
const resClasses = onto.get(this.currentOntoIri).getClassDefinitionsByType(ResourceClassDefinition);
146+
(ontoMap: Map<string, ReadOntology>) => {
147+
148+
// filter out knorabase ontology
149+
const filteredOntoMap = new Map(
150+
Array.from(ontoMap).filter(([key, _]) => key !== Constants.KnoraApiV2)
151+
);
152+
153+
let resClasses = [];
154+
155+
// loop through each ontology in the project and create an array of ResourceClassDefinitions
156+
filteredOntoMap.forEach( onto => {
157+
resClasses = resClasses.concat(filteredOntoMap.get(onto.id).getClassDefinitionsByType(ResourceClassDefinition));
158+
});
147159

148160
// add the superclass to the list of resource classes
149161
this.resourceClasses = resClasses.filter(
@@ -154,7 +166,7 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On
154166
// and add them to the list of resource classes
155167
this.resourceClasses = this.resourceClasses.concat(this._getSubclasses(resClasses, this.restrictToResourceClass));
156168

157-
this.properties = onto.get(this.currentOntoIri).getPropertyDefinitionsByType(ResourcePropertyDefinition);
169+
this.properties = filteredOntoMap.get(this.currentOntoIri).getPropertyDefinitionsByType(ResourcePropertyDefinition);
158170
},
159171
error => {
160172
console.error(error);
@@ -263,7 +275,7 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On
263275
position: {
264276
top: '112px'
265277
},
266-
data: { mode: mode, title: resClass.label, id: iri, parentResource: this.parentResource, resourceClassDefinition: resClass.id, ontoIri: this.currentOntoIri },
278+
data: { mode: mode, title: resClass.label, id: iri, parentResource: this.parentResource, resourceClassDefinition: resClass.id },
267279
disableClose: true
268280
};
269281

0 commit comments

Comments
 (0)