create bund-projects component and table

This commit is contained in:
2026-07-24 01:56:03 +02:00
parent 00e5597b08
commit 3a342961e2
6 changed files with 819 additions and 0 deletions
@@ -0,0 +1,158 @@
<app-data-table
[columns]="columns"
[data]="elements()"
[queryParamSortKey]="queryParamKeys.sortBy"
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
<app-query-param-paginator
[total]="total()"
[queryParamPageKey]="queryParamKeys.page"
[queryParamSizeKey]="queryParamKeys.size"
[pageSizeOptions]="[10]" />
<ng-template #fundingEndTmp let-element>
{{
element.funding_end == '2999' || element.funding_end == null
? 'laufend'
: element.funding_end
}}
</ng-template>
<ng-template #actionsTmp let-element>
<a
[routerLink]="['/projects/dfg', element.id]"
target="_blank"
mat-icon-button
color="primary">
<mat-icon>open_in_new</mat-icon>
</a>
</ng-template>
<ng-template #detailRowTmp let-element>
<div class="classification-container">
@for (classification of element.subject_classifications; track $index) {
<p>
{{ classification.wissenschaftsbereich || '-' }}
→ {{ classification.fachkollegium || '-' }} →
{{ classification.fachgebiet || '-' }} →
{{ classification.fach || '-' }}
</p>
} @empty {
<span>-</span>
}
</div>
</ng-template>
<!-- <ng-template #authorsTmp let-project>
@let projectAuthors = getProjectAuthors(project);
@let isProjectAuthorsExpanded = isProjectPersonsExpanded(project);
@let visibleAuthors =
isProjectAuthorsExpanded ? projectAuthors : projectAuthors.slice(0, 3); -->
<!-- <div class="author-tags" aria-label="Autoren" style="padding: 0.5rem 0">
@for (author of visibleAuthors; track author.person_id) {
<button
type="button"
class="publication-institution-tag"
[class.active]="isAuthorActive(author.person_id!)"
[matTooltip]="getAuthorTooltipText(author)"
matTooltipPosition="above"
[attr.aria-label]="getAuthorTooltipText(author)"
(click)="filterByAuthor(author.person_id!)">
<mat-icon class="institution-icon">person</mat-icon>
<span class="institution-name">{{ author.full_name }}</span>
</button>
} @empty {
<span class="empty-text">-</span>
} -->
<!-- @if (projectAuthors.length > 3) {
<button
type="button"
class="publication-institution-more"
[attr.aria-expanded]="isProjectAuthorsExpanded"
(click)="toggleProjectAuthorsExpansion(project)">
{{
isProjectAuthorsExpanded
? 'weniger'
: '+' + (projectAuthors.length - 3)
}}
</button>
} -->
<!-- </div>
</ng-template> -->
<ng-template #institutionsTmp let-project>
@let institutions = getProjectInstitutions(project);
<div
class="institution-tags"
aria-label="Institutionen"
style="padding: 0.5rem 0">
@for (
institution of isProjectInstitutionsExpanded(project)
? institutions
: institutions.slice(0, 3);
track getProjectInstitutionId(institution)
) {
<button
type="button"
class="publication-institution-tag"
[class.active]="isInstitutionActive(institution.id!)"
[matTooltip]="getInstitutionTooltipText(institution)"
matTooltipPosition="above"
[attr.aria-label]="getInstitutionTooltipText(institution)"
(click)="filterByInstitution(institution)">
<mat-icon class="institution-icon">apartment</mat-icon>
<span class="institution-name">{{
institution.institute_name_de || institution.institute_name_en
}}</span>
</button>
} @empty {
<span class="empty-text">-</span>
}
@if (institutions.length > 3) {
<button
type="button"
class="publication-institution-more"
(click)="toggleProjectInstitutionsExpansion(project)">
@if (isProjectInstitutionsExpanded(project)) {
Weniger anzeigen
} @else {
+{{ institutions.length - 3 }} weitere
}
</button>
}
</div>
</ng-template>
<ng-template #topicsTmp let-project>
@let projectTopics = project.topics ?? [];
@let isTopicsExpanded = isProjectTopicsExpanded(project);
@let visibleTopics =
isTopicsExpanded ? projectTopics : projectTopics.slice(0, 3);
<div class="topic-chips" aria-label="Themen" style="padding: 0.5rem 0">
@for (topic of visibleTopics; track $index) {
<app-topic-chip
size="mini"
[label]="topic.display_name || ''"
[description]="topic.description"
[subfieldName]="topic.subfield?.display_name"
[fieldName]="topic.field?.display_name"
[domainName]="topic.domain?.display_name"
[color]="getWorkTopicColor(topic)"
[disabled]="!topic.id"
[active]="isTopicActive(topic)"
(chipClick)="filterByTopic(topic)">
</app-topic-chip>
} @empty {
<span class="empty-text">-</span>
}
@if (projectTopics.length > 3) {
<button
type="button"
class="publication-institution-more"
[attr.aria-expanded]="isTopicsExpanded"
(click)="toggleProjectTopicsExpansion(project)">
{{ isTopicsExpanded ? 'weniger' : '+' + (projectTopics.length - 3) }}
</button>
}
</div>
</ng-template>
@@ -0,0 +1,220 @@
.page {
padding: 28px 32px 42px;
max-width: 100%;
margin: 0 auto;
}
// ------------------------
// Shared tags & chips
// ------------------------
.publication-institution-tag {
display: inline-flex;
align-items: center;
padding: 2px 6px;
border: 1px solid var(--sg-primary-border, var(--sg-border));
border-radius: 4px;
background: var(--sg-primary-soft);
color: var(--sg-primary);
font-size: 10px;
font-weight: 600;
line-height: normal;
max-width: 100%;
margin: 0;
font-family: inherit;
cursor: pointer;
transition: all 0.2s ease;
&:hover,
&:focus-visible {
background: var(--sg-primary);
color: #fff;
border-color: var(--sg-primary);
outline: none;
box-shadow:
0 0 0 2px var(--sg-background),
0 0 0 4px var(--sg-primary);
}
&.active {
border-color: var(--sg-primary);
box-shadow:
0 0 0 1px #ffffff,
0 0 0 3px var(--sg-primary);
}
&.active:hover,
&.active:focus-visible {
background: var(--sg-primary);
color: #fff;
}
.institution-icon {
flex-shrink: 0;
width: 12px;
height: 12px;
margin-right: 4px;
font-size: 12px;
}
.institution-name {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
min-width: 0;
white-space: normal;
overflow-wrap: anywhere;
}
.flag-img {
flex-shrink: 0;
margin-left: 6px;
border: 1px solid;
}
.country-code {
flex-shrink: 0;
margin-left: 2px;
font-size: 9px;
}
.institution-open-icon {
flex-shrink: 0;
width: 12px;
height: 12px;
margin-left: 5px;
font-size: 12px;
line-height: 1;
cursor: pointer;
opacity: 0;
transition: opacity 0.15s ease;
}
&:hover .institution-open-icon {
opacity: 0.7;
}
.institution-open-icon:hover {
opacity: 1;
}
}
.publication-institution-more {
display: inline-flex;
align-items: center;
min-height: 24px;
padding: 3px 8px;
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
background: #fff;
color: var(--sg-text-muted);
font-family: inherit;
font-size: 11px;
line-height: 1.2;
cursor: pointer;
transition: all 0.2s ease;
&:hover,
&:focus-visible {
border-color: var(--sg-primary);
color: var(--sg-primary);
background: var(--sg-surface-soft);
outline: none;
}
}
// ------------------------
// Containers for chips
// ------------------------
.topic-chips,
.institution-tags,
.author-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.topic-chips {
max-width: 320px;
}
.institution-tags {
align-items: flex-start;
max-width: 280px;
}
.author-tags {
align-items: flex-start;
max-width: 280px;
padding: 0.5rem 0;
}
// ------------------------
// Empty text
// ------------------------
.empty-text {
color: rgba(0, 0, 0, 0.54);
}
// ------------------------
// Classification container
// ------------------------
.classification-container {
max-width: 200px;
}
// ------------------------
// Data table overrides (applied via ::ng-deep)
// ------------------------
::ng-deep {
.mat-mdc-header-cell {
color: var(--sg-text-muted);
font-size: 12px;
font-weight: 700;
}
.mat-mdc-row {
height: 86px;
}
.mat-mdc-cell {
color: var(--sg-text);
border-bottom-color: var(--sg-border);
font-size: 13px;
}
.table-wrap {
.mat-column-type,
.mat-column-year,
.mat-column-language,
.mat-column-citations,
.mat-mdc-header-cell {
text-align: center;
}
.mat-mdc-cell:not(:last-child),
.mat-mdc-header-cell:not(:last-child) {
border-right: 1px solid var(--sg-border);
}
.mat-column-institutions,
.mat-column-topics {
overflow: visible;
}
}
}
// ------------------------
// Responsive adjustments
// ------------------------
@media (max-width: 600px) {
.page {
padding: 16px;
}
}
@@ -0,0 +1,369 @@
import {
Component,
computed,
input,
OnInit,
TemplateRef,
viewChild,
inject,
} from '@angular/core';
import {
BundProjectPage,
DfgProjectPage,
DfgProjectSummary,
Topic,
} from '../../../api';
import { BundProjectSummary } from '../../../api/model/bundProjectSummary';
import { TopicChipComponent } from '../topic-chip/topic-chip.component';
import {
DataTableComponent,
GenericColumn,
} from '../data-table/data-table.component';
import { RouterModule } from '@angular/router';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { QueryParamPaginatorComponent } from '../query-param-paginator/query-param-paginator.component';
import { dfgProjectQueryParamKeys } from '../../../resolvers/dfg-projects.resolver';
import { toSignal } from '@angular/core/rxjs-interop';
import { ActivatedRoute, Router } from '@angular/router';
import { DfgPersonSummary } from '../../../api/model/dfgPersonSummary';
import { MatTooltip } from '@angular/material/tooltip';
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
@Component({
selector: 'app-bund-project-table',
imports: [
DataTableComponent,
RouterModule,
MatIconModule,
MatButtonModule,
QueryParamPaginatorComponent,
MatTooltip,
TopicChipComponent,
],
templateUrl: './bund-project-table.component.html',
styleUrl: './bund-project-table.component.scss',
})
export class BundProjectTableComponent implements OnInit {
private readonly activatedRoute = inject(ActivatedRoute);
private readonly router = inject(Router);
page = input.required<BundProjectPage>();
authorFilterEnabled = input<boolean>(false);
institutionFilterEnabled = input<boolean>(false);
topicFilterEnabled = input<boolean>(false);
elements = computed(() => this.page().elements ?? []);
queryParamMap = toSignal(this.activatedRoute.queryParamMap, {
initialValue: this.activatedRoute.snapshot.queryParamMap,
});
queryParamKeys = dfgProjectQueryParamKeys;
total = computed(() => this.page().total ?? 0);
columns: GenericColumn<BundProjectSummary>[] = [];
titleTmp = viewChild.required<TemplateRef<any>>('titleTmp');
authorsTmp = viewChild.required<TemplateRef<any>>('authorsTmp');
institutionsTmp = viewChild.required<TemplateRef<any>>('institutionsTmp');
fundingStartTmp = viewChild.required<TemplateRef<any>>('fundingStartTmp');
fundingEndTmp = viewChild.required<TemplateRef<any>>('fundingEndTmp');
actionsTmp = viewChild.required<TemplateRef<any>>('actionsTmp');
detailRowTmp = viewChild.required<TemplateRef<any>>('detailRowTmp');
topicsTmp = viewChild.required<TemplateRef<any>>('topicsTmp');
expandedProjectAuthorsId: string[] = [];
expandedProjectInstitutionsId: string[] = [];
expandedProjectTopicsId: string[] = [];
selectedFundingStartYearsQueryParams = computed(() => {
return this.queryParamMap()
.getAll(this.queryParamKeys.funding_start)
.map(Number);
});
selectedFundingEndYearsQueryParams = computed(() => {
return this.queryParamMap()
.getAll(this.queryParamKeys.funding_end)
.map(Number);
});
selectedAuthorIdsQueryParams = computed(() => {
return this.queryParamMap().getAll(this.queryParamKeys.authorId);
});
selectedInstitutionIdsQueryParams = computed(() => {
return this.queryParamMap().getAll(this.queryParamKeys.institutionId);
});
selectedTopicIdsQueryParams = computed(() => {
return this.queryParamMap().getAll(this.queryParamKeys.topicId);
});
ngOnInit(): void {
this.columns = [
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'topic' },
{
id: 'funding_start',
header: 'Förderbeginn',
type: 'accessor',
accessorKey: 'funding_start',
},
{
id: 'funding_end',
header: 'Förderende',
type: 'accessor',
accessorKey: 'funding_end',
cellTemplate: this.fundingEndTmp(),
},
// {
// id: 'names',
// header: 'Autoren',
// type: 'accessor',
// accessorKey: 'names',
// cellTemplate: this.authorsTmp(),
// },
{
id: 'institutions',
header: 'Institutionen',
type: 'display',
cellTemplate: this.institutionsTmp(),
},
{
id: 'professional_classification',
header: 'Fachliche Zuordnung',
type: 'display',
cellTemplate: this.detailRowTmp(),
},
{
id: 'topics',
header: 'Themen',
type: 'display',
cellTemplate: this.topicsTmp(),
},
{
id: 'actions',
header: '',
type: 'display',
cellTemplate: this.actionsTmp(),
},
];
}
sortNames(names: string[] | undefined): string[] {
return [...(names ?? [])].sort((a, b) => a.localeCompare(b));
}
isAuthorActive(authorId: number): boolean {
return (
!!authorId &&
this.authorFilterEnabled() &&
this.selectedAuthorIdsQueryParams().includes(String(authorId))
);
}
// getProjectAuthors(project: DfgProjectSummary): DfgPersonSummary[] {
// return project.persons?.filter((a): a is DfgPersonSummary => !!a) || [];
// }
// toggleProjectAuthorsExpansion(project: DfgProjectSummary): void {
// if (!project.id) return;
// if (this.expandedProjectAuthorsId.includes(project.id)) {
// this.expandedProjectAuthorsId = this.expandedProjectAuthorsId.filter(
// (id) => id !== project.id,
// );
// } else {
// this.expandedProjectAuthorsId.push(project.id);
// }
// }
isProjectPersonsExpanded(project: DfgProjectSummary): boolean {
if (!project.id) return false;
return this.expandedProjectAuthorsId.includes(project.id);
}
// getAuthorTooltipText(author: DfgPersonSummary): string {
// if (this.authorFilterEnabled() && author.person_id) {
// return `Nach Autor filtern: ${author.full_name}`;
// }
// return `Autor: ${author.full_name}`;
// }
// filterByAuthor(authorId: number): void {
// if (!authorId || !this.authorFilterEnabled()) return;
// const selectedAuthorIds = this.selectedAuthorIdsQueryParams();
// if (selectedAuthorIds.includes(String(authorId))) {
// this.router.navigate([], {
// queryParams: {
// [this.queryParamKeys.authorId]: selectedAuthorIds.filter(
// (id) => id !== String(authorId),
// ),
// [this.queryParamKeys.page]: 0,
// },
// queryParamsHandling: 'merge',
// });
// } else {
// this.router.navigate([], {
// queryParams: {
// [this.queryParamKeys.authorId]: [
// ...selectedAuthorIds,
// String(authorId),
// ],
// [this.queryParamKeys.page]: 0,
// },
// queryParamsHandling: 'merge',
// });
// }
// }
isProjectInstitutionsExpanded(project: DfgProjectSummary): boolean {
if (!project.id) return false;
return this.expandedProjectInstitutionsId.includes(project.id);
}
toggleProjectInstitutionsExpansion(project: DfgProjectSummary): void {
if (!project.id) return;
if (this.expandedProjectInstitutionsId.includes(project.id)) {
this.expandedProjectInstitutionsId =
this.expandedProjectInstitutionsId.filter((id) => id !== project.id);
} else {
this.expandedProjectInstitutionsId.push(project.id);
}
}
getProjectInstitutions(project: DfgProjectSummary): any[] {
const institutions = new Map<string, any>();
for (const institution of project.institutions ?? []) {
const id = this.getProjectInstitutionId(institution);
if (!id) continue;
institutions.set(id, institution);
}
return Array.from(institutions.values()).sort((a, b) =>
this.getProjectInstitutionName(a).localeCompare(
this.getProjectInstitutionName(b),
),
);
}
getProjectInstitutionId(institution: any): string | null {
const id = institution.id;
return id == null ? null : String(id);
}
getProjectInstitutionName(institution: any): string {
return institution.institute_name_de ?? institution.institute_name_en;
}
isInstitutionActive(
institutionId: string | number | null | undefined,
): boolean {
return (
!!institutionId &&
this.institutionFilterEnabled() &&
this.selectedInstitutionIdsQueryParams().includes(String(institutionId))
);
}
filterByInstitution(institution: any): void {
const institutionId = this.getProjectInstitutionId(institution);
if (!institutionId || !this.institutionFilterEnabled()) return;
const selectedInstitutionIds = this.selectedInstitutionIdsQueryParams();
if (selectedInstitutionIds.includes(institutionId)) {
this.router.navigate([], {
queryParams: {
[this.queryParamKeys.institutionId]: selectedInstitutionIds.filter(
(id) => id !== institutionId,
),
[this.queryParamKeys.page]: 0,
},
queryParamsHandling: 'merge',
});
} else {
this.router.navigate([], {
queryParams: {
[this.queryParamKeys.institutionId]: [
...selectedInstitutionIds,
institutionId,
],
[this.queryParamKeys.page]: 0,
},
queryParamsHandling: 'merge',
});
}
}
getInstitutionTooltipText(institution: any): string {
const name = this.getProjectInstitutionName(institution);
if (this.institutionFilterEnabled()) {
return `Nach Institution filtern: ${name}`;
}
return `Institution: ${name}`;
}
getWorkTopicColor(topic: Topic): string {
return topicHierarchyColor({
id: topic.id,
name: topic.display_name,
field_id: topic.field?.id,
field_name: topic.field?.display_name,
domain_id: topic.domain?.id,
domain_name: topic.domain?.display_name,
});
}
isTopicActive(topic: Topic): boolean {
return (
!!topic.id &&
this.authorFilterEnabled() &&
this.selectedTopicIdsQueryParams().includes(topic.id)
);
}
filterByTopic(topic: Topic): void {
if (!topic.id || !this.topicFilterEnabled()) return;
const selectedTopicIds = this.selectedTopicIdsQueryParams();
if (selectedTopicIds.includes(topic.id)) {
this.router.navigate([], {
queryParams: {
[this.queryParamKeys.topicId]: selectedTopicIds.filter(
(id) => id !== topic.id,
),
[this.queryParamKeys.page]: 0,
},
queryParamsHandling: 'merge',
});
} else {
this.router.navigate([], {
queryParams: {
[this.queryParamKeys.topicId]: [...selectedTopicIds, topic.id],
[this.queryParamKeys.page]: 0,
},
queryParamsHandling: 'merge',
});
}
}
toggleProjectTopicsExpansion(project: DfgProjectSummary): void {
if (!project.id) return;
if (this.expandedProjectTopicsId.includes(project.id)) {
this.expandedProjectTopicsId = this.expandedProjectTopicsId.filter(
(id) => id !== project.id,
);
} else {
this.expandedProjectTopicsId.push(project.id);
}
}
isProjectTopicsExpanded(project: DfgProjectSummary): boolean {
if (!project.id) return false;
return this.expandedProjectTopicsId.includes(project.id);
}
}
@@ -0,0 +1,19 @@
<div>
<app-project-filters
filterMode="bund"
[queryParamKeys]="bundQueryParamKeys"
[selectedBundInstitutionsPage]="selectedBundInstitutionsPage()"
[selectedTopicsPage]="selectedTopicsPage()"
[showFundingStartFilter]="true"
[showTopicFilter]="topicFilterEnabled()"
[showFundingEndFilter]="true"
[showAuthorFilter]="true"
[showInstitutionFilter]="true"
[showEuProjectTypeFilter]="false" />
<app-bund-project-table
[page]="bundProjectPage()"
[authorFilterEnabled]="true"
[topicFilterEnabled]="topicFilterEnabled()"
[institutionFilterEnabled]="true" />
</div>
@@ -0,0 +1,53 @@
import { Component, computed, input } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { toSignal } from '@angular/core/rxjs-interop';
import {
BundProjectPage,
DfgPersonSummaryPage,
TopicPageV2,
} from '../../../api';
import { DfgInstitutionSummaryPage } from '../../../api/model/dfgInstitutionSummaryPage';
import { MatCardModule } from '@angular/material/card';
import { MatTabsModule } from '@angular/material/tabs';
import { ProjectFilterComponent } from '../project-filters/project-filters.component';
import { BundProjectTableComponent } from '../bund-project-table/bund-project-table.component';
import { bundProjectQueryParamKeys } from '../../../resolvers/bund-projects.resolver';
@Component({
selector: 'app-bund-projects',
imports: [
MatCardModule,
MatTabsModule,
ProjectFilterComponent,
BundProjectTableComponent,
],
templateUrl: './bund-projects.component.html',
styleUrl: './bund-projects.component.scss',
})
export class BundProjectsComponent {
bundProjectPage = input.required<BundProjectPage>();
selectedBundInstitutionsPage = input.required<DfgInstitutionSummaryPage>();
selectedBundAuthorsPage = input.required<DfgPersonSummaryPage>();
selectedTopicsPage = input.required<TopicPageV2>();
readonly bundQueryParamKeys = bundProjectQueryParamKeys;
constructor(
private readonly router: Router,
private readonly activatedRoute: ActivatedRoute,
) {
console.log('BundProjectsComponent created');
}
ngOnInit(): void {
console.log('BUND PROJECTS', this.bundProjectPage());
}
queryParamMap = toSignal(this.activatedRoute.queryParamMap, {
initialValue: this.activatedRoute.snapshot.queryParamMap,
});
readonly topicFilterEnabled = computed(
() =>
this.queryParamMap().get('fuzzy') === 'true' ||
this.queryParamMap().get('fuzzy') === null,
);
}