From 77c7eeef8b21f66e7f636e03600aa19c17c6b893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20Paul=20Ton=C4=8Dik?= Date: Fri, 10 Jul 2026 17:02:19 +0200 Subject: [PATCH] fix(person/publications): changed publications to generic data table --- .../person-publications.component.html | 175 +++++++++++++++++- .../person-publications.component.ts | 88 +++++++++ .../publication-detail.component.html | 8 +- .../publication-detail.component.ts | 4 + .../src/app/resolvers/work-page.resolver.ts | 27 +++ .../app/shared/pipes/language-code.pipe.ts | 66 +++++++ webapp/src/app/shared/pipes/work-type.pipe.ts | 27 +++ 7 files changed, 389 insertions(+), 6 deletions(-) create mode 100644 webapp/src/app/resolvers/work-page.resolver.ts create mode 100644 webapp/src/app/shared/pipes/language-code.pipe.ts create mode 100644 webapp/src/app/shared/pipes/work-type.pipe.ts diff --git a/webapp/src/app/modules/person-publications/person-publications.component.html b/webapp/src/app/modules/person-publications/person-publications.component.html index b300aeeb..65798fd6 100644 --- a/webapp/src/app/modules/person-publications/person-publications.component.html +++ b/webapp/src/app/modules/person-publications/person-publications.component.html @@ -322,7 +322,8 @@ } -
+ + + + +
+ + + {{ work.title }} + + + + @if (work.type) { + + } @else { + - + } + + + + @if (work.publication_year) { + + } @else { + - + } + + + + @if (work.language) { + + } @else { + - + } + + + + @let publicationInstitutions = getInstitutions(work); + @let institutionsExpanded = true; + @let visibleInstitutions = + institutionsExpanded + ? publicationInstitutions + : publicationInstitutions.slice(0, 3); +
+ @for (institution of visibleInstitutions; track institution.id) { + + } @empty { + - + } + @if (publicationInstitutions.length > 3) { + + } +
+
+ + + @let publicationTopics = work.topics ?? []; + @let topicsExpanded = isTopicsExpanded(work); + @let visibleTopics = + topicsExpanded ? publicationTopics : publicationTopics.slice(0, 3); +
+ @for (topic of visibleTopics; track topic.id) { + + + } @empty { + - + } + @if (publicationTopics.length > 3) { + + } +
+
+ + + {{ work.cited_by_count ?? 0 }} + + + + + open_in_new + + diff --git a/webapp/src/app/modules/person-publications/person-publications.component.ts b/webapp/src/app/modules/person-publications/person-publications.component.ts index 55ed9c7d..51130e80 100644 --- a/webapp/src/app/modules/person-publications/person-publications.component.ts +++ b/webapp/src/app/modules/person-publications/person-publications.component.ts @@ -2,11 +2,13 @@ import { Component, DestroyRef, OnInit, + TemplateRef, ViewChild, computed, effect, inject, input, + viewChild, } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; @@ -43,6 +45,7 @@ import { import { AuthorWorkPurposes, + Institution, InstitutionsService, SpecificWorkPurpose, Work, @@ -67,6 +70,13 @@ import { CanvasRenderer } from 'echarts/renderers'; import { GraphChart } from 'echarts/charts'; import { MatCardModule } from '@angular/material/card'; import { MatExpansionModule } from '@angular/material/expansion'; +import { + GenericColumn, + DataTableComponent, +} from '../../shared/ui/data-table/data-table.component'; +import { WorkTypePipe } from '../../shared/pipes/work-type.pipe'; +import { LanguageCodePipe } from '../../shared/pipes/language-code.pipe'; +import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component'; echarts.use([ GridComponent, CanvasRenderer, @@ -144,6 +154,10 @@ const PURPOSE_LABELS: Record<'FOUNDATION' | 'APPLICATION', string> = { NgxEchartsDirective, MatCardModule, MatExpansionModule, + DataTableComponent, + WorkTypePipe, + LanguageCodePipe, + QueryParamPaginatorComponent, ], templateUrl: './person-publications.component.html', styleUrl: './person-publications.component.scss', @@ -180,6 +194,16 @@ export class PersonPublicationsComponent implements OnInit { chartOption!: echarts.EChartsCoreOption; + workColumns: GenericColumn[] = []; + titleTmp = viewChild.required>('titleTmp'); + typeTmp = viewChild.required>('typeTmp'); + yearTmp = viewChild.required>('yearTmp'); + languageTmp = viewChild.required>('languageTmp'); + institutionsTmp = viewChild.required>('institutionsTmp'); + topicsTmp = viewChild.required>('topicsTmp'); + citationsTmp = viewChild.required>('citationsTmp'); + actionsTmp = viewChild.required>('actionsTmp'); + displayedColumns: string[] = [ 'title', 'type', @@ -362,6 +386,57 @@ export class PersonPublicationsComponent implements OnInit { this.setupInstitutionAutocomplete(); this.setupTopicAutocomplete(); + this.workColumns = [ + { + id: 'title', + header: 'Titel', + type: 'display', + cellTemplate: this.titleTmp(), + }, + { + id: 'type', + header: 'Typ', + type: 'display', + cellTemplate: this.typeTmp(), + }, + { + id: 'publication_year', + header: 'Jahr', + type: 'display', + cellTemplate: this.yearTmp(), + }, + { + id: 'language', + header: 'Sprache', + type: 'display', + cellTemplate: this.languageTmp(), + }, + { + id: 'institutions', + header: 'Institutionen', + type: 'display', + cellTemplate: this.institutionsTmp(), + }, + { + id: 'topics', + header: 'Themen', + type: 'display', + cellTemplate: this.topicsTmp(), + }, + { + id: 'cited_by_count', + header: 'Zitiert von', + type: 'display', + cellTemplate: this.citationsTmp(), + }, + { + id: 'actions', + header: 'Aktionen', + type: 'display', + cellTemplate: this.actionsTmp(), + }, + ]; + const parentParamMap = this.route.parent?.paramMap; if (!parentParamMap) return; @@ -707,6 +782,19 @@ export class PersonPublicationsComponent implements OnInit { return 'info'; } + getInstitutions(work: Work): Array { + const institutions: Array = []; + for (const authorship of work.authorships ?? []) { + for (const institution of authorship.institutions ?? []) { + if (!institution.id || !institution.display_name) continue; + if (!institutions.some((inst) => inst.id === institution.id)) { + institutions.push(institution); + } + } + } + return institutions; + } + institutions( publication: Work, ): Array<{ id: string; name: string; country: string | null }> { diff --git a/webapp/src/app/modules/publication-detail/publication-detail.component.html b/webapp/src/app/modules/publication-detail/publication-detail.component.html index c672c74c..7bd7299f 100644 --- a/webapp/src/app/modules/publication-detail/publication-detail.component.html +++ b/webapp/src/app/modules/publication-detail/publication-detail.component.html @@ -25,13 +25,13 @@
@if (publication.type) { - {{ publication.type }} + {{ publication.type | workType }} } @if (publication.publication_year) { {{ publication.publication_year }} } @if (publication.language) { - {{ publication.language | uppercase }} + {{ publication.language | languageCode }} }

@@ -269,11 +269,11 @@

Typ
-
{{ publication.type || '-' }}
+
{{ publication.type | workType }}
Sprache
-
{{ publication.language || '-' }}
+
{{ publication.language | languageCode }}
Open Access
diff --git a/webapp/src/app/modules/publication-detail/publication-detail.component.ts b/webapp/src/app/modules/publication-detail/publication-detail.component.ts index b377543b..57094961 100644 --- a/webapp/src/app/modules/publication-detail/publication-detail.component.ts +++ b/webapp/src/app/modules/publication-detail/publication-detail.component.ts @@ -17,6 +17,8 @@ import { } from '../../api'; import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component'; import { topicHierarchyColor } from '../../resolvers/utils/topic-colors'; +import { WorkTypePipe } from '../../shared/pipes/work-type.pipe'; +import { LanguageCodePipe } from '../../shared/pipes/language-code.pipe'; interface DetailLink { label: string; @@ -41,6 +43,8 @@ interface InstitutionDetail { RouterLink, TopicChipComponent, UpperCasePipe, + WorkTypePipe, + LanguageCodePipe ], templateUrl: './publication-detail.component.html', styleUrl: './publication-detail.component.scss', diff --git a/webapp/src/app/resolvers/work-page.resolver.ts b/webapp/src/app/resolvers/work-page.resolver.ts new file mode 100644 index 00000000..5c69230a --- /dev/null +++ b/webapp/src/app/resolvers/work-page.resolver.ts @@ -0,0 +1,27 @@ +import { ResolveFn } from '@angular/router'; +import { WorkPage, WorksService } from '../api'; +import { inject } from '@angular/core'; + +export const workPageResolver: ResolveFn = (route, state) => { + const authorId = route.paramMap.get('authorId'); + const page = Number(route.queryParamMap.get('page') || 0); + const pageSize = Number(route.queryParamMap.get('pageSize') || 10); + const publicationYears = route.queryParamMap + .getAll('publicationYears') + .map(Number); + const type = route.queryParamMap.getAll('types'); + const languages = route.queryParamMap.getAll('languages'); + const institutionIds = route.queryParamMap.getAll('institutionIds'); + const topicsIds = route.queryParamMap.getAll('topicsIds'); + + return inject(WorksService).getAuthorWorks( + authorId!, + page, + pageSize, + publicationYears, + type, + languages, + institutionIds, + topicsIds, + ); +}; diff --git a/webapp/src/app/shared/pipes/language-code.pipe.ts b/webapp/src/app/shared/pipes/language-code.pipe.ts new file mode 100644 index 00000000..ea985af7 --- /dev/null +++ b/webapp/src/app/shared/pipes/language-code.pipe.ts @@ -0,0 +1,66 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'languageCode', +}) +export class LanguageCodePipe implements PipeTransform { + transform( + languageCode: string | null | undefined, + ...args: unknown[] + ): string { + switch (languageCode) { + case 'en': + return 'Englisch'; + case 'de': + return 'Deutsch'; + case 'fr': + return 'Französisch'; + case 'es': + return 'Spanisch'; + case 'it': + return 'Italienisch'; + case 'pt': + return 'Portugiesisch'; + case 'ru': + return 'Russisch'; + case 'zh': + return 'Chinesisch'; + case 'ja': + return 'Japanisch'; + case 'ar': + return 'Arabisch'; + case 'ko': + return 'Koreanisch'; + case 'nl': + return 'Niederländisch'; + case 'sv': + return 'Schwedisch'; + case 'no': + return 'Norwegisch'; + case 'da': + return 'Dänisch'; + case 'fi': + return 'Finnisch'; + case 'pl': + return 'Polnisch'; + case 'cs': + return 'Tschechisch'; + case 'hu': + return 'Ungarisch'; + case 'tr': + return 'Türkisch'; + case 'el': + return 'Griechisch'; + case 'he': + return 'Hebräisch'; + case 'hi': + return 'Hindi'; + case 'th': + return 'Thailändisch'; + case 'vi': + return 'Vietnamesisch'; + default: + return languageCode ?? 'Unbekannte Sprache'; + } + } +} diff --git a/webapp/src/app/shared/pipes/work-type.pipe.ts b/webapp/src/app/shared/pipes/work-type.pipe.ts new file mode 100644 index 00000000..eebedae6 --- /dev/null +++ b/webapp/src/app/shared/pipes/work-type.pipe.ts @@ -0,0 +1,27 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'workType', +}) +export class WorkTypePipe implements PipeTransform { + transform(value: string | null | undefined, ...args: unknown[]): string { + switch (value) { + case 'article': + return 'Artikel'; + case 'book': + return 'Buch'; + case 'book-chapter': + return 'Buchkapitel'; + case 'dataset': + return 'Datensatz'; + case 'dissertation': + return 'Dissertation'; + case 'report': + return 'Bericht'; + case 'preprint': + return 'Preprint'; + default: + return value ?? 'Unbekannter Typ'; + } + } +}