Skip to content

Commit

Permalink
feat(resource): open resource instances from ontology class (DEV-950) (
Browse files Browse the repository at this point in the history
…#746)

* feat(resource): open resource instances from ontology class (DEV-950)

* refactor(ontology): reset format

* refactor(ontology): reset format

* refactor(ontology): reset format

* docs(ontology): add jsDocs to new method
  • Loading branch information
kilchenmann committed May 23, 2022
1 parent 7d2f6f3 commit e937b5f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Expand Up @@ -33,8 +33,12 @@
(click)="editResourceClass.emit({iri: resourceClass.id, label: resourceClass.label})">
Edit resource class info
</button>
<span
[matTooltip]="(classCanBeDeleted ? null : 'This class can\'t be deleted because it is in use')">
<span [matTooltip]="(classCanBeDeleted ? 'This class doesn\'t have any instances yet' : null)" matTooltipPosition="before">
<button mat-menu-item (click)="openResource(resourceClass.id)" [disabled]="classCanBeDeleted">
Open resource instances
</button>
</span>
<span [matTooltip]="(classCanBeDeleted ? null : 'This class can\'t be deleted because it is in use')" matTooltipPosition="before">
<button mat-menu-item [disabled]="!classCanBeDeleted" class="res-class-delete"
(click)="deleteResourceClass.emit({iri: resourceClass.id, label: resourceClass.label})">
Delete resource class
Expand Down
Expand Up @@ -486,4 +486,32 @@ export class ResourceClassInfoComponent implements OnInit {

}

/**
* opens resource instances in new tab using gravsearch
* @param iri
*/
openResource(iri: string) {
// open resource instances in new tab:
// it's important not to indent the gravsearch.
const gravsearch = `
PREFIX knora-api: <http://api.knora.org/ontology/knora-api/v2#>
CONSTRUCT {
?mainRes knora-api:isMainResource true .
} WHERE {
?mainRes a knora-api:Resource .
?mainRes a <${iri}> .
}
OFFSET 0`;

const doSearchRoute = `/search/gravsearch/${encodeURIComponent(gravsearch)}`;
window.open(doSearchRoute, '_blank');
}

}

0 comments on commit e937b5f

Please sign in to comment.