feat(topic, institution): reused generic link tab nav bar
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -1,27 +1,15 @@
|
||||
<div class="content">
|
||||
<h1>{{ institution().display_name }}</h1>
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content>
|
||||
<p>{{ institution().homepage_url }}</p>
|
||||
<p>{{ institution().display_name_alternatives }}</p>
|
||||
<p>And many more useful details...</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<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>
|
||||
<div class="container">
|
||||
<div class="content">
|
||||
<h1>{{ institution().display_name }}</h1>
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content>
|
||||
<p>{{ institution().homepage_url }}</p>
|
||||
<p>{{ institution().display_name_alternatives }}</p>
|
||||
<p>And many more useful details...</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
<app-link-tab-nav-bar [links]="_links()" [tabPanel]="tabPanel" />
|
||||
</div>
|
||||
<mat-tab-nav-panel #tabPanel>
|
||||
<router-outlet />
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
.content {
|
||||
padding: 16px;
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
margin: 0 1rem;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { RouterLink, RouterOutlet, RouterLinkActive } from '@angular/router';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { Institution } from '../../api';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
|
||||
type TabLink = {
|
||||
label: string;
|
||||
path: string;
|
||||
disabled: boolean;
|
||||
queryParams?: Record<string, any>;
|
||||
};
|
||||
import {
|
||||
LinkTabNavBarComponent,
|
||||
LinkTabNavBarItem,
|
||||
} from '../../shared/ui/link-tab-nav-bar/link-tab-nav-bar.component';
|
||||
import {
|
||||
PATENT_ICON,
|
||||
PROJECT_ICON,
|
||||
PUBLICATION_ICON,
|
||||
} from '../../shared/ui/icons';
|
||||
|
||||
@Component({
|
||||
selector: 'app-institution',
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatTabsModule,
|
||||
RouterLink,
|
||||
RouterOutlet,
|
||||
RouterLinkActive,
|
||||
],
|
||||
imports: [MatCardModule, MatTabsModule, RouterModule, LinkTabNavBarComponent],
|
||||
templateUrl: './institution.component.html',
|
||||
styleUrl: './institution.component.scss',
|
||||
})
|
||||
@@ -27,14 +23,20 @@ export class InstitutionComponent {
|
||||
institution = input.required<Institution>();
|
||||
canFetchGdprRelevantData = input.required<boolean>();
|
||||
|
||||
_links = computed<TabLink[]>(() => {
|
||||
const links: TabLink[] = [
|
||||
{ label: 'Publikationen', path: 'publications', disabled: false },
|
||||
_links = computed<LinkTabNavBarItem[]>(() => {
|
||||
const links: LinkTabNavBarItem[] = [
|
||||
{
|
||||
label: 'Publikationen',
|
||||
icon: PUBLICATION_ICON,
|
||||
path: 'publications',
|
||||
disabled: false,
|
||||
},
|
||||
];
|
||||
if (this.canFetchGdprRelevantData()) {
|
||||
links.push(
|
||||
{
|
||||
label: 'Projekte',
|
||||
icon: PROJECT_ICON,
|
||||
path: 'projects',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
@@ -46,7 +48,12 @@ export class InstitutionComponent {
|
||||
sort_direction: 'asc',
|
||||
},
|
||||
},
|
||||
{ label: 'Patente', path: 'patents', disabled: false },
|
||||
{
|
||||
label: 'Patente',
|
||||
icon: PATENT_ICON,
|
||||
path: 'patents',
|
||||
disabled: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
return links;
|
||||
|
||||
@@ -31,21 +31,8 @@
|
||||
</div>
|
||||
|
||||
<mat-divider />
|
||||
<app-link-tab-nav-bar [links]="links" [tabPanel]="tabPanel" />
|
||||
<mat-tab-nav-panel #tabPanel>
|
||||
<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>
|
||||
<div class="outlet-container">
|
||||
<router-outlet />
|
||||
</div>
|
||||
|
||||
@@ -6,6 +6,11 @@ import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import { PUBLICATION_ICON } from '../../shared/ui/icons';
|
||||
import {
|
||||
LinkTabNavBarComponent,
|
||||
LinkTabNavBarItem,
|
||||
} from '../../shared/ui/link-tab-nav-bar/link-tab-nav-bar.component';
|
||||
|
||||
@Component({
|
||||
host: {
|
||||
@@ -18,6 +23,7 @@ import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
MatDividerModule,
|
||||
MatIconModule,
|
||||
DecimalPipe,
|
||||
LinkTabNavBarComponent,
|
||||
],
|
||||
templateUrl: './topic.component.html',
|
||||
styleUrl: './topic.component.scss',
|
||||
@@ -25,9 +31,10 @@ import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
export class TopicComponent {
|
||||
topic = input.required<Topic>();
|
||||
|
||||
links = [
|
||||
links: LinkTabNavBarItem[] = [
|
||||
{
|
||||
label: 'Publikationen',
|
||||
icon: PUBLICATION_ICON,
|
||||
path: 'publications',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
|
||||
Reference in New Issue
Block a user