From 27f289f4a0392359d4695892efcd9fabc7f4a26f Mon Sep 17 00:00:00 2001 From: Khuder Khalti Date: Mon, 27 Jul 2026 21:22:49 +0200 Subject: [PATCH] refactor(person-funding): reuse shared publication-detail page for 'Mehr Infos' instead of duplicated inline panel --- .../person-funding.component.html | 305 +--------------- .../person-funding.component.scss | 286 +-------------- .../person-funding.component.ts | 345 +----------------- 3 files changed, 7 insertions(+), 929 deletions(-) diff --git a/webapp/src/app/modules/person-funding/person-funding.component.html b/webapp/src/app/modules/person-funding/person-funding.component.html index 00805abc..b154301f 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.html +++ b/webapp/src/app/modules/person-funding/person-funding.component.html @@ -4,303 +4,6 @@

Fehler beim Laden der Förderungen.

} @else if (funders.length === 0) {

Keine Förderungen gefunden.

-} @else if (selectedPublicationDetailId) { - @if (getSelectedPublicationDetail(); as publication) { -
- - -
-
-
- @if (publication.publication_year) { - {{ publication.publication_year }} - } - @if (hasTextValue(getPublicationTypeLabel(publication))) { - {{ getPublicationTypeLabel(publication) }} - } - @if (hasTextValue(getLanguageLabel(publication))) { - {{ getLanguageLabel(publication) }} - } -
-

{{ publication.title }}

- @if (hasPublicationSource(publication)) { -

- {{ getPublicationSourceLabel(publication) }} -

- } -

- {{ getPublicationAuthors(publication) }} -

-
- @if (typeof publication.cited_by_count === 'number') { - - {{ - publication.cited_by_count - }} - Zitationen - - } - - {{ getOpenAccessBadge(publication).label }} - - - {{ getPositionLabel(publication.author_position || 'unknown') }} - -
-
- @if (getPublicationExternalUrl(publication); as externalUrl) { - - Zur Publikation - open_in_new - - } -
- -
-
-
-

Überblick

-

-
- -
-

Abstract

-

- {{ publication.abstract || 'Kein Abstract vorhanden.' }} -

-
- - @if (publication.publication_date) { -
-

Publikationsdaten

-
-
-
Datum
-
{{ getPublicationDateLabel(publication) }}
-
-
-
- } - - @if ( - hasTextValue(publication.primary_topic) || - hasTextValue(publication.topic_field) || - hasTextValue(publication.topic_subfield) || - hasTextValue(publication.topic_domain) || - hasListValues(publication.topics) || - hasListValues(publication.keywords) - ) { -
-

Einordnung

-
- @if (hasTextValue(publication.primary_topic)) { -
-
Hauptthema
-
{{ publication.primary_topic }}
-
- } - @if (hasTextValue(publication.topic_field)) { -
-
Fachgebiet
-
{{ publication.topic_field }}
-
- } - @if (hasTextValue(publication.topic_subfield)) { -
-
Teilgebiet
-
{{ publication.topic_subfield }}
-
- } - @if (hasTextValue(publication.topic_domain)) { -
-
Bereich
-
{{ publication.topic_domain }}
-
- } - @if (hasListValues(publication.topics)) { -
-
Themen
-
-
    - @for (topic of publication.topics; track topic) { -
  • {{ topic }}
  • - } -
-
-
- } - @if (hasListValues(publication.keywords)) { -
-
Keywords
-
-
    - @for (keyword of publication.keywords; track keyword) { -
  • {{ keyword }}
  • - } -
-
-
- } -
-
- } - - @if ( - getCitationCountsByYear(publication).length || - publication.is_retracted - ) { -
-

Wirkung

-
- @if (getCitationCountsByYear(publication); as citationYears) { - @if (citationYears.length) { -
-
Zitiert pro Jahr
-
- - - @for (entry of citationYears; track entry.year) { - - - - - } - -
{{ entry.year }}{{ entry.count }}
-
-
- } - } - @if (publication.is_retracted) { -
-
Zurückgezogen
-
- Ja, zurückgezogen -
-
- } -
-
- } - -
-

Zugang

-
-
-
Open Access
-
- - {{ getOpenAccessBadge(publication).label }} - -
-
-
-
Volltext
-
- {{ getFulltextLabel(publication) }} - @if (publication.pdf_url) { - - PDF öffnen - open_in_new - - } -
-
- @if (hasTextValue(getLicenseLabel(publication))) { -
-
Lizenz
-
{{ getLicenseLabel(publication) }}
-
- } -
-
-
- - -
-
- } } @else {
@@ -412,16 +115,16 @@ getPublicationTitle(id) }} @if (expandedPublicationId === id) { - + } } diff --git a/webapp/src/app/modules/person-funding/person-funding.component.scss b/webapp/src/app/modules/person-funding/person-funding.component.scss index 2cc57090..debe3dff 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.scss +++ b/webapp/src/app/modules/person-funding/person-funding.component.scss @@ -144,9 +144,7 @@ } } -.position-badge--first, -.hero-highlight--open, -.publication-detail-grid .access-badge--open { +.position-badge--first { background: #effaf3; border-color: #bdebcf; color: #24834f; @@ -311,281 +309,16 @@ } } -.funding-publication-page { - padding: 16px; -} - -.publication-detail-back, .publication-more-info { display: inline-flex; align-items: center; border: 0; background: transparent; cursor: pointer; -} - -.publication-detail-back { - gap: 6px; -} - -.publication-more-info { gap: 4px; margin-top: 6px; padding: 0; -} - -.publication-detail-hero { - display: flex; - justify-content: space-between; - gap: 20px; - align-items: flex-start; - padding: 24px; - border: 1px solid #dbe3f2; - border-radius: 12px; - margin-bottom: 16px; - background: - radial-gradient( - circle at 95% 5%, - rgba(200, 217, 255, 0.45), - transparent 35% - ), - linear-gradient(140deg, #fff 0%, #f8faff 100%); - - &__content { - min-width: 0; - flex: 1; - } - - &__meta { - display: flex; - flex-wrap: wrap; - gap: 8px; - margin-bottom: 12px; - - span { - padding: 4px 10px; - border: 1px solid #dbe3f2; - border-radius: 999px; - background: rgba(255, 255, 255, 0.9); - color: #64748b; - font-size: 0.75rem; - font-weight: 700; - text-transform: uppercase; - } - } - - h2 { - margin: 0 0 10px; - font-size: clamp(1.25rem, 2vw, 1.75rem); - line-height: 1.25; - color: #1e3a5f; - } - - &__source { - margin: 0 0 8px; - color: #334155; - font-weight: 600; - line-height: 1.4; - } - - &__authors { - margin: 0 0 16px; - color: #64748b; - line-height: 1.5; - font-size: 0.9rem; - } - - &__highlights { - display: flex; - flex-wrap: wrap; - gap: 8px; - align-items: center; - } - - &__action { - display: inline-flex; - align-items: center; - gap: 6px; - padding: 10px 16px; - border: 1px solid #bdd4ff; - border-radius: 8px; - background: #f0f6ff; - color: #0b63ce; - font-weight: 600; - font-size: 0.875rem; - text-decoration: none; - - .material-icons { - font-size: 18px; - } - } -} - -.hero-highlight { - display: inline-flex; - flex-direction: column; - padding: 8px 12px; - border: 1px solid #e0e6f0; - border-radius: 8px; - background: rgba(255, 255, 255, 0.85); - - &__value { - font-size: 1.25rem; - font-weight: 700; - color: #1e3a5f; - line-height: 1.1; - } - - &__label { - font-size: 0.7rem; - color: #64748b; - text-transform: uppercase; - } - - &--badge { - flex-direction: row; - align-items: center; - min-width: 0; - font-size: 0.8rem; - font-weight: 600; - color: #475569; - } - - &--closed { - border-color: #e0e6f0; - background: #f8fafc; - color: #64748b; - } -} - -.position-badge { - display: inline-flex; - align-items: center; - padding: 6px 12px; - border-radius: 999px; - font-size: 0.8rem; - font-weight: 700; - - &--unknown { - background: #f1f5f9; - color: #64748b; - border: 1px solid #e2e8f0; - } -} - -$g: '.publication-detail-grid'; - -#{$g} { - display: grid; - grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); - gap: 12px; -} - -#{$g} .publication-detail-main, -#{$g} .publication-detail-side { - display: grid; - gap: 12px; - min-width: 0; -} - -#{$g} .publication-detail-section { - border: 1px solid #e0e6f0; - border-radius: 10px; - padding: 18px; - background: #fff; - - h3 { - margin: 0 0 14px; - font-size: 1rem; - color: #1e3a5f; - } -} - -#{$g} .publication-overview, -#{$g} .publication-abstract { - margin: 0; - color: #334155; - line-height: 1.65; -} - -#{$g} .publication-detail-facts { - display: grid; - gap: 12px; - margin: 0; -} - -#{$g} .publication-detail-facts div { - display: grid; - grid-template-columns: 130px minmax(0, 1fr); - gap: 12px; -} - -#{$g} .publication-detail-facts dt { - color: #64748b; - font-size: 0.875rem; -} - -#{$g} .publication-detail-facts dd { - margin: 0; - word-break: break-word; - color: #1e293b; -} - -#{$g} .tag-list { - display: flex; - flex-wrap: wrap; - gap: 6px; - margin: 0; - padding: 0; - list-style: none; -} - -#{$g} .tag, -#{$g} .access-badge, -#{$g} .warning-badge { - display: inline-flex; - padding: 4px 10px; - border-radius: 999px; - font-size: 0.8rem; -} - -#{$g} .tag { - background: #f0f6ff; - border: 1px solid #dbeafe; - color: #1e40af; - line-height: 1.3; -} - -#{$g} .access-badge { - font-weight: 600; - background: #f1f5f9; - color: #64748b; -} - -#{$g} .access-badge--closed { - background: #f8fafc; - color: #475569; -} - -#{$g} .inline-action { - display: inline-flex; - align-items: center; - gap: 4px; - color: #0b63ce; - font-weight: 600; - font-size: 0.875rem; text-decoration: none; - - .material-icons { - font-size: 16px; - } -} - -#{$g} .warning-badge { - background: #fef2f2; - border: 1px solid #fecaca; - color: #b91c1c; - font-weight: 600; } .publication-item { @@ -620,20 +353,3 @@ $g: '.publication-detail-grid'; font-size: 16px; } } - -@media (max-width: 720px) { - .publication-detail-hero { - flex-direction: column; - align-items: stretch; - - &__action { - justify-content: center; - } - } -} - -@media (max-width: 960px) { - #{$g} { - grid-template-columns: 1fr; - } -} diff --git a/webapp/src/app/modules/person-funding/person-funding.component.ts b/webapp/src/app/modules/person-funding/person-funding.component.ts index 250711b4..e86450b8 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.ts +++ b/webapp/src/app/modules/person-funding/person-funding.component.ts @@ -1,7 +1,6 @@ import { Component, OnInit, inject } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, RouterLink } from '@angular/router'; import { Router } from '@angular/router'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatSelectModule } from '@angular/material/select'; @@ -11,52 +10,19 @@ import { FundingService } from '../../api'; type SortMode = 'name' | 'top'; type AuthorPosition = 'first' | 'middle' | 'last' | 'unknown'; -type CitationCountByYear = { - year: number; - count: number; -}; - type FundingPublicationDetail = { id: string; title: string; - abstract?: string | null; - doi?: string | null; - publication_year?: number | null; - publication_date?: string | null; - publication_type?: string | null; - language?: string | null; publication_url?: string | null; - pdf_url?: string | null; - source_name?: string | null; - source_type?: string | null; - is_open_access?: boolean | null; - open_access_status?: string | null; - has_fulltext?: boolean | null; - license?: string | null; - cited_by_count?: number | null; - is_retracted?: boolean | null; - primary_topic?: string | null; - topic_field?: string | null; - topic_subfield?: string | null; - topic_domain?: string | null; author_position?: AuthorPosition | string | null; authors?: string[]; - funder_names?: string[]; - institutions?: string[]; - countries?: string[]; - topics?: string[]; - keywords?: string[]; - grant_labels?: string[]; - counts_by_year?: Array<{ - year?: number | null; - cited_by_count?: number | null; - }>; }; @Component({ selector: 'app-person-funding', imports: [ CommonModule, + RouterLink, MatFormFieldModule, MatSelectModule, MatIconModule, @@ -68,15 +34,12 @@ export class PersonFundingComponent implements OnInit { private route = inject(ActivatedRoute); private router = inject(Router); private fundingApi = inject(FundingService); - private sanitizer = inject(DomSanitizer); private initialSelectedFunderKey: string | null = null; private initialPublicationPage = 1; private initialFunderListPage = 1; - private initialPublicationDetailId: string | null = null; funders: any[] = []; filteredFunders: any[] = []; - authorName: string | null = null; selectedFunder: any = null; selectedFunderListPage = 1; selectedPublicationPage = 1; @@ -87,7 +50,6 @@ export class PersonFundingComponent implements OnInit { loading = true; error = false; expandedPublicationId: string | null = null; - selectedPublicationDetailId: string | null = null; ngOnInit(): void { this.route.parent?.paramMap.subscribe((params) => { @@ -96,8 +58,6 @@ export class PersonFundingComponent implements OnInit { const sortFromUrl = this.route.snapshot.queryParamMap.get('sortBy'); this.initialSelectedFunderKey = this.route.snapshot.queryParamMap.get('funder'); - this.initialPublicationDetailId = - this.route.snapshot.queryParamMap.get('publicationDetail'); this.initialPublicationPage = this.parsePageParam( this.route.snapshot.queryParamMap.get('publicationPage') ?? this.route.snapshot.queryParamMap.get('page'), @@ -116,7 +76,6 @@ export class PersonFundingComponent implements OnInit { this.fundingApi.getFundersByAuthor(authorId).subscribe({ next: (result: any) => { this.funders = result.funders ?? []; - this.authorName = result.author_name ?? null; this.applyFilter(); this.selectedFunderListPage = this.clampPage( this.initialFunderListPage, @@ -137,7 +96,6 @@ export class PersonFundingComponent implements OnInit { selectFunder(funder: any): void { this.selectedFunder = funder; this.selectedPublicationPage = 1; - this.selectedPublicationDetailId = null; this.updateQueryParams(); } @@ -155,7 +113,6 @@ export class PersonFundingComponent implements OnInit { private applyFilter(): void { this.selectedFunder = null; - this.selectedPublicationDetailId = null; this.selectedFunderListPage = 1; this.selectedPublicationPage = 1; let funders: any[]; @@ -193,14 +150,6 @@ export class PersonFundingComponent implements OnInit { this.initialPublicationPage, this.getPublicationPageCountForFunder(matchedFunder), ); - if ( - this.initialPublicationDetailId && - this.getPublicationIds(matchedFunder).includes( - this.initialPublicationDetailId, - ) - ) { - this.selectedPublicationDetailId = this.initialPublicationDetailId; - } this.updateQueryParams(); } else { this.updateQueryParams(); @@ -219,7 +168,6 @@ export class PersonFundingComponent implements OnInit { publicationPage: this.selectedFunder ? this.selectedPublicationPage : null, - publicationDetail: this.selectedPublicationDetailId, funderPage: this.selectedFunderListPage, }, queryParamsHandling: 'merge', @@ -409,25 +357,6 @@ export class PersonFundingComponent implements OnInit { this.expandedPublicationId = this.expandedPublicationId === id ? null : id; } - openPublicationDetail(event: MouseEvent, publicationId: string): void { - event.stopPropagation(); - this.selectedPublicationDetailId = publicationId; - this.expandedPublicationId = null; - this.updateQueryParams(); - } - - closePublicationDetail(): void { - this.selectedPublicationDetailId = null; - this.updateQueryParams(); - } - - getSelectedPublicationDetail(): FundingPublicationDetail | null { - if (!this.selectedPublicationDetailId) { - return null; - } - return this.getPublicationDetail(this.selectedPublicationDetailId); - } - getPublicationDetail(publicationId: string): FundingPublicationDetail | null { const detail = this.selectedFunder?.publication_details?.[publicationId]; if (detail) { @@ -452,64 +381,6 @@ export class PersonFundingComponent implements OnInit { return parts[parts.length - 1] ?? publicationId; } - getPublicationExternalUrl( - publication: FundingPublicationDetail, - ): string | null { - return ( - publication.publication_url ?? - this.selectedFunder?.publication_urls?.[publication.id] ?? - publication.id ?? - null - ); - } - - getPublicationAuthors(publication: FundingPublicationDetail): string { - return publication.authors?.length - ? publication.authors.join(', ') - : 'Keine Angaben'; - } - - hasPublicationSource(publication: FundingPublicationDetail): boolean { - return !!publication.source_name; - } - - hasListValues(values?: string[] | null): boolean { - return !!values?.length; - } - - hasTextValue(value?: string | null): boolean { - return !!value && value !== '-' && value !== 'Keine Angaben'; - } - - getOpenAccessBadge(publication: FundingPublicationDetail): { - label: string; - tone: 'open' | 'closed' | 'unknown'; - } { - if (publication.is_open_access) { - const statusLabels: Record = { - bronze: 'Bronze', - diamond: 'Diamond', - gold: 'Gold', - green: 'Green', - hybrid: 'Hybrid', - }; - const status = publication.open_access_status - ? (statusLabels[publication.open_access_status] ?? - publication.open_access_status) - : null; - return { - label: status ? `Open Access (${status})` : 'Open Access', - tone: 'open', - }; - } - - if (publication.open_access_status === 'closed') { - return { label: 'Nicht frei zugänglich', tone: 'closed' }; - } - - return { label: 'Zugang unbekannt', tone: 'unknown' }; - } - getPositionBadgeClass(position?: AuthorPosition | string | null): string { const classes: Record = { first: 'position-badge--first', @@ -520,218 +391,6 @@ export class PersonFundingComponent implements OnInit { return classes[position ?? 'unknown'] ?? classes['unknown']; } - getAuthorName(): string { - return this.authorName ?? 'Die Person'; - } - - getPublicationOverview(publication: FundingPublicationDetail): SafeHtml { - const yearText = publication.publication_year - ? `aus dem Jahr ${publication.publication_year}` - : 'ohne Jahresangabe'; - const authorText = publication.authors?.length - ? `von ${publication.authors.map((author) => this.escapeHtml(author)).join(', ')}` - : 'ohne Autorenangabe'; - const funderText = this.selectedFunder?.funder_name - ? `Sie ist dem Förderer ${this.escapeHtml(this.selectedFunder.funder_name)} zugeordnet` - : 'Es ist kein Förderer ausgewählt'; - const positionText = publication.author_position - ? `${this.boldAuthorName(this.getAuthorName())} ist als ${this.getPositionLabel(publication.author_position)} beteiligt` - : 'die Autorposition ist nicht bekannt'; - const sourceText = publication.source_name - ? `Erschienen ist sie in/bei ${this.escapeHtml(publication.source_name)}.` - : ''; - const citationText = - typeof publication.cited_by_count === 'number' - ? `Sie wurde ${publication.cited_by_count} Mal zitiert.` - : ''; - - const html = - `Publikation ${yearText} ${authorText}. ${sourceText} ${funderText}; ${positionText}. ${citationText}`.trim(); - return this.sanitizer.bypassSecurityTrustHtml(html); - } - - private escapeHtml(value: string): string { - return value - .replaceAll('&', '&') - .replaceAll('<', '<') - .replaceAll('>', '>'); - } - - private boldAuthorName(name: string): string { - return `${this.escapeHtml(name)}`; - } - - getPublicationDateLabel(publication: FundingPublicationDetail): string { - if (publication.publication_date) { - const date = new Date(`${publication.publication_date}T00:00:00`); - if (!Number.isNaN(date.getTime())) { - return new Intl.DateTimeFormat('de-DE').format(date); - } - return publication.publication_date; - } - - return publication.publication_year - ? String(publication.publication_year) - : '-'; - } - - getPublicationTypeLabel(publication: FundingPublicationDetail): string { - const labels: Record = { - article: 'Artikel', - book: 'Buch', - 'book-chapter': 'Buchkapitel', - dataset: 'Datensatz', - dissertation: 'Dissertation', - editorial: 'Editorial', - letter: 'Letter', - preprint: 'Preprint', - 'proceedings-article': 'Konferenzbeitrag', - report: 'Bericht', - review: 'Review', - }; - const type = publication.publication_type; - if (!type) { - return '-'; - } - - return labels[type] ?? type; - } - - getLanguageLabel(publication: FundingPublicationDetail): string { - const labels: Record = { - de: 'Deutsch', - en: 'Englisch', - es: 'Spanisch', - fr: 'Französisch', - it: 'Italienisch', - pt: 'Portugiesisch', - }; - const language = publication.language; - if (!language) { - return '-'; - } - - return labels[language] ?? language.toUpperCase(); - } - - getPublicationSourceLabel(publication: FundingPublicationDetail): string { - if (!publication.source_name) { - return 'Keine Angaben'; - } - - const sourceType = this.getSourceTypeLabel(publication.source_type); - return sourceType === '-' - ? publication.source_name - : `${publication.source_name} (${sourceType})`; - } - - getSourceTypeLabel(sourceType?: string | null): string { - const labels: Record = { - book: 'Buch', - conference: 'Konferenz', - journal: 'Journal', - repository: 'Repository', - }; - if (!sourceType) { - return '-'; - } - - return labels[sourceType] ?? sourceType; - } - - getListLabel(values?: string[] | null): string { - return values?.length ? values.join(', ') : 'Keine Angaben'; - } - - getPublicationFunderLabel(publication: FundingPublicationDetail): string { - if (publication.funder_names?.length) { - return this.getListLabel(publication.funder_names); - } - - return this.selectedFunder?.funder_name ?? 'Keine Angaben'; - } - - getCitationCountLabel(publication: FundingPublicationDetail): string { - if (typeof publication.cited_by_count !== 'number') { - return 'Keine Angaben'; - } - - return publication.cited_by_count === 1 - ? '1 Zitation' - : `${publication.cited_by_count} Zitationen`; - } - - getCitationCountsByYear( - publication: FundingPublicationDetail, - ): CitationCountByYear[] { - return (publication.counts_by_year ?? []) - .filter( - (count) => - typeof count.year === 'number' && - typeof count.cited_by_count === 'number', - ) - .map((count) => ({ - year: count.year as number, - count: count.cited_by_count as number, - })) - .sort((first, second) => second.year - first.year); - } - - getOpenAccessLabel(publication: FundingPublicationDetail): string { - const statusLabels: Record = { - bronze: 'Bronze', - closed: 'geschlossen', - diamond: 'Diamond', - gold: 'Gold', - green: 'Green', - hybrid: 'Hybrid', - }; - const status = publication.open_access_status - ? (statusLabels[publication.open_access_status] ?? - publication.open_access_status) - : null; - - if (publication.is_open_access) { - return status ? `Ja (${status})` : 'Ja'; - } - - return status === 'geschlossen' ? 'Nein' : 'Keine Angaben'; - } - - getFulltextLabel(publication: FundingPublicationDetail): string { - if (publication.pdf_url) { - return 'PDF verfügbar'; - } - if (publication.has_fulltext) { - return 'Volltext verfügbar'; - } - - return 'Kein Volltext hinterlegt'; - } - - getLicenseLabel(publication: FundingPublicationDetail): string { - return publication.license - ? publication.license.toUpperCase() - : 'Keine Angaben'; - } - - getRetractionLabel(publication: FundingPublicationDetail): string { - if (publication.is_retracted === true) { - return 'Ja, zurückgezogen'; - } - if (publication.is_retracted === false) { - return 'Nein, nicht zurückgezogen'; - } - - return 'Keine Angaben'; - } - - getGrantLabel(publication: FundingPublicationDetail): string { - return publication.grant_labels?.length - ? publication.grant_labels.join(', ') - : 'Kein Grant-Name hinterlegt'; - } - getPublicationPosition(publicationId: string): AuthorPosition { if (!this.selectedFunder) { return 'unknown'; -- 2.56.1