diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts
index 3e5549add4..603a1e837b 100644
--- a/src/app/project/ontology/ontology.component.ts
+++ b/src/app/project/ontology/ontology.component.ts
@@ -31,11 +31,6 @@ import { DefaultProperties, PropertyCategory, PropertyInfoObject } from './defau
import { DefaultClass, DefaultResourceClasses } from './default-data/default-resource-classes';
import { OntologyService } from './ontology.service';
-export interface OntologyInfo {
- id: string;
- label: string;
-}
-
export interface CardinalityInfo {
resClass: ClassDefinition;
property: PropertyInfoObject;
diff --git a/src/app/project/ontology/property-form/property-form.component.html b/src/app/project/ontology/property-form/property-form.component.html
index df55906f8e..ec19e60ef4 100644
--- a/src/app/project/ontology/property-form/property-form.component.html
+++ b/src/app/project/ontology/property-form/property-form.component.html
@@ -75,6 +75,7 @@
+
{{guiAttrIcon}}
@@ -90,15 +91,18 @@
+
{{guiAttrIcon}}
Select resource class
-
- {{item.label}}
-
+
+
+ {{class.label}}
+
+
{{formErrors.guiAttr}}
diff --git a/src/app/project/ontology/property-form/property-form.component.spec.ts b/src/app/project/ontology/property-form/property-form.component.spec.ts
index f2aea01501..8f2a663b52 100644
--- a/src/app/project/ontology/property-form/property-form.component.spec.ts
+++ b/src/app/project/ontology/property-form/property-form.component.spec.ts
@@ -200,8 +200,7 @@ describe('PropertyFormComponent', () => {
beforeEach(waitForAsync(() => {
- const cacheServiceSpyOnto = jasmine.createSpyObj('CacheServiceOnto', ['get']);
- const cacheServiceSpyLists = jasmine.createSpyObj('CacheServiceLists', ['get']);
+ const cacheServiceSpy = jasmine.createSpyObj('CacheService', ['get']);
const ontologyEndpointSpyObj = {
v2: {
@@ -239,11 +238,7 @@ describe('PropertyFormComponent', () => {
},
{
provide: CacheService,
- useValue: cacheServiceSpyOnto
- },
- {
- provide: CacheService,
- useValue: cacheServiceSpyLists
+ useValue: cacheServiceSpy
}
]
})
@@ -261,6 +256,18 @@ describe('PropertyFormComponent', () => {
}
);
+ // mock cache service for currentProjectOntologies
+ const cacheSpyProjOnto = TestBed.inject(CacheService);
+ (cacheSpyProjOnto as jasmine.SpyObj).get.withArgs('currentProjectOntologies').and.callFake (
+ () => {
+ const ontologies: ReadOntology[] = [];
+ ontologies.push(MockOntology.mockReadOntology('http://0.0.0.0:3333/ontology/0001/anything/v2'));
+ ontologies.push(MockOntology.mockReadOntology('http://0.0.0.0:3333/ontology/0001/minimal/v2'));
+ const response: ReadOntology[] = ontologies;
+ return of(response);
+ }
+ );
+
// mock cache service for currentOntologyLists
const cacheSpyLists = TestBed.inject(CacheService);
(cacheSpyLists as jasmine.SpyObj).get.withArgs('currentOntologyLists').and.callFake(
diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts
index 58a108b797..a068dd6dd8 100644
--- a/src/app/project/ontology/property-form/property-form.component.ts
+++ b/src/app/project/ontology/property-form/property-form.component.ts
@@ -29,6 +29,12 @@ import { AutocompleteItem } from 'src/app/workspace/search/advanced-search/resou
import { DefaultProperties, DefaultProperty, PropertyCategory, PropertyInfoObject } from '../default-data/default-properties';
import { OntologyService } from '../ontology.service';
+export interface ClassToSelect {
+ ontologyId: string;
+ ontologyLabel: string;
+ classes: ClassDefinition[];
+}
+
@Component({
selector: 'app-property-form',
templateUrl: './property-form.component.html',
@@ -106,7 +112,7 @@ export class PropertyFormComponent implements OnInit {
lists: ListNodeInfo[];
// resource classes in this ontology
- resourceClasses: ClassDefinition[] = [];
+ ontologyClasses: ClassToSelect[] = [];
loading = false;
@@ -136,15 +142,12 @@ export class PropertyFormComponent implements OnInit {
this.loading = true;
+ // set various lists to select from
this._cache.get('currentOntology').subscribe(
(response: ReadOntology) => {
this.ontology = response;
this.lastModificationDate = response.lastModificationDate;
- // set various lists to select from
- // a) in case of link value:
- // set list of resource classes from response; needed for linkValue
- this.resourceClasses = response.getAllClassDefinitions();
const resourceProperties = response.getAllPropertyDefinitions();
// set list of all existing resource property names to avoid same name twice
@@ -156,7 +159,7 @@ export class PropertyFormComponent implements OnInit {
});
// add all resource classes to the same list
- this.resourceClasses.forEach((resClass: ClassDefinition) => {
+ response.getAllClassDefinitions().forEach((resClass: ClassDefinition) => {
const name = this._os.getNameFromIri(resClass.id);
this.existingNames.push(
new RegExp('(?:^|W)' + name.toLowerCase() + '(?:$|W)')
@@ -169,8 +172,25 @@ export class PropertyFormComponent implements OnInit {
}
);
- // b) in case of list value:s
+ // a) in case of link value:
+ // set list of resource classes from response; needed for linkValue
+ this._cache.get('currentProjectOntologies').subscribe(
+ (response: ReadOntology[]) => {
+ // reset list of ontology classes
+ this.ontologyClasses = [];
+ response.forEach(onto => {
+ const ontoClasses: ClassToSelect = {
+ ontologyId: onto.id,
+ ontologyLabel: onto.label,
+ classes: onto.getAllClassDefinitions()
+ };
+ this.ontologyClasses.push(ontoClasses);
+ });
+
+ }
+ );
+ // b) in case of list value:
// set list of lists; needed for listValue
this._cache.get('currentOntologyLists').subscribe(
(response: ListNodeInfo[]) => {