Improve funding publication detail view with richer metadata and clearer layout #122

Merged
taguesokoudjou merged 1 commits from ts-86-funding-design-improvements into dev 2026-06-08 23:46:57 +02:00
7 changed files with 1578 additions and 73 deletions
@@ -78,22 +78,53 @@ class FundedPublicationsSearchClient:
"doi",
"title",
"display_name",
"abstract_inverted_index",
"publication_year",
"publication_date",
"type",
"language",
"cited_by_count",
"is_retracted",
"primary_location.landing_page_url",
"primary_location.pdf_url",
"primary_location.is_oa",
"primary_location.license",
"primary_location.source.display_name",
"primary_location.source.type",
"best_oa_location.landing_page_url",
"best_oa_location.pdf_url",
"best_oa_location.is_oa",
"best_oa_location.license",
"best_oa_location.source.display_name",
"open_access.oa_url",
"open_access.is_oa",
"open_access.oa_status",
"open_access.any_repository_has_fulltext",
"topics.display_name",
"topics.score",
"primary_topic.display_name",
"primary_topic.subfield.display_name",
"primary_topic.field.display_name",
"primary_topic.domain.display_name",
"keywords.display_name",
"keywords.score",
"counts_by_year.year",
"counts_by_year.cited_by_count",
"authorships.author.id",
"authorships.author.display_name",
"authorships.author_position",
"authorships.institutions.display_name",
"authorships.institutions.country_code",
"authorships.countries",
"funders.id",
"funders.display_name",
"funders.ror",
"awards.id",
"awards.display_name",
"awards.funder_id",
"awards.funder_display_name",
"awards.funder_award_id",
"awards.doi",
]
@staticmethod
+249
View File
@@ -242,6 +242,246 @@ def _resolve_publication_url(publication: dict) -> str | None:
return publication.get("id")
def _publication_author_names(publication: dict) -> list[str]:
names: list[str] = []
for authorship in publication.get("authorships", []):
author_name = authorship.get("author", {}).get("display_name")
if author_name:
names.append(author_name)
return names
def _unique_strings(values: list[Any], limit: int | None = None) -> list[str]:
seen: set[str] = set()
unique_values: list[str] = []
for value in values:
if not value:
continue
text = str(value).strip()
if not text or text in seen:
continue
seen.add(text)
unique_values.append(text)
if limit and len(unique_values) >= limit:
break
return unique_values
def _publication_pdf_url(publication: dict) -> str | None:
primary_location = publication.get("primary_location") or {}
best_oa_location = publication.get("best_oa_location") or {}
return primary_location.get("pdf_url") or best_oa_location.get("pdf_url")
def _publication_source(publication: dict) -> dict:
primary_location = publication.get("primary_location") or {}
best_oa_location = publication.get("best_oa_location") or {}
primary_source = primary_location.get("source") or {}
best_oa_source = best_oa_location.get("source") or {}
return primary_source or best_oa_source
def _publication_license(publication: dict) -> str | None:
primary_location = publication.get("primary_location") or {}
best_oa_location = publication.get("best_oa_location") or {}
return primary_location.get("license") or best_oa_location.get("license")
def _publication_is_open_access(publication: dict) -> bool:
primary_location = publication.get("primary_location") or {}
best_oa_location = publication.get("best_oa_location") or {}
open_access = publication.get("open_access") or {}
return bool(
open_access.get("is_oa")
or open_access.get("oa_url")
or primary_location.get("is_oa")
or best_oa_location.get("is_oa")
)
def _publication_has_fulltext(publication: dict) -> bool:
open_access = publication.get("open_access") or {}
return bool(open_access.get("any_repository_has_fulltext") or _publication_pdf_url(publication))
def _publication_topic_names(publication: dict) -> list[str]:
topics = publication.get("topics")
if not isinstance(topics, list):
return []
sorted_topics = sorted(
topics,
key=lambda topic: topic.get("score", 0) if isinstance(topic, dict) else 0,
reverse=True,
)
return _unique_strings(
[topic.get("display_name") for topic in sorted_topics if isinstance(topic, dict)],
limit=6,
)
def _publication_keyword_names(publication: dict) -> list[str]:
keywords = publication.get("keywords")
if not isinstance(keywords, list):
return []
sorted_keywords = sorted(
keywords,
key=lambda keyword: keyword.get("score", 0) if isinstance(keyword, dict) else 0,
reverse=True,
)
return _unique_strings(
[keyword.get("display_name") for keyword in sorted_keywords if isinstance(keyword, dict)],
limit=8,
)
def _publication_institutions(publication: dict) -> list[str]:
institution_names: list[str] = []
for authorship in publication.get("authorships", []):
if not isinstance(authorship, dict):
continue
for institution in authorship.get("institutions") or []:
if isinstance(institution, dict):
institution_names.append(institution.get("display_name"))
return _unique_strings(institution_names, limit=8)
def _publication_countries(publication: dict) -> list[str]:
countries: list[str] = []
for authorship in publication.get("authorships", []):
if not isinstance(authorship, dict):
continue
countries.extend(authorship.get("countries") or [])
for institution in authorship.get("institutions") or []:
if isinstance(institution, dict):
countries.append(institution.get("country_code"))
return _unique_strings(countries, limit=8)
def _publication_counts_by_year(publication: dict) -> list[dict[str, int]]:
counts_by_year = publication.get("counts_by_year")
if not isinstance(counts_by_year, list):
return []
sanitized_counts: list[dict[str, int]] = []
for year_count in counts_by_year:
if not isinstance(year_count, dict):
continue
year = year_count.get("year")
cited_by_count = year_count.get("cited_by_count")
if isinstance(year, int) and isinstance(cited_by_count, int):
sanitized_counts.append({"year": year, "cited_by_count": cited_by_count})
return sorted(sanitized_counts, key=lambda year_count: year_count["year"], reverse=True)[:6]
def _publication_funder_names(publication: dict) -> list[str]:
names: list[Any] = []
for funder in publication.get("funders", []):
if isinstance(funder, dict):
names.append(funder.get("display_name"))
for award in publication.get("awards", []):
if isinstance(award, dict):
names.append(award.get("funder_display_name"))
return sorted(_unique_strings(names), key=str.casefold)
def _publication_grant_labels(
publication: dict,
funder_id: str | None,
funder_name: str | None,
) -> list[str]:
labels: list[str] = []
for award in publication.get("awards", []):
if not isinstance(award, dict):
continue
award_funder_id = award.get("funder_id")
award_funder_name = award.get("funder_display_name")
matches_funder_id = bool(funder_id and award_funder_id == funder_id)
matches_funder_name = bool(funder_name and award_funder_name == funder_name)
has_funder_reference = bool(award_funder_id or award_funder_name)
if has_funder_reference and not (matches_funder_id or matches_funder_name):
continue
display_name = award.get("display_name")
if display_name:
labels.append(display_name)
return _unique_strings(labels, limit=6)
def _publication_abstract(publication: dict) -> str | None:
inverted_index = publication.get("abstract_inverted_index")
if not isinstance(inverted_index, dict):
return None
words: list[tuple[int, str]] = []
for word, positions in inverted_index.items():
if not isinstance(positions, list):
continue
for position in positions:
if isinstance(position, int):
words.append((position, word))
if not words:
return None
return " ".join(word for _, word in sorted(words))
def _publication_detail_summary(
publication: dict,
publication_id: str,
publication_url: str | None,
author_position: str,
funder_id: str | None,
funder_name: str | None,
) -> dict[str, Any]:
title = publication.get("title") or publication.get("display_name") or publication_id
source = _publication_source(publication)
open_access = publication.get("open_access") or {}
primary_topic = publication.get("primary_topic") or {}
topic_field = primary_topic.get("field") or {}
topic_subfield = primary_topic.get("subfield") or {}
topic_domain = primary_topic.get("domain") or {}
return {
"id": publication_id,
"title": title,
"abstract": _publication_abstract(publication),
"doi": publication.get("doi"),
"publication_year": publication.get("publication_year"),
"publication_date": publication.get("publication_date"),
"publication_type": publication.get("type"),
"language": publication.get("language"),
"publication_url": publication_url,
"pdf_url": _publication_pdf_url(publication),
"source_name": source.get("display_name"),
"source_type": source.get("type"),
"is_open_access": _publication_is_open_access(publication),
"open_access_status": open_access.get("oa_status"),
"has_fulltext": _publication_has_fulltext(publication),
"license": _publication_license(publication),
"cited_by_count": publication.get("cited_by_count"),
"is_retracted": publication.get("is_retracted"),
"primary_topic": primary_topic.get("display_name"),
"topic_field": topic_field.get("display_name"),
"topic_subfield": topic_subfield.get("display_name"),
"topic_domain": topic_domain.get("display_name"),
"author_position": author_position,
"authors": _publication_author_names(publication),
"funder_names": _publication_funder_names(publication),
"institutions": _publication_institutions(publication),
"countries": _publication_countries(publication),
"topics": _publication_topic_names(publication),
"keywords": _publication_keyword_names(publication),
"grant_labels": _publication_grant_labels(publication, funder_id, funder_name),
"counts_by_year": _publication_counts_by_year(publication),
}
def _collect_funders_from_publications(
results: list[dict],
author_id: str,
@@ -291,6 +531,7 @@ def _collect_funders_from_publications(
},
"publication_urls": {},
"publication_titles": {},
"publication_details": {},
}
entry = funder_counts[key]
@@ -302,4 +543,12 @@ def _collect_funders_from_publications(
if publication_id:
title = publication.get("display_name") or publication.get("title") or publication_id
entry["publication_titles"][publication_id] = title
entry["publication_details"][publication_id] = _publication_detail_summary(
publication,
publication_id,
publication_url,
author_position,
funder_id,
funder_name,
)
+36
View File
@@ -1,6 +1,7 @@
from typing import Any
from pydantic import BaseModel
from pydantic import Field
class PublicationsByAuthorResponse(BaseModel):
@@ -27,6 +28,40 @@ class AuthorPositionCount(BaseModel):
unknown: int = 0
class PublicationDetailByFunder(BaseModel):
id: str
title: str
abstract: str | None = None
doi: str | None = None
publication_year: int | None = None
publication_date: str | None = None
publication_type: str | None = None
language: str | None = None
publication_url: str | None = None
pdf_url: str | None = None
source_name: str | None = None
source_type: str | None = None
is_open_access: bool | None = None
open_access_status: str | None = None
has_fulltext: bool | None = None
license: str | None = None
cited_by_count: int | None = None
is_retracted: bool | None = None
primary_topic: str | None = None
topic_field: str | None = None
topic_subfield: str | None = None
topic_domain: str | None = None
author_position: str | None = None
authors: list[str] = Field(default_factory=list)
funder_names: list[str] = Field(default_factory=list)
institutions: list[str] = Field(default_factory=list)
countries: list[str] = Field(default_factory=list)
topics: list[str] = Field(default_factory=list)
keywords: list[str] = Field(default_factory=list)
grant_labels: list[str] = Field(default_factory=list)
counts_by_year: list[dict[str, Any]] = Field(default_factory=list)
class FunderByAuthor(BaseModel):
funder_id: str | None = None
funder_name: str | None = None
@@ -35,6 +70,7 @@ class FunderByAuthor(BaseModel):
publication_ids: PublicationIdsByAuthorPosition
publication_urls: dict[str, str] = {}
publication_titles: dict[str, str] = {}
publication_details: dict[str, PublicationDetailByFunder] = Field(default_factory=dict)
class FundersByAuthorResponse(BaseModel):
+136 -1
View File
@@ -21,7 +21,11 @@ def _funded_publication_hit(
author_position: str = "first",
award_funder_id: str | None = None,
award_funder_name: str | None = None,
award_display_name: str | None = None,
award_number: str | None = None,
pdf_url: str | None = None,
abstract_inverted_index: dict | None = None,
extra_source: dict | None = None,
) -> dict:
source: dict = {
"id": work_id,
@@ -40,6 +44,10 @@ def _funded_publication_hit(
"funders": [],
"awards": [],
}
if abstract_inverted_index:
source["abstract_inverted_index"] = abstract_inverted_index
if extra_source:
source.update(extra_source)
if funder_id or funder_name:
source["funders"].append(
{
@@ -52,6 +60,8 @@ def _funded_publication_hit(
{
"funder_id": award_funder_id,
"funder_display_name": award_funder_name,
"display_name": award_display_name,
"funder_award_id": award_number,
}
)
return {"_source": source}
@@ -74,6 +84,59 @@ async def test_get_funders_by_author_id_aggregates_funders_and_awards(monkeypatc
funder_name="Funder A",
author_position="first",
pdf_url="https://example.org/w1.pdf",
abstract_inverted_index={
"This": [0],
"is": [1],
"an": [2],
"abstract.": [3],
},
extra_source={
"title": "Example publication: full detail",
"funders": [
{
"id": "https://openalex.org/F456",
"display_name": "Funder B",
}
],
"publication_year": 2020,
"publication_date": "2020-05-10",
"type": "article",
"language": "en",
"cited_by_count": 12,
"is_retracted": False,
"primary_location": {
"pdf_url": "https://example.org/w1.pdf",
"is_oa": True,
"license": "cc-by",
"source": {
"display_name": "Example Journal",
"type": "journal",
},
},
"open_access": {
"is_oa": True,
"oa_status": "gold",
"any_repository_has_fulltext": True,
},
"primary_topic": {
"display_name": "Clinical Trials",
"subfield": {"display_name": "Medicine"},
"field": {"display_name": "Health Sciences"},
"domain": {"display_name": "Life Sciences"},
},
"topics": [
{"display_name": "Trials", "score": 0.8},
{"display_name": "Guidelines", "score": 0.6},
],
"keywords": [
{"display_name": "randomised trials", "score": 0.9},
{"display_name": "reporting guideline", "score": 0.7},
],
"counts_by_year": [
{"year": 2024, "cited_by_count": 3},
{"year": 2023, "cited_by_count": 2},
],
},
),
_funded_publication_hit(
"https://openalex.org/W2",
@@ -81,6 +144,8 @@ async def test_get_funders_by_author_id_aggregates_funders_and_awards(monkeypatc
funder_name=None,
award_funder_id="https://openalex.org/F123",
award_funder_name="Funder A",
award_display_name="Project Grant",
award_number="PG-42",
author_position="last",
),
],
@@ -108,7 +173,7 @@ async def test_get_funders_by_author_id_aggregates_funders_and_awards(monkeypatc
assert response.author_id == "https://openalex.org/A5023888391"
assert response.author_name == "Example Author"
assert response.funder_count == 1
assert response.funder_count == 2
assert response.funders[0].funder_id == "https://openalex.org/F123"
assert response.funders[0].funder_name == "Funder A"
assert response.funders[0].publication_count == 2
@@ -118,6 +183,76 @@ async def test_get_funders_by_author_id_aggregates_funders_and_awards(monkeypatc
assert response.funders[0].publication_ids.last == ["https://openalex.org/W2"]
assert response.funders[0].publication_urls["https://openalex.org/W1"] == "https://example.org/w1.pdf"
assert response.funders[0].publication_urls["https://openalex.org/W2"] == "https://openalex.org/W2"
publication_detail = response.funders[0].publication_details["https://openalex.org/W1"]
assert publication_detail.title == "Example publication: full detail"
assert publication_detail.funder_names == ["Funder A", "Funder B"]
assert publication_detail.abstract == "This is an abstract."
assert publication_detail.publication_date == "2020-05-10"
assert publication_detail.publication_type == "article"
assert publication_detail.source_name == "Example Journal"
assert publication_detail.source_type == "journal"
assert publication_detail.is_open_access is True
assert publication_detail.open_access_status == "gold"
assert publication_detail.has_fulltext is True
assert publication_detail.license == "cc-by"
assert publication_detail.cited_by_count == 12
assert publication_detail.primary_topic == "Clinical Trials"
assert publication_detail.topic_field == "Health Sciences"
assert publication_detail.topic_subfield == "Medicine"
assert publication_detail.topic_domain == "Life Sciences"
assert publication_detail.topics == ["Trials", "Guidelines"]
assert publication_detail.keywords == ["randomised trials", "reporting guideline"]
assert publication_detail.counts_by_year == [
{"year": 2024, "cited_by_count": 3},
{"year": 2023, "cited_by_count": 2},
]
assert response.funders[0].publication_details["https://openalex.org/W2"].grant_labels == [
"Project Grant"
]
@pytest.mark.anyio
async def test_publication_grant_labels_ignore_funder_award_id_without_display_name(monkeypatch):
def handler(request: httpx.Request) -> httpx.Response:
return httpx.Response(
200,
json={
"hits": {
"total": {"value": 1},
"hits": [
_funded_publication_hit(
"https://openalex.org/W3",
funder_id="https://openalex.org/F123",
funder_name="Funder A",
award_funder_id="https://openalex.org/F123",
award_funder_name="Funder A",
award_display_name=None,
award_number="ANR-12-1234",
),
],
},
},
)
monkeypatch.setattr(
logic.person_logic,
"search_persons",
lambda author_id: type(
"Result",
(),
{"results": [type("Author", (), {"display_name": "Example Author"})()]},
)(),
)
client = FundedPublicationsSearchClient(
base_url="https://project.nes.uni-due.de/elastic",
api_key="test-key",
transport=httpx.MockTransport(handler),
)
response = await logic.get_funders_by_author_id("A5023888391", client=client)
assert response.funders[0].publication_details["https://openalex.org/W3"].grant_labels == []
@pytest.mark.anyio
@@ -4,6 +4,273 @@
<p class="message">Fehler beim Laden der Förderungen.</p>
} @else if (funders.length === 0) {
<p class="message">Keine Förderungen gefunden.</p>
} @else if (selectedPublicationDetailId) {
@if (getSelectedPublicationDetail(); as publication) {
<div class="funding-publication-page">
<button
type="button"
class="publication-detail-back"
(click)="closePublicationDetail()"
>
<span class="material-icons">arrow_back</span>
Zurück zu den Förderungen
</button>
<section class="publication-detail-hero">
<div class="publication-detail-hero__content">
<div class="publication-detail-hero__meta">
@if (publication.publication_year) {
<span>{{ publication.publication_year }}</span>
}
@if (hasTextValue(getPublicationTypeLabel(publication))) {
<span>{{ getPublicationTypeLabel(publication) }}</span>
}
@if (hasTextValue(getLanguageLabel(publication))) {
<span>{{ getLanguageLabel(publication) }}</span>
}
</div>
<h2>{{ publication.title }}</h2>
@if (hasPublicationSource(publication)) {
<p class="publication-detail-hero__source">{{ getPublicationSourceLabel(publication) }}</p>
}
<p class="publication-detail-hero__authors">{{ getPublicationAuthors(publication) }}</p>
<div class="publication-detail-hero__highlights">
@if (typeof publication.cited_by_count === 'number') {
<span class="hero-highlight">
<span class="hero-highlight__value">{{ publication.cited_by_count }}</span>
<span class="hero-highlight__label">Zitationen</span>
</span>
}
<span
class="hero-highlight hero-highlight--badge"
[class.hero-highlight--open]="getOpenAccessBadge(publication).tone === 'open'"
[class.hero-highlight--closed]="getOpenAccessBadge(publication).tone === 'closed'"
>
{{ getOpenAccessBadge(publication).label }}
</span>
<span class="position-badge" [ngClass]="getPositionBadgeClass(publication.author_position)">
{{ getPositionLabel(publication.author_position || "unknown") }}
</span>
</div>
</div>
@if (getPublicationExternalUrl(publication); as externalUrl) {
<a
class="publication-detail-hero__action"
[href]="externalUrl"
target="_blank"
rel="noopener"
>
Zur Publikation
<span class="material-icons">open_in_new</span>
</a>
}
</section>
<div class="publication-detail-grid">
<div class="publication-detail-main">
<section class="publication-detail-section">
<h3>Überblick</h3>
<p class="publication-overview" [innerHTML]="getPublicationOverview(publication)"></p>
</section>
<section class="publication-detail-section">
<h3>Abstract</h3>
<p class="publication-abstract">
{{ publication.abstract || "Kein Abstract vorhanden." }}
</p>
</section>
@if (publication.publication_date) {
<section class="publication-detail-section">
<h3>Publikationsdaten</h3>
<dl class="publication-detail-facts">
<div>
<dt>Datum</dt>
<dd>{{ getPublicationDateLabel(publication) }}</dd>
</div>
</dl>
</section>
}
@if (
hasTextValue(publication.primary_topic) ||
hasTextValue(publication.topic_field) ||
hasTextValue(publication.topic_subfield) ||
hasTextValue(publication.topic_domain) ||
hasListValues(publication.topics) ||
hasListValues(publication.keywords)
) {
<section class="publication-detail-section">
<h3>Einordnung</h3>
<dl class="publication-detail-facts">
@if (hasTextValue(publication.primary_topic)) {
<div>
<dt>Hauptthema</dt>
<dd>{{ publication.primary_topic }}</dd>
</div>
}
@if (hasTextValue(publication.topic_field)) {
<div>
<dt>Fachgebiet</dt>
<dd>{{ publication.topic_field }}</dd>
</div>
}
@if (hasTextValue(publication.topic_subfield)) {
<div>
<dt>Teilgebiet</dt>
<dd>{{ publication.topic_subfield }}</dd>
</div>
}
@if (hasTextValue(publication.topic_domain)) {
<div>
<dt>Bereich</dt>
<dd>{{ publication.topic_domain }}</dd>
</div>
}
@if (hasListValues(publication.topics)) {
<div>
<dt>Themen</dt>
<dd>
<ul class="tag-list">
@for (topic of publication.topics; track topic) {
<li class="tag">{{ topic }}</li>
}
</ul>
</dd>
</div>
}
@if (hasListValues(publication.keywords)) {
<div>
<dt>Keywords</dt>
<dd>
<ul class="tag-list">
@for (keyword of publication.keywords; track keyword) {
<li class="tag">{{ keyword }}</li>
}
</ul>
</dd>
</div>
}
</dl>
</section>
}
@if (getCitationCountsByYear(publication).length || publication.is_retracted) {
<section class="publication-detail-section">
<h3>Wirkung</h3>
<dl class="publication-detail-facts">
@if (getCitationCountsByYear(publication); as citationYears) {
@if (citationYears.length) {
<div>
<dt>Zitiert pro Jahr</dt>
<dd>
<table class="citation-year-table">
<tbody>
@for (entry of citationYears; track entry.year) {
<tr>
<th scope="row">{{ entry.year }}</th>
<td>{{ entry.count }}</td>
</tr>
}
</tbody>
</table>
</dd>
</div>
}
}
@if (publication.is_retracted) {
<div>
<dt>Zurückgezogen</dt>
<dd><span class="warning-badge">Ja, zurückgezogen</span></dd>
</div>
}
</dl>
</section>
}
<section class="publication-detail-section">
<h3>Zugang</h3>
<dl class="publication-detail-facts">
<div>
<dt>Open Access</dt>
<dd>
<span
class="access-badge"
[class.access-badge--open]="getOpenAccessBadge(publication).tone === 'open'"
[class.access-badge--closed]="getOpenAccessBadge(publication).tone === 'closed'"
>
{{ getOpenAccessBadge(publication).label }}
</span>
</dd>
</div>
<div>
<dt>Volltext</dt>
<dd class="access-actions">
<span>{{ getFulltextLabel(publication) }}</span>
@if (publication.pdf_url) {
<a class="inline-action" [href]="publication.pdf_url" target="_blank" rel="noopener">
PDF öffnen
<span class="material-icons">open_in_new</span>
</a>
}
</dd>
</div>
@if (hasTextValue(getLicenseLabel(publication))) {
<div>
<dt>Lizenz</dt>
<dd>{{ getLicenseLabel(publication) }}</dd>
</div>
}
</dl>
</section>
</div>
<aside class="publication-detail-side">
<section class="publication-detail-section publication-detail-section--funding">
<h3>Förderbezug</h3>
<dl class="publication-detail-facts">
<div>
<dt>Förderer</dt>
<dd>{{ getPublicationFunderLabel(publication) }}</dd>
</div>
<div>
<dt>Position</dt>
<dd>
<span class="position-badge" [ngClass]="getPositionBadgeClass(publication.author_position)">
{{ getPositionLabel(publication.author_position || "unknown") }}
</span>
</dd>
</div>
@if (publication.grant_labels?.length) {
<div>
<dt>Grant</dt>
<dd>{{ getGrantLabel(publication) }}</dd>
</div>
}
@if (hasListValues(publication.institutions)) {
<div>
<dt>Institutionen</dt>
<dd>{{ getListLabel(publication.institutions) }}</dd>
</div>
}
@if (hasListValues(publication.countries)) {
<div>
<dt>Länder</dt>
<dd>
<ul class="tag-list tag-list--compact">
@for (country of publication.countries; track country) {
<li class="tag">{{ country }}</li>
}
</ul>
</dd>
</div>
}
</dl>
</section>
</aside>
</div>
</div>
}
} @else {
<div class="funding-container">
<div class="funding-summary">
@@ -17,38 +284,48 @@
</p>
</div>
<!-- Filter Buttons -->
<div class="filter-bar">
<span>Filter nach Position:</span>
<button
[class.active]="activeFilter === 'all'"
(click)="setFilter('all')"
>
Alle
</button>
<button
[class.active]="activeFilter === 'first'"
(click)="setFilter('first')"
>
Erstautor
</button>
<button
[class.active]="activeFilter === 'middle'"
(click)="setFilter('middle')"
>
Mitautor
</button>
<button
[class.active]="activeFilter === 'last'"
(click)="setFilter('last')"
>
Letztautor
</button>
</div>
<div class="funding-content">
<!-- Linke Seite: Tabelle -->
<div class="funding-list">
<div class="funding-list-toolbar">
<div class="filter-bar">
<span>Filter nach Position:</span>
<button
[class.active]="activeFilter === 'all'"
(click)="setFilter('all')"
>
Alle
</button>
<button
[class.active]="activeFilter === 'first'"
(click)="setFilter('first')"
>
Erstautor
</button>
<button
[class.active]="activeFilter === 'middle'"
(click)="setFilter('middle')"
>
Mitautor
</button>
<button
[class.active]="activeFilter === 'last'"
(click)="setFilter('last')"
>
Letztautor
</button>
</div>
<label class="sort-control">
<span>Sortieren nach:</span>
<select
[value]="sortMode"
(change)="setSortMode($any($event.target).value)"
>
<option value="name">Name</option>
<option value="top">Top Förderer</option>
</select>
</label>
</div>
<table>
<thead>
<tr>
@@ -130,19 +407,17 @@
getPublicationTitle(id)
}}</span>
@if (expandedPublicationId === id) {
<div class="publication-more-info">
<button
type="button"
class="publication-more-info"
title="Publikationsdetails öffnen"
(click)="openPublicationDetail($event, id)"
>
<span class="mehr-infos-label">Mehr Infos</span>
<a
[href]="getPublicationUrl(id)"
target="_blank"
rel="noopener"
(click)="openPublication($event, id)"
class="publication-link-icon"
title="Publikation öffnen"
>
<span class="publication-link-icon">
<span class="material-icons">open_in_new</span>
</a>
</div>
</span>
</button>
}
</li>
}
@@ -28,7 +28,6 @@
background: white;
cursor: pointer;
font-size: 14px;
transition: all 0.2s;
&:hover {
background: #f0f0f0;
@@ -59,6 +58,31 @@ button:nth-child(5) {
}
}
.sort-control {
display: inline-flex;
align-items: center;
gap: 6px;
width: fit-content;
padding: 10px 14px;
border-radius: 20px;
background: #f2f2f2;
color: #333;
font-size: 14px;
span {
color: #555;
}
select {
border: 0;
background: transparent;
color: #111827;
font: inherit;
cursor: pointer;
outline: none;
}
}
.funding-content {
display: flex;
gap: 24px;
@@ -68,6 +92,19 @@ button:nth-child(5) {
.funding-list {
flex: 1;
.funding-list-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 18px;
flex-wrap: wrap;
}
.sort-control {
margin-left: auto;
}
table {
width: 100%;
border-collapse: collapse;
@@ -82,7 +119,6 @@ button:nth-child(5) {
tr {
cursor: pointer;
transition: background 0.15s;
&:hover {
background: #f5f5f5;
@@ -191,17 +227,6 @@ button:nth-child(5) {
padding: 6px 0;
border-bottom: 1px solid #5b5555;
font-size: 13px;
a {
color: #2563eb;
text-decoration: none;
word-break: break-all;
&:hover {
color: #1d4ed8;
text-decoration: underline;
}
}
}
}
@@ -250,6 +275,364 @@ button:nth-child(5) {
color: #333;
}
}
.funding-publication-page {
padding: 16px;
}
.publication-detail-back {
display: inline-flex;
align-items: center;
gap: 6px;
border: 0;
background: transparent;
cursor: pointer;
}
.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;
letter-spacing: 0.02em;
}
}
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;
flex-shrink: 0;
padding: 10px 16px;
border: 1px solid #bdd4ff;
border-radius: 8px;
background: #f0f6ff;
color: #0b63ce;
font-weight: 600;
font-size: 0.875rem;
text-decoration: none;
white-space: nowrap;
&:hover {
background: #e3efff;
}
.material-icons {
font-size: 18px;
}
}
}
@media (max-width: 720px) {
.publication-detail-hero {
flex-direction: column;
align-items: stretch;
&__action {
justify-content: center;
}
}
}
.hero-highlight {
display: inline-flex;
flex-direction: column;
min-width: 72px;
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;
letter-spacing: 0.03em;
}
&--badge {
flex-direction: row;
align-items: center;
min-width: 0;
font-size: 0.8rem;
font-weight: 600;
color: #475569;
}
&--open {
border-color: #bdebcf;
background: #effaf3;
color: #24834f;
}
&--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;
&--first {
background: #effaf3;
color: #24834f;
border: 1px solid #bdebcf;
}
&--middle {
background: #f6f0ff;
color: #7255d9;
border: 1px solid #d8cafe;
}
&--last {
background: #fff7e8;
color: #c67500;
border: 1px solid #ffd796;
}
&--unknown {
background: #f1f5f9;
color: #64748b;
border: 1px solid #e2e8f0;
}
}
.publication-detail-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
gap: 12px;
.publication-detail-main,
.publication-detail-side {
display: grid;
gap: 12px;
min-width: 0;
}
.publication-detail-section {
border: 1px solid #e0e6f0;
border-radius: 10px;
padding: 18px;
background: #fff;
h3 {
margin: 0 0 14px;
font-size: 1rem;
color: #1e3a5f;
}
&--funding {
background: #fafbfd;
}
}
.publication-overview,
.publication-abstract {
margin: 0;
color: #334155;
line-height: 1.65;
}
.publication-detail-facts {
display: grid;
gap: 12px;
margin: 0;
div {
display: grid;
grid-template-columns: 130px minmax(0, 1fr);
gap: 12px;
}
dt {
color: #64748b;
font-size: 0.875rem;
}
dd {
margin: 0;
word-break: break-word;
color: #1e293b;
}
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin: 0;
padding: 0;
list-style: none;
&--compact .tag {
font-size: 0.75rem;
padding: 3px 8px;
}
}
.tag {
padding: 4px 10px;
border-radius: 999px;
background: #f0f6ff;
border: 1px solid #dbeafe;
color: #1e40af;
font-size: 0.8rem;
line-height: 1.3;
}
.access-badge {
display: inline-flex;
padding: 4px 10px;
border-radius: 999px;
font-size: 0.8rem;
font-weight: 600;
background: #f1f5f9;
color: #64748b;
&--open {
background: #effaf3;
color: #24834f;
}
&--closed {
background: #f8fafc;
color: #475569;
}
}
.access-actions {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
}
.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;
}
}
.warning-badge {
display: inline-flex;
padding: 4px 10px;
border-radius: 999px;
background: #fef2f2;
border: 1px solid #fecaca;
color: #b91c1c;
font-size: 0.8rem;
font-weight: 600;
}
.citation-year-table {
border-collapse: collapse;
th,
td {
padding: 2px 0;
font-weight: normal;
text-align: left;
vertical-align: top;
}
th {
padding-right: 20px;
font-weight: 600;
color: #334155;
white-space: nowrap;
}
td {
color: #1e293b;
}
}
}
@media (max-width: 960px) {
.publication-detail-grid {
grid-template-columns: 1fr;
}
}
.publication-item {
padding: 8px 0;
border-bottom: 2px solid #5b5555;
@@ -270,9 +653,12 @@ button:nth-child(5) {
.publication-more-info {
display: flex;
align-items: center;
flex-direction: row;
gap: 4px;
margin-top: 6px;
border: 0;
background: transparent;
padding: 0;
cursor: pointer;
}
.mehr-infos-label {
@@ -285,14 +671,9 @@ button:nth-child(5) {
display: flex;
align-items: center;
color: #1976d2;
text-decoration: none;
flex-shrink: 0;
.material-icons {
font-size: 16px;
}
&:hover {
color: #0d47a1;
}
}
@@ -1,9 +1,55 @@
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 { Router } from '@angular/router';
import { PersonsService } from '../../api';
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],
@@ -14,27 +60,34 @@ 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;
readonly funderListPageSize = 10;
readonly publicationPageSize = 10;
activeFilter: 'all' | 'first' | 'middle' | 'last' = 'all';
sortMode: SortMode = 'name';
loading = true;
error = false;
expandedPublicationId: string | null = null;
selectedPublicationDetailId: string | null = null;
ngOnInit(): void {
this.route.parent?.paramMap.subscribe(params => {
const authorId = params.get('id') ?? '';
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
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')
);
@@ -42,11 +95,15 @@ export class PersonFundingComponent implements OnInit {
if (this.isValidFilter(filterFromUrl)) {
this.activeFilter = filterFromUrl;
}
if (this.isValidSortMode(sortFromUrl)) {
this.sortMode = sortFromUrl;
}
if (authorId) {
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, this.getFunderListPageCount());
this.restoreSelectedFunderFromUrl();
@@ -64,6 +121,7 @@ export class PersonFundingComponent implements OnInit {
selectFunder(funder: any): void {
this.selectedFunder = funder;
this.selectedPublicationPage = 1;
this.selectedPublicationDetailId = null;
this.updateQueryParams();
}
@@ -73,17 +131,26 @@ export class PersonFundingComponent implements OnInit {
this.updateQueryParams();
}
setSortMode(sortMode: SortMode): void {
this.sortMode = sortMode;
this.applyFilter();
this.updateQueryParams();
}
private applyFilter(): void {
this.selectedFunder = null;
this.selectedPublicationDetailId = null;
this.selectedFunderListPage = 1;
this.selectedPublicationPage = 1;
let funders: any[];
if (this.activeFilter === 'all') {
this.filteredFunders = this.funders;
funders = this.funders;
} else {
this.filteredFunders = this.funders.filter(
funders = this.funders.filter(
f => f.author_position_count[this.activeFilter] > 0
);
}
this.filteredFunders = this.sortFunders(funders);
}
private restoreSelectedFunderFromUrl(): void {
@@ -107,6 +174,12 @@ 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();
@@ -118,8 +191,10 @@ export class PersonFundingComponent implements OnInit {
relativeTo: this.route,
queryParams: {
filter: this.activeFilter,
sortBy: this.sortMode,
funder: this.selectedFunder ? this.getFunderKey(this.selectedFunder) : null,
publicationPage: this.selectedFunder ? this.selectedPublicationPage : null,
publicationDetail: this.selectedPublicationDetailId,
funderPage: this.selectedFunderListPage
},
queryParamsHandling: 'merge',
@@ -135,6 +210,10 @@ export class PersonFundingComponent implements OnInit {
return value === 'all' || value === 'first' || value === 'middle' || value === 'last';
}
private isValidSortMode(value: string | null): value is SortMode {
return value === 'name' || value === 'top';
}
getPublicationCount(funder: any): number {
if (this.activeFilter === 'all') {
return funder.publication_count ?? 0;
@@ -198,12 +277,6 @@ export class PersonFundingComponent implements OnInit {
this.updateQueryParams();
}
openPublication(event: MouseEvent, publicationId: string): void {
event.preventDefault();
const url = this.getPublicationUrl(publicationId);
window.open(url, '_blank', 'noopener');
}
getPositionLabel(position: string): string {
const labels: Record<string, string> = {
first: 'Erstautor',
@@ -234,15 +307,34 @@ export class PersonFundingComponent implements OnInit {
return allIds.size;
}
getPublicationUrl(publicationId: string): string {
return this.selectedFunder?.publication_urls?.[publicationId] ?? publicationId;
}
private getPublicationPageCountForFunder(funder: any): number {
const publicationCount = this.getPublicationIds(funder).length;
return Math.max(1, Math.ceil(publicationCount / this.publicationPageSize));
}
private sortFunders(funders: any[]): any[] {
const sortedFunders = [...funders];
return sortedFunders.sort((first, second) => {
if (this.sortMode === 'top') {
const publicationCountDifference =
this.getPublicationCount(second) - this.getPublicationCount(first);
if (publicationCountDifference !== 0) {
return publicationCountDifference;
}
}
return this.getSortableFunderName(first).localeCompare(
this.getSortableFunderName(second),
'de',
{ sensitivity: 'base' },
);
});
}
private getSortableFunderName(funder: any): string {
return funder.funder_name ?? '';
}
private clampPublicationPage(page: number, totalPages: number): number {
return this.clampPage(page, totalPages);
}
@@ -259,12 +351,318 @@ export class PersonFundingComponent implements OnInit {
return parsed;
}
getPublicationTitle(publicationId: string): string {
const detailTitle = this.getPublicationDetail(publicationId)?.title;
if (detailTitle) return detailTitle;
const title = this.selectedFunder?.publication_titles?.[publicationId];
if (title) return title;
const parts = publicationId.split('/');
return parts[parts.length - 1] ?? publicationId;
}
togglePublication(id: string): void {
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) {
return detail;
}
const title = this.selectedFunder?.publication_titles?.[publicationId] ?? this.getShortPublicationId(publicationId);
return {
id: publicationId,
title,
publication_url: this.selectedFunder?.publication_urls?.[publicationId] ?? publicationId,
author_position: this.getPublicationPosition(publicationId),
authors: [],
};
}
getShortPublicationId(publicationId: string): string {
const parts = publicationId.split('/');
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<string, string> = {
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<string, string> = {
first: 'position-badge--first',
middle: 'position-badge--middle',
last: 'position-badge--last',
unknown: 'position-badge--unknown',
};
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('&', '&amp;')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;');
}
private boldAuthorName(name: string): string {
return `<strong>${this.escapeHtml(name)}</strong>`;
}
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<string, string> = {
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<string, string> = {
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<string, string> = {
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<string, string> = {
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';
}
for (const position of ['first', 'middle', 'last', 'unknown'] as AuthorPosition[]) {
if ((this.selectedFunder.publication_ids?.[position] ?? []).includes(publicationId)) {
return position;
}
}
return 'unknown';
}
}