From 5b3176dc6e7f9ab6d6ae6e45031e63be8ce4dc71 Mon Sep 17 00:00:00 2001 From: genja Date: Mon, 20 Jul 2026 23:25:31 +0200 Subject: [PATCH] added filters to projects table and project filters components --- .../dfg-project-table.component.html | 78 +++++++---------- .../dfg-project-table.component.ts | 86 ++++++++++++++++++- .../project-filters.component.html | 24 ++++-- .../searchable-dfg-author-select.component.ts | 5 +- 4 files changed, 131 insertions(+), 62 deletions(-) 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 index 2d3860e5..bfefb7ca 100644 --- 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 @@ -11,7 +11,11 @@ [pageSizeOptions]="[10]" /> - {{ element.funding_end == '2999' ? 'laufend' : element.funding_end }} + {{ + element.funding_end == '2999' || element.funding_end == null + ? 'laufend' + : element.funding_end + }} @@ -104,59 +108,37 @@ } - + 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 index 050730c8..5d08d368 100644 --- 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 @@ -7,7 +7,8 @@ import { viewChild, inject, } from '@angular/core'; -import { DfgProjectPage, DfgProjectSummary } from '../../../api'; +import { DfgProjectPage, DfgProjectSummary, Topic } from '../../../api'; +import { TopicChipComponent } from '../topic-chip/topic-chip.component'; import { DataTableComponent, GenericColumn, @@ -21,6 +22,7 @@ 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-dfg-project-table', imports: [ @@ -30,6 +32,7 @@ import { MatTooltip } from '@angular/material/tooltip'; MatButtonModule, QueryParamPaginatorComponent, MatTooltip, + TopicChipComponent, ], templateUrl: './dfg-project-table.component.html', styleUrl: './dfg-project-table.component.scss', @@ -48,14 +51,15 @@ export class DfgProjectTableComponent implements OnInit { 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'); + fundingStartTmp = viewChild.required>('fundingStartTmp'); fundingEndTmp = viewChild.required>('fundingEndTmp'); actionsTmp = viewChild.required>('actionsTmp'); detailRowTmp = viewChild.required>('detailRowTmp'); @@ -63,9 +67,18 @@ export class DfgProjectTableComponent implements OnInit { expandedProjectAuthorsId: string[] = []; expandedProjectInstitutionsId: string[] = []; + expandedProjectTopicsId: string[] = []; - selectedYearsQueryParams = computed(() => { - return this.queryParamMap().getAll(this.queryParamKeys.years).map(Number); + 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(() => { @@ -116,6 +129,12 @@ export class DfgProjectTableComponent implements OnInit { type: 'accessor', accessorKey: 'professional_classification', }, + { + id: 'topics', + header: 'Themen', + type: 'display', + cellTemplate: this.topicsTmp(), + }, { id: 'actions', header: '', @@ -282,4 +301,63 @@ export class DfgProjectTableComponent implements OnInit { 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); + } } 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 index bc7d53da..c04b5464 100644 --- a/webapp/src/app/shared/ui/project-filters/project-filters.component.html +++ b/webapp/src/app/shared/ui/project-filters/project-filters.component.html @@ -7,6 +7,18 @@ [debounceTime]="300" /> }
+ @if (showFundingStartFilter()) { + + } + @if (showFundingEndFilter()) { + + } @if (showInstitutionFilter()) { } - @if (showYearFilter()) { - - } @if (showAuthorFilter()) { } + @if (showTopicFilter()) { + + }