From 8e352dfbb29d2da41f64b664514550d1d797b02c Mon Sep 17 00:00:00 2001 From: genja Date: Sun, 19 Jul 2026 18:41:54 +0200 Subject: [PATCH] added project filters and tables components (DFG and EU) --- .../person-projects.component.html | 82 +-- .../person-projects.component.ts | 175 ++---- .../dfg-project-table.component.html | 160 +++++ .../dfg-project-table.component.scss | 594 ++++++++++++++++++ .../dfg-project-table.component.ts | 285 +++++++++ .../eu-project-table.component.html | 33 + .../eu-project-table.component.scss | 0 .../eu-project-table.component.ts | 78 +++ .../project-filters.component.html | 36 ++ .../project-filters.component.scss | 13 + .../project-filters.component.ts | 182 ++++++ 11 files changed, 1436 insertions(+), 202 deletions(-) create mode 100644 webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html create mode 100644 webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.scss create mode 100644 webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts create mode 100644 webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html create mode 100644 webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.scss create mode 100644 webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts create mode 100644 webapp/src/app/shared/ui/project-filters/project-filters.component.html create mode 100644 webapp/src/app/shared/ui/project-filters/project-filters.component.scss create mode 100644 webapp/src/app/shared/ui/project-filters/project-filters.component.ts diff --git a/webapp/src/app/modules/person-projects/person-projects.component.html b/webapp/src/app/modules/person-projects/person-projects.component.html index ed14000b..1499a315 100644 --- a/webapp/src/app/modules/person-projects/person-projects.component.html +++ b/webapp/src/app/modules/person-projects/person-projects.component.html @@ -5,78 +5,26 @@ - - + - + + - + + - - - - - open_in_new - - - - - {{ element.funding_end == '2999' ? 'laufend' : element.funding_end }} - - - -
-
    - @for ( - name of element.names.sort((a, b) => a.localeCompare(b)); - track $index - ) { -
  • - {{ name }} -
  • - } -
