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 a587b8467d..8db346216a 100644 --- a/src/app/project/ontology/property-form/property-form.component.html +++ b/src/app/project/ontology/property-form/property-form.component.html @@ -72,34 +72,40 @@
- - + + {{guiAttrIcon}}  - Select list + Select list * {{item.labels[0].value}} + + {{formErrors.guiAttr}} + - - + + {{guiAttrIcon}}  - Select resource class + Select resource class * {{item.label}} + + {{formErrors.guiAttr}} + - - + {{guiAttrIcon}}  Define range 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 162f7b0c79..5a454336f5 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -8,6 +8,7 @@ import { IHasProperty, KnoraApiConnection, ListNodeInfo, + PropertyDefinition, ReadOntology, ResourceClassDefinitionWithAllLanguages, ResourcePropertyDefinitionWithAllLanguages, @@ -141,23 +142,32 @@ export class PropertyFormComponent implements OnInit { // 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 + resourceProperties.forEach((resProp: PropertyDefinition) => { + const name = this._os.getNameFromIri(resProp.id); + this.existingNames.push( + new RegExp('(?:^|W)' + name.toLowerCase() + '(?:$|W)') + ); + }); + + // add all resource classes to the same list + this.resourceClasses.forEach((resClass: ClassDefinition) => { + const name = this._os.getNameFromIri(resClass.id); + this.existingNames.push( + new RegExp('(?:^|W)' + name.toLowerCase() + '(?:$|W)') + ); + }); - // set list of all existing property names to avoid same name twice - Object.entries(this.ontology.properties).forEach( - ([key]) => { - const name = this._os.getNameFromIri(key); - this.existingNames.push( - new RegExp('(?:^|W)' + name.toLowerCase() + '(?:$|W)') - ); - } - ); }, (error: ApiResponseError) => { this._errorHandler.showMessage(error); } ); - // b) in case of list value: + // b) in case of list value:s + // set list of lists; needed for listValue this._cache.get('currentOntologyLists').subscribe( (response: ListNodeInfo[]) => { diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts index 37a813948b..34bb34518a 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts @@ -2,8 +2,10 @@ import { AfterViewChecked, ChangeDetectorRef, Component, EventEmitter, Inject, I import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { ApiResponseError, + ClassDefinition, CreateResourceClass, KnoraApiConnection, + PropertyDefinition, ReadOntology, ResourceClassDefinitionWithAllLanguages, StringLiteral, @@ -146,17 +148,25 @@ export class ResourceClassFormComponent implements OnInit, AfterViewChecked { this.lastModificationDate = this.ontology.lastModificationDate; - // get all ontology resource classes: - // can be used to select resource class as gui attribute in link property, - // but also to avoid same name which should be unique - Object.entries(this.ontology.classes).forEach( - ([key]) => { - const name = this._os.getNameFromIri(key); - this.existingNames.push( - new RegExp('(?:^|W)' + name.toLowerCase() + '(?:$|W)') - ); - } - ); + const resourceClasses = response.getAllClassDefinitions(); + const resourceProperties = response.getAllPropertyDefinitions(); + + // set list of all existing resource class names to avoid same name twice + resourceClasses.forEach((resClass: ClassDefinition) => { + const name = this._os.getNameFromIri(resClass.id); + this.existingNames.push( + new RegExp('(?:^|W)' + name.toLowerCase() + '(?:$|W)') + ); + }); + + // add all resource properties to the same list + resourceProperties.forEach((resProp: PropertyDefinition) => { + const name = this._os.getNameFromIri(resProp.id); + this.existingNames.push( + new RegExp('(?:^|W)' + name.toLowerCase() + '(?:$|W)') + ); + }); + }, (error: ApiResponseError) => { this._errorHandler.showMessage(error);