feat(person): moved link tab nav bar to dedicated component
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Mats Paul Tončik
2026-08-04 15:03:50 +02:00
parent 9011d58355
commit 42bcac251b
8 changed files with 174 additions and 56 deletions
@@ -132,20 +132,12 @@
[loading]="isTopicsLoading()"
(tagClick)="onInterestingTagClick($event)"></app-person-interesting>
</section>
<nav class="person-tabs sg-tab-nav" mat-tab-nav-bar [tabPanel]="tabPanel">
@for (link of links(); track link.path) {
<a
mat-tab-link
[routerLink]="link.path"
[queryParams]="link.queryParams"
routerLinkActive
#rla="routerLinkActive"
[active]="rla.isActive"
[disabled]="link.disabled">
{{ link.label }}
</a>
}
</nav>
@if (this.links()) {
<app-link-tab-nav-bar
#navBar
[links]="links()"
[tabPanel]="tabPanel"></app-link-tab-nav-bar>
}
} @else {
<app-loading
text="Person wird geladen..."
@@ -6,6 +6,7 @@ import {
signal,
DestroyRef,
input,
viewChild,
} from '@angular/core';
import {
toSignal,
@@ -33,14 +34,20 @@ import { PersonDataResolved } from '../../resolvers/person.resolver';
import { BookmarkService } from '../../shared/services/bookmark.service';
import { collaborationGraphQueryParamKeys } from '../../resolvers/collaboration-graph.resolver';
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
type PersonLink = {
label: string;
description?: string;
path: string;
queryParams?: Record<string, any>;
disabled: boolean;
};
import {
LinkTabNavBarComponent,
LinkTabNavBarItem,
} from '../../shared/ui/link-tab-nav-bar/link-tab-nav-bar.component';
import {
COMPANY_CONNECTION_ICON,
FUNDING_ICON,
NETWORK_ICON,
NEWS_ICON,
OVERVIEW_ICON,
PATENT_ICON,
PROJECT_ICON,
PUBLICATION_ICON,
} from '../../shared/ui/icons';
@Component({
selector: 'app-person',
@@ -55,6 +62,7 @@ type PersonLink = {
LoadingComponent,
CountryFlagComponent,
CareerStageChipComponent,
LinkTabNavBarComponent,
],
templateUrl: './person.component.html',
styleUrl: './person.component.scss',
@@ -69,6 +77,11 @@ export class PersonComponent {
canFetchGdprRelevantData = input.required<boolean>();
protected readonly navBar = viewChild<LinkTabNavBarComponent>('navBar');
protected readonly activeLink = computed(
() => this.navBar()?.activeLink() ?? null,
);
constructor() {
this.bookmarkService
.load()
@@ -236,11 +249,12 @@ export class PersonComponent {
{ initialValue: [] },
);
readonly links = computed<PersonLink[]>(() => {
readonly links = computed<LinkTabNavBarItem[]>(() => {
const links = [
{
label: 'Übersicht',
description: 'Übersicht über die Person',
icon: OVERVIEW_ICON,
path: 'overview',
disabled: false,
},
@@ -249,6 +263,7 @@ export class PersonComponent {
{
label: 'Projekte',
description: 'Übersicht der durchgeführten Projekte der Person',
icon: PROJECT_ICON,
path: 'projects',
queryParams: {
page: 0,
@@ -264,12 +279,13 @@ export class PersonComponent {
{
label: 'Publikationen',
description: 'Übersicht der Publikationen der Person',
icon: PUBLICATION_ICON,
path: 'publications',
disabled: false,
},
{
label: 'Netzwerk',
description: 'Kooperationsnetzwerk der Person',
icon: NETWORK_ICON,
path: 'network',
disabled: false,
queryParams: {
@@ -284,6 +300,7 @@ export class PersonComponent {
{
label: 'Unternehmen',
description: 'Unternehmen, mit denen die Person verbunden ist',
icon: COMPANY_CONNECTION_ICON,
path: 'company-connections',
disabled: false,
},
@@ -292,18 +309,21 @@ export class PersonComponent {
{
label: 'Förderungen',
description: 'Übersicht der Förderungen der Person',
icon: FUNDING_ICON,
path: 'funding',
disabled: false,
},
{
label: 'Nachrichten',
description: 'Nachrichten über die Person',
icon: NEWS_ICON,
path: 'news',
disabled: false,
},
{
label: 'Patente',
description: 'Patente der Person',
icon: PATENT_ICON,
path: 'patents',
disabled: false,
},
@@ -311,25 +331,25 @@ export class PersonComponent {
return links;
});
readonly activeLink = computed<PersonLink | null>(() => {
const currentUrl = this.currentUrl();
if (!currentUrl) {
return null;
}
// readonly activeLink = computed<LinkTabNavBarItem | null>(() => {
// const currentUrl = this.currentUrl();
// if (!currentUrl) {
// return null;
// }
for (const link of this.links()) {
const linkUrl = this.router
.createUrlTree([link.path], {
relativeTo: this.activatedRoute,
})
.toString();
// for (const link of this.links()) {
// const linkUrl = this.router
// .createUrlTree([link.path], {
// relativeTo: this.activatedRoute,
// })
// .toString();
if (linkUrl.startsWith(currentUrl) || currentUrl.startsWith(linkUrl)) {
return link;
}
}
return null;
});
// if (linkUrl.startsWith(currentUrl) || currentUrl.startsWith(linkUrl)) {
// return link;
// }
// }
// return null;
// });
onInterestingTagClick(selection: {
id: string;
@@ -17,6 +17,21 @@ import { topicQueryParamKeys } from '../../../resolvers/topic-page.resolver';
import { SortDirection, TopicSortBy, WorkSortBy } from '../../../api';
import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
import { MatMenuModule } from '@angular/material/menu';
import {
BOOKMARKS_ICON,
DASHBOARD_ICON,
INSTITUTION_ICON,
JOBS_ICON,
KEYWORDS_ICON,
MANAGE_ACCOUNTS_ICON,
NEWS_ICON,
ORGANIZATIONS_ICON,
PATENT_ICON,
PERSONS_ICON,
PROJECT_ICON,
PUBLICATION_ICON,
TOPIC_ICON,
} from '../icons';
type NavItem = {
label: string;
@@ -71,13 +86,13 @@ export class AppMenuComponent {
const items: NavItem[] = [
{
label: 'Dashboard',
icon: 'dashboard',
icon: DASHBOARD_ICON,
route: '/dashboard',
disabled: false,
},
{
label: 'Personen',
icon: 'groups',
icon: PERSONS_ICON,
route: '/persons',
queryParams: activeInstitutionPersonListQueryParams(
this.credentialService.effectiveInstitutionId(),
@@ -87,19 +102,19 @@ export class AppMenuComponent {
},
{
label: 'Bookmarks',
icon: 'bookmarks',
icon: BOOKMARKS_ICON,
route: '/bookmarks',
disabled: false,
},
{
label: 'News',
icon: 'newspaper',
icon: NEWS_ICON,
route: '/news',
disabled: false,
},
{
label: 'Institutionen',
icon: 'apartment',
icon: INSTITUTION_ICON,
route: '/institutions',
disabled: false,
queryParams: {
@@ -112,7 +127,7 @@ export class AppMenuComponent {
},
{
label: 'Publikationen',
icon: 'menu_book',
icon: PUBLICATION_ICON,
route: '/publications',
disabled: false,
queryParams: {
@@ -125,7 +140,7 @@ export class AppMenuComponent {
},
{
label: 'Themen',
icon: 'topic',
icon: TOPIC_ICON,
route: '/topics',
disabled: false,
queryParams: {
@@ -138,7 +153,7 @@ export class AppMenuComponent {
},
{
label: 'Projekte',
icon: 'work',
icon: PROJECT_ICON,
route: '/projects',
disabled: false,
queryParams: {
@@ -152,13 +167,13 @@ export class AppMenuComponent {
},
{
label: 'Patente',
icon: 'workspace_premium',
icon: PATENT_ICON,
route: '/patents',
disabled: false,
},
{
label: 'Keywords',
icon: 'join_left',
icon: KEYWORDS_ICON,
route: '/keywords',
disabled: false,
queryParams: {
@@ -167,21 +182,21 @@ export class AppMenuComponent {
},
{
label: 'Accounts',
icon: 'manage_accounts',
icon: MANAGE_ACCOUNTS_ICON,
route: '/accounts',
disabled: false,
managerOrAdminOnly: true,
},
{
label: 'Organisationen',
icon: 'domain',
icon: ORGANIZATIONS_ICON,
route: '/organizations',
disabled: false,
superAdminOnly: true,
},
{
label: 'Jobs',
icon: 'sync',
icon: JOBS_ICON,
route: '/jobs',
disabled: false,
superAdminOnly: true,
+18
View File
@@ -0,0 +1,18 @@
export const BOOKMARKS_ICON = "bookmarks" as const;
export const COMPANY_CONNECTION_ICON = 'business' as const;
export const DASHBOARD_ICON = 'dashboard' as const;
export const FUNDING_ICON = 'account_balance' as const;
export const INSTITUTION_ICON = 'school' as const;
export const JOBS_ICON = "sync" as const;
export const KEYWORDS_ICON = 'join_left' as const;
export const MANAGE_ACCOUNTS_ICON = 'manage_accounts' as const;
export const NETWORK_ICON = 'share' as const;
export const NEWS_ICON = 'newspaper' as const;
export const ORGANIZATIONS_ICON = 'domain' as const;
export const OVERVIEW_ICON = 'visibility' as const;
export const PATENT_ICON = 'workspace_premium' as const;
export const PERSONS_ICON = 'groups' as const;
export const PERSON_ICON = 'person' as const;
export const PROJECT_ICON = 'work' as const;
export const PUBLICATION_ICON = 'menu_book' as const;
export const TOPIC_ICON = 'topic' as const;
@@ -0,0 +1,19 @@
<nav mat-tab-nav-bar [tabPanel]="tabPanel()" mat-stretch-tabs="true">
@for (link of links(); track link.path) {
<a
mat-tab-link
[routerLink]="link.path"
[queryParams]="link.queryParams"
routerLinkActive
#rla="routerLinkActive"
[active]="rla.isActive"
[disabled]="link.disabled">
<div class="link-tab-nav-bar-item">
@if (link.icon) {
<mat-icon>{{ link.icon }}</mat-icon>
}
<span>{{ link.label }}</span>
</div>
</a>
}
</nav>
@@ -0,0 +1,5 @@
.link-tab-nav-bar-item {
display: flex;
align-items: center;
gap: 0.25rem;
}
@@ -0,0 +1,50 @@
import { Component, computed, inject, input } from '@angular/core';
import { MatTabNavPanel, MatTabsModule } from '@angular/material/tabs';
import {
ActivatedRoute,
isActive,
Router,
RouterModule,
} from '@angular/router';
import { MatIconModule } from '@angular/material/icon';
export type LinkTabNavBarItem = {
label: string;
path: string;
icon?: string;
description?: string;
queryParams?: Record<string, any>;
disabled?: boolean;
};
@Component({
selector: 'app-link-tab-nav-bar',
imports: [MatTabsModule, RouterModule, MatIconModule],
templateUrl: './link-tab-nav-bar.component.html',
styleUrl: './link-tab-nav-bar.component.scss',
})
export class LinkTabNavBarComponent {
private readonly router = inject(Router);
private readonly activatedRoute = inject(ActivatedRoute);
links = input.required<LinkTabNavBarItem[]>();
tabPanel = input<MatTabNavPanel>();
activeLink = computed<LinkTabNavBarItem | null>(() => {
for (const link of this.links()) {
const linkUrlTree = this.router.createUrlTree([link.path], {
relativeTo: this.activatedRoute,
});
if (
isActive(linkUrlTree, this.router, {
paths: 'subset',
queryParams: 'ignored',
})()
) {
return link;
}
}
return null;
});
}
+1 -2
View File
@@ -2,12 +2,11 @@
// For more information: https://material.angular.io/guide/theming
@use '@angular/material' as mat;
@use 'm3-theme' as m3;
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,200..700,0..1,-50..200');
@include mat.elevation-classes();
@include mat.app-background();
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,200..700,0..1,-50..200');
@font-face {
font-display: swap;
font-family: 'Montserrat';