From 2fbf0d3b52aed7b7355361c39ccfdd7202614dbe Mon Sep 17 00:00:00 2001 From: "Hofstetter Benjamin (extern)" Date: Mon, 18 Nov 2024 13:13:56 +0100 Subject: [PATCH] add template for menu options --- .../explore-header.component.html | 18 +++++++++++- .../explore-header.component.ts | 29 ++++++++++++------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/projects/blueprint/src/app/features/explore/explore-header/explore-header.component.html b/projects/blueprint/src/app/features/explore/explore-header/explore-header.component.html index c840693..52b8ddf 100644 --- a/projects/blueprint/src/app/features/explore/explore-header/explore-header.component.html +++ b/projects/blueprint/src/app/features/explore/explore-header/explore-header.component.html @@ -26,7 +26,23 @@

{{subjectLabel()}}

- + + + @if(item.url) { + + + {{ item.label }} + + } @else { + + + {{ item.label }} + + } + + +
diff --git a/projects/blueprint/src/app/features/explore/explore-header/explore-header.component.ts b/projects/blueprint/src/app/features/explore/explore-header/explore-header.component.ts index c9608a3..e47cb75 100644 --- a/projects/blueprint/src/app/features/explore/explore-header/explore-header.component.ts +++ b/projects/blueprint/src/app/features/explore/explore-header/explore-header.component.ts @@ -1,4 +1,4 @@ -import {Component, inject, input} from '@angular/core'; +import { Component, computed, inject, input } from '@angular/core'; import { CommonModule } from '@angular/common'; import { Clipboard } from '@angular/cdk/clipboard'; @@ -8,6 +8,7 @@ import { ToastModule } from 'primeng/toast'; import { ButtonModule } from 'primeng/button'; import { MenuItem, MessageService } from 'primeng/api'; import { SkeletonModule } from 'primeng/skeleton'; +import { RippleModule } from 'primeng/ripple'; import { Avatar, AvatarComponent } from '../../../core/component/avatar/avatar.component'; @@ -20,12 +21,12 @@ import { LibraryConfigurationService } from '@blueprint/service/library-configur standalone: true, templateUrl: './explore-header.component.html', styleUrls: ['./explore-header.component.scss'], - imports: [CommonModule, MenuModule, ButtonModule, ToastModule, AvatarComponent, SkeletonModule], + imports: [CommonModule, MenuModule, ButtonModule, ToastModule, AvatarComponent, SkeletonModule, RippleModule], animations: [fadeIn], providers: [MessageService] }) export class ExploreHeaderComponent { - iri = input(''); + iri = input.required(); subjectLabel = input.required(); subjectClassLabel = input.required(); avatars = input.required(); @@ -35,35 +36,43 @@ export class ExploreHeaderComponent { public readonly config = inject(LibraryConfigurationService); public readonly clipboard = inject(Clipboard); - get items(): MenuItem[] { + + items = computed(() => { + const iri = this.iri(); return [ { label: 'Copy IRI', icon: 'pi pi-copy', command: () => { this.copyIri(); - } + }, + tabindex: '-1', }, { label: 'Dereference', icon: 'pi pi-link', - url: this.iri(), - target: '_blank' + url: iri, + target: '_blank', + tabindex: '-1', }, { label: 'SPARQL', icon: 'pi pi-share-alt', url: this.sparqlConsoleUrl(), - target: '_blank' + target: '_blank', + visible: this.config.sparqlConsoleUrl !== null, + tabindex: '-1', }, { label: 'Graph Explorer', icon: 'pi pi-compass', url: this.graphExplorerUrl(), - target: '_blank' + target: '_blank', + tabindex: '-1', } ] - } + }); + public copyIri(): void { this.clipboard.copy(this.iri());