added project filters and tables components (DFG and EU)

This commit is contained in:
2026-07-19 18:41:54 +02:00
parent 9e48cc1641
commit 8e352dfbb2
11 changed files with 1436 additions and 202 deletions
@@ -5,78 +5,26 @@
</div>
<mat-card appearance="outlined">
<mat-card-content>
<app-query-param-input label="Suche nach Titel" queryParamKey="search" />
<mat-tab-group>
<mat-tab-group
[selectedIndex]="selectedTabIndex()"
(selectedIndexChange)="onTabChange($event)">
<mat-tab label="DFG">
<app-data-table
[columns]="dfgProjectColumns"
[data]="dfgProjectData"
[detailTemplate]="dfgProjectDetailRowTmp"
queryParamSortKey="sort_by"
queryParamSortDirectionKey="sort_direction" />
<app-project-filters
[selectedInstitutions]="selectedDfgInstitutions()"
[showAuthorFilter]="true"
[showInstitutionFilter]="true" />
<app-dfg-project-table
[page]="dfgProjectPage()"
[authorFilterEnabled]="true"
[institutionFilterEnabled]="true" />
</mat-tab>
<mat-tab label="EU">
<app-data-table
[columns]="personCordisEuProjectColumns"
[data]="personCordisEuProjectData"
queryParamSortKey="sort_by"
queryParamSortDirectionKey="sort_direction" />
<app-project-filters
[selectedInstitutions]="selectedEuInstitutions()"
[selectedAuthors]="selectedEuAuthors()" />
<app-eu-project-table [page]="personCordisEuProjectPage()" />
</mat-tab>
</mat-tab-group>
<app-query-param-paginator
[total]="this.pageTotal()"
[pageSizeOptions]="[10]" />
</mat-card-content>
</mat-card>
</div>
<ng-template #dfgProjectActionsTmp 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 #dfgProjectFundingEndTmp let-element>
{{ element.funding_end == '2999' ? 'laufend' : element.funding_end }}
</ng-template>
<ng-template #dfgProjectDetailRowTmp let-element>
<div class="detail-row">
<ul>
@for (
name of element.names.sort((a, b) => a.localeCompare(b));
track $index
) {
<li>
{{ name }}
</li>
}
</ul>
</div>
</ng-template>
<ng-template #euProjectsFundingStartTmp let-element>
{{ element.startDate | date: 'dd.MM.yyyy' }}
</ng-template>
<ng-template #euProjectsFundingEndTmp let-element>
{{ element.endDate | date: 'dd.MM.yyyy' }}
</ng-template>
<ng-template #euProjectsFundingAmountTmp let-element>
{{ element.ecMaxContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }}
</ng-template>
<ng-template #euProjectsActionsTmp let-element>
<a
[routerLink]="['/projects/eu', element.id]"
target="_blank"
mat-icon-button
color="primary">
<mat-icon>open_in_new</mat-icon>
</a>
</ng-template>
@@ -1,160 +1,65 @@
import { Component, computed, input } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { toSignal } from '@angular/core/rxjs-interop';
import {
Component,
computed,
effect,
input,
OnInit,
TemplateRef,
viewChild,
} from '@angular/core';
import {
CordisEuProject,
CordisEuProjectPage,
DfgProjectPage,
DfgProjectSummary,
Author,
Institution,
} from '../../api';
import {
DataTableComponent,
GenericColumn,
} from '../../shared/ui/data-table/data-table.component';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatTabsModule } from '@angular/material/tabs';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { Router, RouterModule } from '@angular/router';
import { CurrencyPipe, DatePipe } from '@angular/common';
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
import { QueryParamInputComponent } from '../../shared/ui/query-param-input/query-param-input.component';
import { ProjectFilterComponent } from '../../shared/ui/project-filters/project-filters.component';
import { DfgProjectTableComponent } from '../../shared/ui/dfg-project-table/dfg-project-table.component';
import { EuProjectTableComponent } from '../../shared/ui/eu-project-table/eu-project-table.component';
import { projectQueryParamKeys } from '../../resolvers/dfg-projects.resolver';
import { euProjectQueryParamKeys } from '../../resolvers/person-cordis-eu-project-page.resolver';
const PROJECT_TAB_QUERY_PARAM_KEY = 'project_type';
@Component({
selector: 'app-person-projects',
imports: [
DataTableComponent,
MatIconModule,
MatButtonModule,
MatCardModule,
MatTabsModule,
MatFormFieldModule,
MatInputModule,
RouterModule,
DatePipe,
CurrencyPipe,
QueryParamPaginatorComponent,
QueryParamInputComponent,
ProjectFilterComponent,
DfgProjectTableComponent,
EuProjectTableComponent,
],
templateUrl: './person-projects.component.html',
styleUrl: './person-projects.component.scss',
})
export class PersonProjectsComponent implements OnInit {
export class PersonProjectsComponent {
dfgProjectPage = input.required<DfgProjectPage>();
dfgProjectColumns: GenericColumn<DfgProjectSummary>[] = [];
dfgProjectData: DfgProjectSummary[] = [];
dfgProjectFundingEndTmp = viewChild.required<TemplateRef<any>>(
'dfgProjectFundingEndTmp',
);
dfgProjectActionsTmp = viewChild.required<TemplateRef<any>>(
'dfgProjectActionsTmp',
);
dfgProjectDetailRowTmp = viewChild.required<TemplateRef<any>>(
'dfgProjectDetailRowTmp',
);
personCordisEuProjectPage = input.required<CordisEuProjectPage>();
personCordisEuProjectColumns: GenericColumn<CordisEuProject>[] = [];
personCordisEuProjectData: CordisEuProject[] = [];
euProjectsFundingStartTmp = viewChild.required<TemplateRef<any>>(
'euProjectsFundingStartTmp',
);
euProjectsFundingEndTmp = viewChild.required<TemplateRef<any>>(
'euProjectsFundingEndTmp',
);
euProjectsFundingAmountTmp = viewChild.required<TemplateRef<any>>(
'euProjectsFundingAmountTmp',
);
euProjectsActionsTmp = viewChild.required<TemplateRef<any>>(
'euProjectsActionsTmp',
);
selectedDfgInstitutions = input.required<Institution[]>();
selectedDfgAuthors = input.required<Author[]>();
selectedEuInstitutions = input.required<Institution[]>();
selectedEuAuthors = input.required<Author[]>();
readonly pageTotal = computed(() => {
return this.dfgProjectPage()?.total ?? 0;
readonly dfgQueryParamKeys = projectQueryParamKeys;
readonly euQueryParamKeys = euProjectQueryParamKeys;
constructor(
private readonly router: Router,
private readonly activatedRoute: ActivatedRoute,
) {}
queryParamMap = toSignal(this.activatedRoute.queryParamMap, {
initialValue: this.activatedRoute.snapshot.queryParamMap,
});
constructor(private readonly router: Router) {
effect(() => {
this.dfgProjectData = this.dfgProjectPage().elements || [];
selectedTabIndex = computed(() => {
const type = this.queryParamMap().get(PROJECT_TAB_QUERY_PARAM_KEY);
return type === 'eu' ? 1 : 0;
});
onTabChange(index: number): void {
const type = index === 1 ? 'eu' : 'dfg';
this.router.navigate([], {
queryParams: { [PROJECT_TAB_QUERY_PARAM_KEY]: type },
queryParamsHandling: 'merge',
});
effect(() => {
this.personCordisEuProjectData =
this.personCordisEuProjectPage().elements || [];
});
}
ngOnInit(): void {
this.dfgProjectColumns = [
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' },
{
id: 'funding_start',
header: 'Förderbeginn',
type: 'accessor',
accessorKey: 'funding_start',
},
{
id: 'funding_end',
header: 'Förderende',
type: 'accessor',
accessorKey: 'funding_end',
cellTemplate: this.dfgProjectFundingEndTmp(),
},
{
id: 'professional_classification',
header: 'Fachliche Zuordnung',
type: 'accessor',
accessorKey: 'professional_classification',
},
{
id: 'actions',
header: '',
type: 'display',
cellTemplate: this.dfgProjectActionsTmp(),
},
];
this.personCordisEuProjectColumns = [
{
id: 'title',
header: 'Titel',
type: 'accessor',
accessorKey: 'title',
},
{
id: 'startDate',
header: 'Startdatum',
type: 'display',
cellTemplate: this.euProjectsFundingStartTmp(),
},
{
id: 'endDate',
header: 'Enddatum',
type: 'display',
cellTemplate: this.euProjectsFundingEndTmp(),
},
{
id: 'ecMaxContribution',
header: 'Förderbetrag (EU)',
type: 'display',
cellTemplate: this.euProjectsFundingAmountTmp(),
},
{
id: 'actions',
header: '',
type: 'display',
cellTemplate: this.euProjectsActionsTmp(),
},
];
}
}
@@ -0,0 +1,160 @@
<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' ? '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 #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.name_de }}</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 #institutionsTmp let-work>
@let publicationInstitutions = getWorkInstitutions(work);
@let institutionsExpanded = isWorkInstitutionsExpanded(work);
@let visibleInstitutions =
institutionsExpanded
? publicationInstitutions
: publicationInstitutions.slice(0, 3);
<div
class="institution-tags"
aria-label="Institutionen"
style="padding: 0.5rem 0">
@for (institution of visibleInstitutions; track institution.id) {
<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.display_name }}</span>
@if (institution.country_code) {
<img
alt=""
class="flag-img"
[src]="
'https://flagcdn.io/' +
institution.country_code.toLowerCase() +
'.svg'
"
height="10" />
<span class="country-code">{{
institution.country_code.toUpperCase()
}}</span>
}
</button>
} @empty {
<span class="empty-text">-</span>
}
@if (publicationInstitutions.length > 3) {
<button
type="button"
class="publication-institution-more"
[attr.aria-expanded]="institutionsExpanded"
(click)="toggleWorkInstitutionsExpansion(work)">
{{
institutionsExpanded
? 'weniger'
: '+' + (publicationInstitutions.length - 3)
}}
</button>
}
</div>
</ng-template> -->
@@ -0,0 +1,594 @@
.page {
padding: 28px 32px 42px;
max-width: 100%;
margin: 0 auto;
}
.publication-filter-stack {
display: flex;
align-items: flex-start;
flex-direction: column;
gap: 8px;
padding-top: 10px;
padding-bottom: 25px;
}
.publication-filters {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
align-items: center;
gap: 10px;
}
.publication-filters mat-form-field {
width: 175px;
}
.publication-filters .institution-filter,
.publication-filters .topic-filter {
flex: 1 1 200px;
width: auto;
min-width: 180px;
max-width: 320px;
}
.publication-filters .sort-field {
width: 235px;
}
.publication-filters .reset-filter-btn {
min-width: 132px;
height: 42px;
padding: 0 14px;
border-color: #d9e2f0;
border-radius: var(--sg-radius-sm);
color: var(--sg-text);
background: #fff;
}
.publication-filters .reset-filter-btn mat-icon {
margin-right: 6px;
width: 20px;
height: 20px;
font-size: 20px;
}
::ng-deep .publication-filters .mat-mdc-form-field-subscript-wrapper {
display: none;
}
::ng-deep .publication-filters .mat-mdc-text-field-wrapper {
height: 42px;
background: var(--sg-surface-soft);
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
transition:
border-color 0.15s,
box-shadow 0.15s;
}
::ng-deep .publication-filters .mat-focused .mat-mdc-text-field-wrapper {
border-color: var(--sg-primary);
box-shadow: 0 0 0 2px var(--sg-primary-soft);
}
::ng-deep .publication-filters .mat-mdc-form-field-flex {
height: 100%;
align-items: center;
}
::ng-deep .publication-filters .mat-mdc-form-field-infix {
min-height: 0;
padding-top: 0;
padding-bottom: 0;
}
::ng-deep .publication-filters .mdc-notched-outline__leading,
::ng-deep .publication-filters .mdc-notched-outline__notch,
::ng-deep .publication-filters .mdc-notched-outline__trailing {
border: none;
}
.filter-prefix-icon {
width: 18px;
height: 18px;
font-size: 18px;
color: var(--sg-text-soft);
}
::ng-deep .publication-filters .mat-mdc-form-field-icon-prefix {
padding: 0 4px 0 10px;
color: var(--sg-text-soft);
}
::ng-deep .publication-filters .mat-mdc-select-value,
::ng-deep .publication-filters input.mat-mdc-input-element {
color: var(--sg-text);
font-size: 14px;
}
::ng-deep .publication-filters .mat-mdc-select-placeholder,
::ng-deep .publication-filters input.mat-mdc-input-element::placeholder {
color: var(--sg-text-muted);
opacity: 1;
font-size: 14px;
}
::ng-deep .publication-filters .mat-mdc-form-field-icon-suffix,
::ng-deep .publication-filters .mat-mdc-select-arrow-wrapper {
transform: none;
}
.active-filters-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
padding: 8px 16px;
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
background: var(--sg-surface);
font-size: 13px;
}
.active-filters-label {
font-weight: 600;
color: var(--sg-text-muted);
}
.chips-container {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px;
}
.filter-meta-chip {
display: inline-flex;
align-items: center;
padding: 2px 8px;
border: 1px solid var(--sg-border-strong);
border-radius: 4px;
background: var(--sg-surface-soft);
color: var(--sg-text);
font-size: 11px;
font-weight: 600;
}
.filter-topic-chip {
display: inline-flex;
align-items: center;
gap: 4px;
max-width: min(320px, 46vw);
padding: 3px 8px;
border-radius: 7px;
background: color-mix(in srgb, var(--topic-color) 22%, #ffffff);
color: color-mix(in srgb, var(--topic-color) 45%, #07163d);
font-size: 11px;
font-weight: 700;
box-shadow: inset 0 0 0 1px
color-mix(in srgb, var(--topic-color) 45%, transparent);
}
.filter-topic-chip__icon {
flex: 0 0 auto;
width: 14px;
height: 14px;
font-size: 14px;
}
.active-institution-filter,
.active-meta-filter {
display: inline-flex;
align-items: center;
gap: 4px;
max-width: 100%;
}
.filter-institution-chip,
.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;
}
.filter-institution-chip {
max-width: 340px;
}
.publication-institution-tag {
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;
}
}
.filter-institution-chip .institution-icon,
.publication-institution-tag .institution-icon,
.filter-meta-chip__icon {
flex-shrink: 0;
width: 12px;
height: 12px;
margin-right: 4px;
font-size: 12px;
}
.filter-meta-chip__icon {
color: var(--sg-text-soft);
}
.filter-institution-chip .institution-name,
.publication-institution-tag .institution-name {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
min-width: 0;
white-space: normal;
overflow-wrap: anywhere;
}
.filter-institution-chip .flag-img,
.publication-institution-tag .flag-img {
flex-shrink: 0;
margin-left: 6px;
border: 1px solid;
}
.filter-institution-chip .country-code,
.publication-institution-tag .country-code {
flex-shrink: 0;
margin-left: 2px;
font-size: 9px;
}
.filter-institution-chip .institution-open-icon,
.publication-institution-tag .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;
}
.filter-institution-chip:hover .institution-open-icon,
.publication-institution-tag:hover .institution-open-icon {
opacity: 0.7;
}
.filter-institution-chip .institution-open-icon:hover,
.publication-institution-tag .institution-open-icon:hover {
opacity: 1;
}
.filter-meta-chip__label,
.filter-topic-chip__label {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
}
.active-institution-filter button,
.active-meta-filter button {
display: flex;
padding: 0;
border: 0;
background: transparent;
color: var(--sg-text-soft);
cursor: pointer;
&:hover {
color: var(--sg-text);
}
}
.active-institution-filter button mat-icon,
.active-meta-filter button mat-icon {
width: 12px;
height: 12px;
font-size: 12px;
}
.table-wrap {
position: relative;
overflow-x: auto;
}
table {
width: 100%;
min-width: 1120px;
border-collapse: separate;
border-spacing: 0 10px;
box-shadow: none;
background: transparent;
}
.title {
display: inline-block;
max-width: 520px;
line-height: 1.35;
color: var(--sg-text);
font-size: 14px;
font-weight: 700;
text-decoration: none;
}
a.title:hover {
color: var(--sg-text);
text-decoration: underline;
}
table.is-hidden {
display: none;
}
.table-status {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
min-height: 240px;
padding: 32px;
color: var(--sg-text-muted);
font-size: 14px;
text-align: center;
}
.empty-text {
color: rgba(0, 0, 0, 0.54);
}
.cell-filter-pill {
display: inline-flex;
align-items: center;
margin: 0;
padding: 3px 10px;
border: 1px solid var(--sg-border);
border-radius: 999px;
background: #fff;
color: var(--sg-text);
font-family: inherit;
font-size: 12px;
line-height: 1.2;
cursor: pointer;
transition: all 0.2s ease;
&:hover,
&:focus-visible {
border-color: var(--sg-primary);
background: var(--sg-surface-soft);
outline: none;
}
&.active {
border-color: var(--sg-primary);
color: var(--sg-primary);
font-weight: 600;
box-shadow:
0 0 0 1px #ffffff,
0 0 0 3px var(--sg-primary);
}
}
.type-filter-btn {
display: inline-flex;
margin: 0;
padding: 0;
border: 0;
border-radius: 7px;
background: transparent;
cursor: pointer;
transition: box-shadow 0.2s ease;
&:hover,
&:focus-visible {
outline: none;
box-shadow: 0 0 0 1px var(--sg-primary);
}
&.active {
box-shadow:
0 0 0 1px #ffffff,
0 0 0 3px var(--sg-primary);
}
}
.topic-chips,
.institution-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.topic-chips {
max-width: 320px;
}
.institution-tags {
align-items: flex-start;
max-width: 280px;
}
.publication-institution-more,
.publication-topic-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;
}
}
.publication-topic-more {
max-width: 180px;
}
::ng-deep .mat-mdc-header-cell {
color: var(--sg-text-muted);
font-size: 12px;
font-weight: 700;
}
::ng-deep .mat-mdc-row {
height: 86px;
}
::ng-deep .mat-mdc-cell {
color: var(--sg-text);
border-bottom-color: var(--sg-border);
font-size: 13px;
}
.table-wrap ::ng-deep {
.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;
}
}
mat-paginator {
background: transparent;
}
.table-footer {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 66px;
padding: 0 22px 0 28px;
border: 0;
color: var(--sg-text-muted);
font-size: 13px;
}
@media (max-width: 600px) {
.page {
padding: 16px;
}
.table-footer {
align-items: stretch;
flex-direction: column;
}
.publication-filter-stack {
align-items: stretch;
}
.publication-filters {
justify-content: stretch;
max-width: none;
}
.publication-filters mat-form-field,
.publication-filters button {
width: 100%;
}
.publication-filters .institution-filter,
.publication-filters .topic-filter {
width: 100%;
}
.active-filters-row {
align-self: stretch;
}
}
mat-expansion-panel {
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
background: var(--sg-none);
box-shadow: none;
}
mat-expansion-panel-header {
padding: 0 16px;
min-height: 48px;
}
mat-panel-title {
font-size: 16px;
font-weight: 700;
}
mat-panel-description {
font-size: 14px;
color: var(--sg-text-muted);
}
// ------------------------
.author-tags {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: flex-start;
max-width: 280px;
}
@@ -0,0 +1,285 @@
import {
Component,
computed,
input,
OnInit,
TemplateRef,
viewChild,
inject,
} from '@angular/core';
import { DfgProjectPage, DfgProjectSummary } from '../../../api';
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 { projectQueryParamKeys } 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';
@Component({
selector: 'app-dfg-project-table',
imports: [
DataTableComponent,
RouterModule,
MatIconModule,
MatButtonModule,
QueryParamPaginatorComponent,
MatTooltip,
],
templateUrl: './dfg-project-table.component.html',
styleUrl: './dfg-project-table.component.scss',
})
export class DfgProjectTableComponent implements OnInit {
private readonly activatedRoute = inject(ActivatedRoute);
private readonly router = inject(Router);
page = input.required<DfgProjectPage>();
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 = projectQueryParamKeys;
total = computed(() => this.page().total ?? 0);
columns: GenericColumn<DfgProjectSummary>[] = [];
titleTmp = viewChild.required<TemplateRef<any>>('titleTmp');
yearTmp = viewChild.required<TemplateRef<any>>('yearTmp');
authorsTmp = viewChild.required<TemplateRef<any>>('authorsTmp');
institutionsTmp = viewChild.required<TemplateRef<any>>('institutionsTmp');
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[] = [];
selectedYearsQueryParams = computed(() => {
return this.queryParamMap().getAll(this.queryParamKeys.years).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 {
console.log('DFG PROJECTS', this.page());
this.columns = [
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' },
{
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: 'user',
type: 'accessor',
accessorKey: 'names',
cellTemplate: this.authorsTmp(),
},
{
id: 'institutions',
header: 'Institutionen',
type: 'display',
cellTemplate: this.institutionsTmp(),
},
{
id: 'professional_classification',
header: 'Fachliche Zuordnung',
type: 'accessor',
accessorKey: 'professional_classification',
},
{
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.name_de ?? institution.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}`;
}
}
@@ -0,0 +1,33 @@
<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 #fundingStartTmp let-element>
{{ element.startDate | date: 'dd.MM.yyyy' }}
</ng-template>
<ng-template #fundingEndTmp let-element>
{{ element.endDate | date: 'dd.MM.yyyy' }}
</ng-template>
<ng-template #fundingAmountTmp let-element>
{{ element.ecMaxContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }}
</ng-template>
<ng-template #actionsTmp let-element>
<a
[routerLink]="['/projects/eu', element.id]"
target="_blank"
mat-icon-button
color="primary">
<mat-icon>open_in_new</mat-icon>
</a>
</ng-template>
@@ -0,0 +1,78 @@
import {
Component,
computed,
input,
OnInit,
TemplateRef,
viewChild,
} from '@angular/core';
import { CordisEuProject, CordisEuProjectPage } from '../../../api';
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 { CurrencyPipe, DatePipe } from '@angular/common';
import { QueryParamPaginatorComponent } from '../query-param-paginator/query-param-paginator.component';
import { projectQueryParamKeys } from '../../../resolvers/dfg-projects.resolver';
@Component({
selector: 'app-eu-project-table',
imports: [
DataTableComponent,
RouterModule,
MatIconModule,
MatButtonModule,
DatePipe,
CurrencyPipe,
QueryParamPaginatorComponent,
],
templateUrl: './eu-project-table.component.html',
styleUrl: './eu-project-table.component.scss',
})
export class EuProjectTableComponent implements OnInit {
page = input.required<CordisEuProjectPage>();
queryParamKeys = projectQueryParamKeys;
elements = computed(() => this.page().elements ?? []);
total = computed(() => this.page().total ?? 0);
columns: GenericColumn<CordisEuProject>[] = [];
fundingStartTmp = viewChild.required<TemplateRef<any>>('fundingStartTmp');
fundingEndTmp = viewChild.required<TemplateRef<any>>('fundingEndTmp');
fundingAmountTmp = viewChild.required<TemplateRef<any>>('fundingAmountTmp');
actionsTmp = viewChild.required<TemplateRef<any>>('actionsTmp');
ngOnInit(): void {
this.columns = [
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' },
{
id: 'startDate',
header: 'Startdatum',
type: 'display',
cellTemplate: this.fundingStartTmp(),
},
{
id: 'endDate',
header: 'Enddatum',
type: 'display',
cellTemplate: this.fundingEndTmp(),
},
{
id: 'ecMaxContribution',
header: 'Förderbetrag (EU)',
type: 'display',
cellTemplate: this.fundingAmountTmp(),
},
{
id: 'actions',
header: '',
type: 'display',
cellTemplate: this.actionsTmp(),
},
];
}
}
@@ -0,0 +1,36 @@
<div class="content">
@if (showTitleFilter()) {
<app-query-param-input
[queryParamKey]="queryParamKeys.title"
label="Suche nach Titel"
placeholder="Suche"
[debounceTime]="300" />
}
<div class="select-area">
@if (showInstitutionFilter()) {
<app-searchable-institution-select
[label]="institutionLabel()"
[selectedInstitutions]="selectedInstitutions()"
(handleInstitutionSelectChange)="
handleInstitutionSelectChange($event)
" />
}
@if (showYearFilter()) {
<app-searchable-year-select
[label]="yearLabel()"
[selectedYears]="selectedYears()"
(handleYearSelectChange)="handleYearSelectChange($event)" />
}
@if (showAuthorFilter()) {
<app-searchable-author-select
[label]="authorLabel()"
[selectedAuthors]="selectedAuthors()"
(handleAuthorSelectChange)="handleAuthorSelectChange($event)" />
}
<button mat-stroked-button color="primary" (click)="resetFilters()">
<mat-icon>filter_alt_off</mat-icon>
Filter zurücksetzen
</button>
</div>
<app-selected-filters [observers]="observers()" />
</div>
@@ -0,0 +1,13 @@
.content {
display: flex;
flex-direction: column;
gap: 1rem;
}
.select-area {
display: flex;
gap: 1rem;
flex-wrap: wrap;
width: 100%;
align-items: center;
}
@@ -0,0 +1,182 @@
import { Component, computed, input } from '@angular/core';
import { Router } from '@angular/router';
import { toSignal } from '@angular/core/rxjs-interop';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { Author, Institution } from '../../../api';
import { QueryParamInputComponent } from '../query-param-input/query-param-input.component';
import { SearchableInstitutionSelectComponent } from '../searchable-institution-select/searchable-institution-select.component';
import { SearchableAuthorSelectComponent } from '../searchable-author-select/searchable-author-select.component';
import { SearchableYearSelectComponent } from '../searchable-year-select/searchable-year-select.component';
import { projectQueryParamKeys } from '../../../resolvers/dfg-projects.resolver';
import {
FilterObserver,
SelectedFiltersComponent,
} from '../selected-filters/selected-filters.component';
import { map } from 'rxjs/internal/operators/map';
@Component({
selector: 'app-project-filters',
imports: [
MatButtonModule,
MatIconModule,
QueryParamInputComponent,
SearchableInstitutionSelectComponent,
SearchableAuthorSelectComponent,
SearchableYearSelectComponent,
SelectedFiltersComponent,
],
templateUrl: './project-filters.component.html',
styleUrl: './project-filters.component.scss',
})
export class ProjectFilterComponent {
constructor(private readonly router: Router) {}
// Each tab (DFG / EU) passes its OWN key set so they never collide.
queryParamKeys = projectQueryParamKeys;
selectedInstitutions = input<Institution[]>([]);
selectedTopics = input<string[]>([]);
selectedAuthors = input<Author[]>([]);
showTitleFilter = input<boolean>(true);
showInstitutionFilter = input<boolean>(true);
showAuthorFilter = input<boolean>(true);
showYearFilter = input<boolean>(true);
queryParamMap = toSignal(this.router.routerState.root.queryParamMap, {
initialValue: this.router.routerState.snapshot.root.queryParamMap,
});
selectedInstitutionIds = computed(() =>
this.queryParamMap().getAll(this.queryParamKeys.institutionId),
);
selectedAuthorIds = computed(() =>
this.queryParamMap().getAll(this.queryParamKeys.authorId),
);
selectedYears = computed(() =>
this.queryParamMap().getAll(this.queryParamKeys.years).map(Number),
);
yearLabel = computed(() => {
const selectedYears = this.selectedYears();
if (selectedYears.length === 0) {
return 'Jahr';
} else if (selectedYears.length === 1) {
return selectedYears[0].toString();
} else {
return `${selectedYears.length} Jahre`;
}
});
institutionLabel = computed(() => {
const selected = this.selectedInstitutions().filter((i) =>
this.selectedInstitutionIds().includes(i.id!),
);
if (selected.length === 0) return 'Institution';
if (selected.length === 1) return selected[0].display_name ?? 'Institution';
return `${selected.length} Institutionen`;
});
authorLabel = computed(() => {
const selected = this.selectedAuthors().filter((a) =>
this.selectedAuthorIds().includes(a.id!),
);
if (selected.length === 0) return 'Autor';
if (selected.length === 1) return selected[0].display_name ?? 'Autor';
return `${selected.length} Autoren`;
});
observers = computed<FilterObserver[]>(() => {
const keys = this.queryParamKeys;
return [
{ id: 'search', queryParamKey: keys.title, icon: 'search' },
{
id: 'years',
queryParamKey: projectQueryParamKeys.years,
icon: 'calendar_today',
},
{
id: 'institutions',
queryParamKey: keys.institutionId,
icon: 'apartment',
valueFormatter: (value: string) =>
this.selectedInstitutions().find((i) => i.id === value)
?.display_name ?? value,
},
{
id: 'authors',
queryParamKey: keys.authorId,
icon: 'person',
valueFormatter: (value: string) =>
this.selectedAuthors().find((a) => a.id === value)?.display_name ??
value,
},
];
});
handleYearSelectChange = (selectedYear: number): void => {
if (this.selectedYears().includes(selectedYear)) {
this.router.navigate([], {
queryParams: {
[projectQueryParamKeys.years]: this.selectedYears().filter(
(year) => year !== selectedYear,
),
},
queryParamsHandling: 'merge',
});
} else {
this.router.navigate([], {
queryParams: {
[projectQueryParamKeys.years]: [
...this.selectedYears(),
selectedYear,
],
},
queryParamsHandling: 'merge',
});
}
};
handleInstitutionSelectChange = (institution: Institution): void => {
if (!institution.id) return;
const keys = this.queryParamKeys;
const selectedIds = this.selectedInstitutionIds();
const nextIds = selectedIds.includes(institution.id)
? selectedIds.filter((id) => id !== institution.id)
: [...selectedIds, institution.id];
this.router.navigate([], {
queryParams: { [keys.institutionId]: nextIds, [keys.page]: 0 },
queryParamsHandling: 'merge',
});
};
handleAuthorSelectChange = (author: Author): void => {
if (!author.id) return;
const keys = this.queryParamKeys;
const selectedIds = this.selectedAuthorIds();
const nextIds = selectedIds.includes(author.id)
? selectedIds.filter((id) => id !== author.id)
: [...selectedIds, author.id];
this.router.navigate([], {
queryParams: { [keys.authorId]: nextIds, [keys.page]: 0 },
queryParamsHandling: 'merge',
});
};
resetFilters = (): void => {
const keys = this.queryParamKeys;
this.router.navigate([], {
queryParams: {
[keys.title]: null,
[keys.institutionId]: null,
[keys.authorId]: null,
[keys.years]: null,
[keys.page]: 0,
},
queryParamsHandling: 'merge',
});
};
}