-
-
- - - {{ element.startDate | date: 'dd.MM.yyyy' }} - - - - {{ element.endDate | date: 'dd.MM.yyyy' }} - - - - {{ element.ecMaxContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }} - - - - - open_in_new - - diff --git a/webapp/src/app/modules/person-projects/person-projects.component.ts b/webapp/src/app/modules/person-projects/person-projects.component.ts index 563c00ce..640293a8 100644 --- a/webapp/src/app/modules/person-projects/person-projects.component.ts +++ b/webapp/src/app/modules/person-projects/person-projects.component.ts @@ -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(); - dfgProjectColumns: GenericColumn[] = []; - dfgProjectData: DfgProjectSummary[] = []; - - dfgProjectFundingEndTmp = viewChild.required>( - 'dfgProjectFundingEndTmp', - ); - dfgProjectActionsTmp = viewChild.required>( - 'dfgProjectActionsTmp', - ); - dfgProjectDetailRowTmp = viewChild.required>( - 'dfgProjectDetailRowTmp', - ); - personCordisEuProjectPage = input.required(); - personCordisEuProjectColumns: GenericColumn[] = []; - personCordisEuProjectData: CordisEuProject[] = []; - euProjectsFundingStartTmp = viewChild.required>( - 'euProjectsFundingStartTmp', - ); - euProjectsFundingEndTmp = viewChild.required>( - 'euProjectsFundingEndTmp', - ); - euProjectsFundingAmountTmp = viewChild.required>( - 'euProjectsFundingAmountTmp', - ); - euProjectsActionsTmp = viewChild.required>( - 'euProjectsActionsTmp', - ); + selectedDfgInstitutions = input.required(); + selectedDfgAuthors = input.required(); + selectedEuInstitutions = input.required(); + selectedEuAuthors = input.required(); - 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(), - }, - ]; } } diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html new file mode 100644 index 00000000..c802f4b3 --- /dev/null +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html @@ -0,0 +1,160 @@ + + + + + + {{ element.funding_end == '2999' ? 'laufend' : element.funding_end }} + + + + + open_in_new + + + + + @let projectAuthors = getProjectAuthors(project); + @let isProjectAuthorsExpanded = isProjectPersonsExpanded(project); + @let visibleAuthors = + isProjectAuthorsExpanded ? projectAuthors : projectAuthors.slice(0, 3); +
+ @for (author of visibleAuthors; track author.person_id) { + + } @empty { + - + } + @if (projectAuthors.length > 3) { + + } +
+
+ + + @let institutions = getProjectInstitutions(project); + +
+ @for ( + institution of isProjectInstitutionsExpanded(project) + ? institutions + : institutions.slice(0, 3); + track getProjectInstitutionId(institution) + ) { + + } @empty { + - + } + @if (institutions.length > 3) { + + } +
+
+ diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.scss b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.scss new file mode 100644 index 00000000..fe4f1b94 --- /dev/null +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.scss @@ -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; +} diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts new file mode 100644 index 00000000..4685c3e2 --- /dev/null +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts @@ -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(); + authorFilterEnabled = input(false); + institutionFilterEnabled = input(false); + topicFilterEnabled = input(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[] = []; + titleTmp = viewChild.required>('titleTmp'); + yearTmp = viewChild.required>('yearTmp'); + authorsTmp = viewChild.required>('authorsTmp'); + institutionsTmp = viewChild.required>('institutionsTmp'); + fundingEndTmp = viewChild.required>('fundingEndTmp'); + actionsTmp = viewChild.required>('actionsTmp'); + detailRowTmp = viewChild.required>('detailRowTmp'); + topicsTmp = viewChild.required>('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(); + + 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}`; + } +} diff --git a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html new file mode 100644 index 00000000..46ba403b --- /dev/null +++ b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html @@ -0,0 +1,33 @@ + + + + + + {{ element.startDate | date: 'dd.MM.yyyy' }} + + + + {{ element.endDate | date: 'dd.MM.yyyy' }} + + + + {{ element.ecMaxContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de' }} + + + + + open_in_new + + diff --git a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.scss b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts new file mode 100644 index 00000000..abd257a5 --- /dev/null +++ b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts @@ -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(); + queryParamKeys = projectQueryParamKeys; + + elements = computed(() => this.page().elements ?? []); + total = computed(() => this.page().total ?? 0); + + columns: GenericColumn[] = []; + + fundingStartTmp = viewChild.required>('fundingStartTmp'); + fundingEndTmp = viewChild.required>('fundingEndTmp'); + fundingAmountTmp = viewChild.required>('fundingAmountTmp'); + actionsTmp = viewChild.required>('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(), + }, + ]; + } +} diff --git a/webapp/src/app/shared/ui/project-filters/project-filters.component.html b/webapp/src/app/shared/ui/project-filters/project-filters.component.html new file mode 100644 index 00000000..e8698b50 --- /dev/null +++ b/webapp/src/app/shared/ui/project-filters/project-filters.component.html @@ -0,0 +1,36 @@ +
+ @if (showTitleFilter()) { + + } +
+ @if (showInstitutionFilter()) { + + } + @if (showYearFilter()) { + + } + @if (showAuthorFilter()) { + + } + +
+ +
diff --git a/webapp/src/app/shared/ui/project-filters/project-filters.component.scss b/webapp/src/app/shared/ui/project-filters/project-filters.component.scss new file mode 100644 index 00000000..94044ea1 --- /dev/null +++ b/webapp/src/app/shared/ui/project-filters/project-filters.component.scss @@ -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; +} diff --git a/webapp/src/app/shared/ui/project-filters/project-filters.component.ts b/webapp/src/app/shared/ui/project-filters/project-filters.component.ts new file mode 100644 index 00000000..a79fb0a6 --- /dev/null +++ b/webapp/src/app/shared/ui/project-filters/project-filters.component.ts @@ -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([]); + selectedTopics = input([]); + selectedAuthors = input([]); + + showTitleFilter = input(true); + showInstitutionFilter = input(true); + showAuthorFilter = input(true); + showYearFilter = input(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(() => { + 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', + }); + }; +}