Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(ontology): adjust tooltip text when property is inherited (DEV-323
…) (#674)

* feat(ontology): different tooltip if prop is inherited (DEV-323)

* refactor(ontology): format code
  • Loading branch information
kilchenmann committed Feb 23, 2022
1 parent 8ac1d25 commit d3a1e49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Expand Up @@ -56,7 +56,11 @@
<mat-icon>tune</mat-icon>
</button>
<span matTooltipPosition="above"
[matTooltip]="((!propCanBeDeleted) ? 'The property can\'t be removed because it is in use' : 'Remove property from resource class')">
[matTooltip]="((!propCanBeDeleted) ?
(propCard.isInherited ?
'The property can\'t be removed because it is inherited from another class' :
'The property can\'t be removed because it is in use'
) : 'Remove property from resource class')">
<button mat-button [disabled]="!propCanBeDeleted" class="delete"
(click)="removePropertyFromClass.emit({iri: propDef.id, label: propDef.label})">
<mat-icon>backspace</mat-icon>
Expand All @@ -73,7 +77,7 @@
</button>
</span>
<span matTooltipPosition="above"
[matTooltip]="((resClasses.length > 0 || !propCanBeDeleted) ? 'The property can\'t be deleted because it is used in a class' : 'Delete property')">
[matTooltip]="((resClasses.length > 0) ? 'The property can\'t be deleted because it is used in a class' : 'Delete property')">
<button mat-button [disabled]="resClasses.length > 0" class="delete"
(click)="deleteResourceProperty.emit({iri: propDef.id, label: propDef.label})">
<mat-icon>delete</mat-icon>
Expand Down
23 changes: 15 additions & 8 deletions src/app/project/ontology/property-info/property-info.component.ts
Expand Up @@ -283,14 +283,21 @@ export class PropertyInfoComponent implements OnChanges, AfterContentInit {
delCard.cardinalities = [this.propCard];
onto.entity = delCard;

this._dspApiConnection.v2.onto.canDeleteCardinalityFromResourceClass(onto).subscribe(
(canDoRes: CanDoResponse) => {
this.propCanBeDeleted = canDoRes.canDo;
},
(error: ApiResponseError) => {
this._errorHandler.showMessage(error);
}
);
// property can only be removed from class if it's not inherited from another prop or class
if (this.propCard.isInherited) {
this.propCanBeDeleted = false;
} else {
this._dspApiConnection.v2.onto.canDeleteCardinalityFromResourceClass(onto).subscribe(
(canDoRes: CanDoResponse) => {
this.propCanBeDeleted = canDoRes.canDo;
},
(error: ApiResponseError) => {
this._errorHandler.showMessage(error);
}
);
}


}
}
}
Expand Down

0 comments on commit d3a1e49

Please sign in to comment.