Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ontology): unsupported property type was displayed wrong (DEV-936) #740

Merged
merged 2 commits into from May 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/app/project/ontology/ontology.service.ts
Expand Up @@ -133,11 +133,6 @@ export class OntologyService {
getDefaultPropType(property: ResourcePropertyDefinitionWithAllLanguages): Observable<DefaultProperty> {
let propType: DefaultProperty;

if (!property.guiElement) {
// we don't know what element to use, so it's unsupported property
return of (DefaultProperties.unsupported);
}

for (const group of this.defaultProperties) {
if (property.subPropertyOf.length) {
for (const subProp of property.subPropertyOf) {
Expand All @@ -148,20 +143,23 @@ export class OntologyService {
i.guiEle === property.guiElement && i.subPropOf === subProp
));
} else {

// if the property is type of number or list, the gui element is not relevant
// because the app supports only one gui element (at the moment): the spinbox resp. the list pulldown
if (property.objectType === Constants.DecimalValue || property.objectType === Constants.ListValue) {
if (property.objectType === Constants.IntValue && subProp === Constants.SeqNum) {
// if the property is of type number, but sub property of SeqNum,
// select the correct default prop params
propType = (group.elements.find(i =>
i.objectType === property.objectType
i.objectType === property.objectType && i.subPropOf === Constants.SeqNum
));
} else if (property.objectType === Constants.IntValue && subProp === Constants.SeqNum) {
} else if (property.objectType === Constants.TextValue) {
// if the property is of type text value, we have to check the gui element
// to get the correct default prop params
propType = (group.elements.find(i =>
i.objectType === property.objectType && i.subPropOf === Constants.SeqNum
i.guiEle === property.guiElement && i.objectType === property.objectType
));
} else {
// in all other cases the gui-element resp. the subProp is not relevant
// because the object type is unique
Comment on lines +147 to +160
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small observation: In line 139/140 you put the comment before the if structure and here after the if and else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. It's always the question, where to put the comment. Normally we put it outside the if statement. But in this long list of if, else if, else I thought it makes sense to have it inside.

propType = (group.elements.find(i =>
i.guiEle === property.guiElement && i.objectType === property.objectType
i.objectType === property.objectType
));
}
}
Expand All @@ -177,7 +175,9 @@ export class OntologyService {

if (!propType) {
// property type could not be found in the list of default properties
// maybe it's not supported e.g. if propDef.objectType === Constants.GeomValue || propDef.subPropertyOf[0] === Constants.HasRepresentation
// maybe it's not supported or it's a subproperty of another prop.
// e.g. if propDef.objectType === Constants.GeomValue || propDef.subPropertyOf[0] === Constants.HasRepresentation
// --> TODO: check if it's a subproperty of another one in this ontology
return of (DefaultProperties.unsupported);
}

Expand Down