moved publications table to a separate component

This commit is contained in:
2026-06-25 21:47:43 +02:00
parent 400a504a89
commit f9fc8addce
6 changed files with 576 additions and 86 deletions
@@ -557,8 +557,10 @@
@if (activeTab === 'organizations' && euProject.organizations) {
<app-organizations-table [orgs]="euProject.organizations"/>
}
<!-- Publications Tab -->
@if (activeTab === 'publications' && euProject.publications) {
<app-publications-table [publications]="euProject.publications"/>
}
<!-- Publications Tab
@if (activeTab === 'publications' && euProject.publications) {
<div class="publications-tab">
<mat-card appearance="outlined" class="card">
@@ -614,7 +616,7 @@
</div>
</mat-card>
</div>
}
} -->
<!-- IPRs Tab -->
@if (activeTab === 'iprs' && euProject.iprs) {
@@ -626,7 +628,7 @@
</div>
<div class="iprs-list">
@for (ipr of euProject.iprs; track ipr.title) {
<div class="ipr-item">
<div class="ipr-item" (click)="searchForPatent(ipr)">
<div class="ipr-icon">
@if (ipr.type === 'PATENT') {
<mat-icon>emoji_events</mat-icon>
@@ -269,13 +269,13 @@ h1 {
padding: 0;
}
.section-header {
display: flex;
align-items: center;
gap: 10px;
padding: 16px 20px 12px;
border-bottom: 1px solid #f0f2f5;
}
.section-header {
display: flex;
align-items: center;
gap: 12px;
padding: 16px 20px;
border-bottom: 1px solid #e6e9ed;
}
.section-header mat-icon {
color: var(--sg-text-muted);
@@ -286,7 +286,7 @@ h1 {
.section-header h2 {
margin: 0;
font-size: 16px;
font-size: 18px;
font-weight: 600;
color: var(--sg-text);
}
@@ -16,8 +16,8 @@ import {
import { EuProjectData } from '../../../api/model/euProjectData';
import { TopicChipComponent } from '../../../shared/ui/topic-chip/topic-chip.component';
import { OrganizationsTableComponent } from './organizations-table/organizations-table/organizations-table.component';
import { HEUPublication } from '../../../api';
import { Fp7ProjectIPR } from '../../../api';
import { PublicationsTableComponent } from './publications-table/publications-table.component';
export type TabType =
| 'overview'
| 'organizations'
@@ -38,6 +38,7 @@ export type TabType =
MatTooltipModule,
TopicChipComponent,
OrganizationsTableComponent,
PublicationsTableComponent
],
templateUrl: './eu-details.component.html',
styleUrl: './eu-details.component.scss',
@@ -49,27 +50,30 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
// Data
euProject: EuProjectData | undefined;
programType: string = '';
// UI State
activeTab: TabType = 'overview';
isLoading = true;
// Tab content flags
hasOrganizations = false;
hasPublications = false;
hasIprs = false;
hasDeliverables = false;
// Subscriptions
private subscriptions: Subscription = new Subscription();
// Tab configuration
private readonly tabConfig: Record<TabType, { label: string; icon: string; order: number }> = {
private readonly tabConfig: Record<
TabType,
{ label: string; icon: string; order: number }
> = {
overview: { label: 'Übersicht', icon: 'info', order: 0 },
organizations: { label: 'Organisationen', icon: 'business', order: 1 },
publications: { label: 'Publikationen', icon: 'article', order: 2 },
iprs: { label: 'IPRs', icon: 'gavel', order: 3 },
deliverables: { label: 'Ergebnisse', icon: 'assignment', order: 4 }
deliverables: { label: 'Ergebnisse', icon: 'assignment', order: 4 },
};
ngOnInit(): void {
@@ -85,7 +89,7 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
this.updateTabContentFlags();
this.handleTabFromQueryParams();
}
})
}),
);
// Subscribe to query params changes
@@ -95,7 +99,7 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
if (this.euProject) {
this.handleTabFromQueryParams(params);
}
})
}),
);
}
@@ -122,14 +126,20 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
* Update flags for which tabs have content
*/
private updateTabContentFlags(): void {
this.hasOrganizations =
(this.euProject?.organizations && this.euProject.organizations.length > 0) || false;
this.hasPublications =
(this.euProject?.publications && this.euProject.publications.length > 0) || false;
this.hasIprs =
this.hasOrganizations =
(this.euProject?.organizations &&
this.euProject.organizations.length > 0) ||
false;
this.hasPublications =
(this.euProject?.publications &&
this.euProject.publications.length > 0) ||
false;
this.hasIprs =
(this.euProject?.iprs && this.euProject.iprs.length > 0) || false;
this.hasDeliverables =
(this.euProject?.deliverables && this.euProject.deliverables.length > 0) || false;
this.hasDeliverables =
(this.euProject?.deliverables &&
this.euProject.deliverables.length > 0) ||
false;
}
/**
@@ -138,7 +148,7 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
private handleTabFromQueryParams(params?: any): void {
const queryParams = params || this.route.snapshot.queryParams;
const tabParam = queryParams['tab'] as TabType;
if (tabParam && this.isValidTab(tabParam)) {
if (this.tabHasContent(tabParam)) {
this.activeTab = tabParam;
@@ -158,7 +168,13 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
* Check if a tab value is valid
*/
private isValidTab(tab: string): tab is TabType {
return ['overview', 'organizations', 'publications', 'iprs', 'deliverables'].includes(tab);
return [
'overview',
'organizations',
'publications',
'iprs',
'deliverables',
].includes(tab);
}
/**
@@ -189,11 +205,13 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
const currentTab = this.route.snapshot.queryParams['tab'];
if (currentTab === tab) return;
this.router.navigate([], {
relativeTo: this.route,
queryParams: { tab: tab },
queryParamsHandling: 'merge',
}).catch(err => console.error('Tab navigation failed:', err));
this.router
.navigate([], {
relativeTo: this.route,
queryParams: { tab: tab },
queryParamsHandling: 'merge',
})
.catch((err) => console.error('Tab navigation failed:', err));
}
/**
@@ -220,7 +238,7 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
*/
setTab(tab: TabType): void {
if (this.activeTab === tab) return;
// Check if tab has content
if (!this.tabHasContent(tab)) {
console.warn(`Tab "${tab}" has no content`);
@@ -281,8 +299,16 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
* Get sorted tabs that have content
*/
getVisibleTabs(): TabType[] {
return (['overview', 'organizations', 'publications', 'iprs', 'deliverables'] as TabType[])
.filter(tab => this.tabHasContent(tab))
return (
[
'overview',
'organizations',
'publications',
'iprs',
'deliverables',
] as TabType[]
)
.filter((tab) => this.tabHasContent(tab))
.sort((a, b) => this.tabConfig[a].order - this.tabConfig[b].order);
}
@@ -323,7 +349,10 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
const statusUpper = status.toUpperCase();
if (statusUpper.includes('CLOSED') || statusUpper.includes('COMPLETED')) {
return '#27ae60';
} else if (statusUpper.includes('ONGOING') || statusUpper.includes('ACTIVE')) {
} else if (
statusUpper.includes('ONGOING') ||
statusUpper.includes('ACTIVE')
) {
return '#f39c12';
} else if (statusUpper.includes('SIGNED')) {
return '#3498db';
@@ -369,13 +398,15 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
if (!scheme) return 'N/A';
const schemeMap: { [key: string]: string } = {
'MSCA-IF-EF-SE': 'MSCA Individual Fellowship - European Fellowship - Standard',
'MSCA-IF-EF-SE':
'MSCA Individual Fellowship - European Fellowship - Standard',
'MSCA-IF-EF': 'MSCA Individual Fellowship - European Fellowship',
'MSCA-IF-GF': 'MSCA Individual Fellowship - Global Fellowship',
'MSCA-IF': 'MSCA Individual Fellowship',
'MSCA-ITN': 'MSCA Innovative Training Networks',
'MSCA-RISE': 'MSCA Research and Innovation Staff Exchange',
'MSCA-COFUND': 'MSCA Co-funding of Regional, National and International Programmes',
'MSCA-COFUND':
'MSCA Co-funding of Regional, National and International Programmes',
};
return schemeMap[scheme] || scheme;
@@ -464,10 +495,12 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
console.warn('Cannot search with empty topic');
return;
}
this.router.navigate(['/eu-projects'], {
queryParams: { topic: topic },
}).catch(err => console.error('Navigation to topic failed:', err));
this.router
.navigate(['/eu-projects'], {
queryParams: { topic: topic },
})
.catch((err) => console.error('Navigation to topic failed:', err));
}
/**
@@ -478,10 +511,12 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
console.warn('Cannot search with empty keyword');
return;
}
this.router.navigate(['/eu-projects'], {
queryParams: { keyword: keyword },
}).catch(err => console.error('Navigation to keyword failed:', err));
this.router
.navigate(['/eu-projects'], {
queryParams: { keyword: keyword },
})
.catch((err) => console.error('Navigation to keyword failed:', err));
}
/**
@@ -492,10 +527,12 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
console.warn('Cannot search with empty framework');
return;
}
this.router.navigate(['/eu-projects'], {
queryParams: { framework: framework },
}).catch(err => console.error('Navigation to framework failed:', err));
this.router
.navigate(['/eu-projects'], {
queryParams: { framework: framework },
})
.catch((err) => console.error('Navigation to framework failed:', err));
}
/**
@@ -506,10 +543,14 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
console.warn('Cannot search with empty funding scheme');
return;
}
this.router.navigate(['/eu-projects'], {
queryParams: { fundingScheme: scheme },
}).catch(err => console.error('Navigation to funding scheme failed:', err));
this.router
.navigate(['/eu-projects'], {
queryParams: { fundingScheme: scheme },
})
.catch((err) =>
console.error('Navigation to funding scheme failed:', err),
);
}
/**
@@ -520,40 +561,26 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
console.warn('Cannot search with empty status');
return;
}
this.router.navigate(['/eu-projects'], {
queryParams: { status: status },
}).catch(err => console.error('Navigation to status failed:', err));
this.router
.navigate(['/eu-projects'], {
queryParams: { status: status },
})
.catch((err) => console.error('Navigation to status failed:', err));
}
/**
* Navigate to publication details
*/
searchForPublication(pub: HEUPublication): void {
if (!pub) {
console.warn('Cannot navigate with empty publication');
return;
}
const doi = pub.doi?.trim() ?? "unknown";
// Encode DOI and navigate
const encodedDoi = encodeURIComponent(doi);
this.router.navigate(['/publication', encodedDoi], {
queryParams: {
title: pub.title || ''
},
}).catch(err => console.error('Navigation to publication failed:', err));
searchForPatent(patent: Fp7ProjectIPR) {
console.log(patent)
}
/**
* Navigate back to projects list with optional filter
*/
goBack(filters?: { [key: string]: any }): void {
this.router.navigate(['/eu-projects'], {
queryParams: filters || {},
queryParamsHandling: 'merge',
}).catch(err => console.error('Navigation back failed:', err));
this.router
.navigate(['/eu-projects'], {
queryParams: filters || {},
queryParamsHandling: 'merge',
})
.catch((err) => console.error('Navigation back failed:', err));
}
}
}
@@ -0,0 +1,141 @@
<div class="publications-tab">
<mat-card appearance="outlined" class="card">
@if (showHeader) {
<div class="section-header">
<mat-icon>description</mat-icon>
<h2>{{ headerTitle }} ({{ getPublicationCount() }})</h2>
</div>
}
<div>
<table mat-table [dataSource]="publications" class="mat-elevation-z2">
<!-- Title Column -->
<ng-container matColumnDef="title">
<th mat-header-cell *matHeaderCellDef>Titel</th>
<td mat-cell *matCellDef="let pub">
<div
class="pub-title-cell"
(click)="searchForPublication(pub)">
<span class="pub-title-text">
{{ pub.title || 'Kein Titel' }}
</span>
</div>
</td>
</ng-container>
<!-- Authors Column -->
<ng-container matColumnDef="authors">
<th mat-header-cell *matHeaderCellDef>Autoren</th>
<td mat-cell *matCellDef="let pub">
@if (pub.authors) {
@let authorList = parseAuthors(pub.authors);
@if (authorList.length > 0) {
<div class="authors-container">
@for (author of authorList; track author; let last = $last) {
<span class="author-wrapper">
<span
class="author-name"
(click)="searchForPersonName(author); $event.stopPropagation()">
{{ author }}
</span>
@if (!last) {
<span class="author-separator">, </span>
}
</span>
}
</div>
} @else {
<span class="empty-value">—</span>
}
} @else {
<span class="empty-value">—</span>
}
</td>
</ng-container>
<!-- Journal Column -->
<ng-container matColumnDef="journal">
<th mat-header-cell *matHeaderCellDef>Zeitschrift</th>
<td mat-cell *matCellDef="let pub">
@if (pub.journalTitle) {
<span class="journal-chip">{{ pub.journalTitle }}</span>
} @else {
<span class="empty-value">—</span>
}
</td>
</ng-container>
<!-- Year Column -->
<ng-container matColumnDef="year">
<th mat-header-cell *matHeaderCellDef>Jahr</th>
<td mat-cell *matCellDef="let pub">
@if (pub.publishedYear) {
<span class="year-value">{{ pub.publishedYear }}</span>
} @else {
<span class="empty-value">—</span>
}
</td>
</ng-container>
<!-- Publisher Column -->
<ng-container matColumnDef="publisher">
<th mat-header-cell *matHeaderCellDef>Verlag</th>
<td mat-cell *matCellDef="let pub">
@if (pub.publisher) {
<span class="publisher-text">{{ pub.publisher }}</span>
} @else {
<span class="empty-value">—</span>
}
</td>
</ng-container>
<!-- Links Column -->
<ng-container matColumnDef="links">
<th mat-header-cell *matHeaderCellDef>Links</th>
<td mat-cell *matCellDef="let pub">
<div class="links-container">
@if (pub.doi) {
<a
[href]="'https://doi.org/' + pub.doi"
target="_blank"
class="link-button"
matTooltip="DOI öffnen">
<mat-icon class="link-icon">open_in_new</mat-icon>
<span class="link-label">DOI</span>
</a>
}
@if (pub.repositoryUrl) {
<a
[href]="pub.repositoryUrl"
target="_blank"
class="link-button"
matTooltip="Repository öffnen">
<mat-icon class="link-icon">folder_open</mat-icon>
<span class="link-label">Repo</span>
</a>
}
@if (pub.publicationUrl) {
<a
[href]="pub.publicationUrl"
target="_blank"
class="link-button"
matTooltip="Publikation öffnen">
<mat-icon class="link-icon">article</mat-icon>
<span class="link-label">Link</span>
</a>
}
@if (!pub.doi && !pub.repositoryUrl && !pub.publicationUrl) {
<span class="empty-value">—</span>
}
</div>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="publicationDisplayedColumns"></tr>
<tr
mat-row
*matRowDef="let row; columns: publicationDisplayedColumns"
class="publication-row"></tr>
</table>
</div>
</mat-card>
</div>
@@ -0,0 +1,233 @@
// Publications Table
.publications-tab {
.card {
margin-bottom: 24px;
}
.section-header {
display: flex;
align-items: center;
gap: 12px;
padding: 16px 20px;
border-bottom: 1px solid #e6e9ed;
mat-icon {
color: #6b7a8a;
font-size: 24px;
width: 24px;
height: 24px;
}
h2 {
margin: 0;
font-size: 18px;
font-weight: 600;
color: #1a1a1a;
}
}
table {
width: 100%;
border-radius: 8px;
overflow: hidden;
}
.mat-mdc-header-cell {
font-weight: 600;
color: #6b7a8a;
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.5px;
background: #f8fafc;
border-bottom: 2px solid #e6e9ed;
padding: 12px 16px;
}
.mat-mdc-cell {
padding: 12px 16px;
border-bottom: 1px solid #f0f2f5;
font-size: 13px;
}
.mat-mdc-row {
transition: background 0.2s ease;
cursor: pointer;
}
.mat-mdc-row:hover {
background: #f8fafc;
}
.pub-title-cell {
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
}
.pub-title-text {
font-weight: 500;
color: #1a1a1a;
line-height: 1.4;
}
.pub-title-cell:hover .pub-title-text {
color: #005a9c;
text-decoration: underline;
}
.authors-text {
color: #4a5a6a;
font-size: 13px;
color: #1a1a1a;
line-height: 1.4;
}
.author-name:hover {
color: #005a9c;
text-decoration: underline;
}
.journal-chip {
display: inline-block;
padding: 2px 10px;
background: #e8edf5;
border-radius: 12px;
font-size: 12px;
color: #6b7a8a;
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.year-value {
font-weight: 500;
color: #1a1a1a;
}
.publisher-text {
color: #4a5a6a;
font-size: 13px;
}
.empty-value {
color: #6b7a8a;
font-size: 13px;
}
.links-container {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.link-button {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
background: #f0f3f7;
border-radius: 12px;
color: #4a5a6a;
text-decoration: none;
font-size: 11px;
font-weight: 500;
transition: all 0.2s ease;
&:hover {
background: #e8edf5;
color: #005a9c;
transform: translateY(-1px);
}
.link-icon {
font-size: 14px;
width: 14px;
height: 14px;
color: #6b7a8a;
}
.link-label {
font-size: 10px;
text-transform: uppercase;
letter-spacing: 0.3px;
}
}
// Responsive styles
@media (max-width: 768px) {
.section-header {
padding: 12px 16px;
h2 {
font-size: 16px;
}
}
.mat-mdc-header-cell,
.mat-mdc-cell {
padding: 8px 10px;
font-size: 12px;
}
.publicationDisplayedColumns {
// Hide less important columns on mobile
.mat-column-publisher {
display: none;
}
}
.journal-chip {
max-width: 120px;
font-size: 11px;
}
.link-button {
padding: 2px 8px;
font-size: 10px;
.link-label {
display: none;
}
}
.pub-title-text {
font-size: 13px;
}
}
@media (max-width: 480px) {
.mat-column-journal {
display: none;
}
.mat-column-publisher {
display: none;
}
.mat-mdc-cell {
padding: 6px 8px;
font-size: 11px;
}
.authors-text {
font-size: 11px;
max-width: 100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
}
.links-container {
gap: 4px;
}
.link-button {
padding: 2px 6px;
font-size: 9px;
}
}
}
@@ -0,0 +1,87 @@
import { Component, computed, inject, Input } from '@angular/core';
import { MatTableModule } from '@angular/material/table';
import { Router } from '@angular/router';
import { MatIcon } from '@angular/material/icon';
import { MatCard } from '@angular/material/card';
import { MatTooltipModule } from '@angular/material/tooltip';
import { CommonModule } from '@angular/common';
import { HEUPublication } from '../../../../api';
@Component({
selector: 'app-publications-table',
imports: [CommonModule, MatTableModule, MatIcon, MatCard, MatTooltipModule],
templateUrl: './publications-table.component.html',
styleUrl: './publications-table.component.scss',
})
export class PublicationsTableComponent {
private router = inject(Router);
@Input() publications: HEUPublication[] = [];
@Input() showHeader: boolean = true;
@Input() headerTitle: string = 'Publikationen';
// Displayed columns for the publications table
publicationDisplayedColumns: string[] = [
'title',
'authors',
'journal',
'year',
'publisher',
'links',
];
author_names = computed(() => 'keka');
/**
* Navigate to publication details
*/
searchForPublication(pub: HEUPublication): void {
if (!pub) {
console.warn('Cannot navigate with empty publication');
return;
}
const doi = pub.doi?.trim() ?? 'unknown';
// Encode DOI and navigate
const encodedDoi = encodeURIComponent(doi);
this.router
.navigate(['/publication', encodedDoi], {
queryParams: {
title: pub.title || '',
},
})
.catch((err) => console.error('Navigation to publication failed:', err));
}
getPublicationCount(): number {
return this.publications?.length || 0;
}
searchForPersonName(personName: string): void {
this.router.navigate(['/persons'], {
queryParams: {
query: personName,
},
});
}
// Parse authors string into array of individual authors
parseAuthors(authorsString: string | undefined): string[] {
if (!authorsString) return [];
// Common separators: 'and', ',', ';', '&'
// Also handle cases like "Author1, Author2 and Author3"
let authors = authorsString;
// Replace ' and ' with ', ' for consistent splitting
authors = authors.replace(/\s+and\s+/g, ', ');
// Split by common separators
let authorList = authors.split(/[,;]\s*/);
// Clean up each author name
authorList = authorList
.map((author) => author.trim())
.filter((author) => author.length > 0);
return authorList;
}
}