added filters to projects table and project filters components
This commit is contained in:
@@ -11,7 +11,11 @@
|
||||
[pageSizeOptions]="[10]" />
|
||||
|
||||
<ng-template #fundingEndTmp let-element>
|
||||
{{ element.funding_end == '2999' ? 'laufend' : element.funding_end }}
|
||||
{{
|
||||
element.funding_end == '2999' || element.funding_end == null
|
||||
? 'laufend'
|
||||
: element.funding_end
|
||||
}}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actionsTmp let-element>
|
||||
@@ -104,59 +108,37 @@
|
||||
}
|
||||
</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>
|
||||
|
||||
<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 (publicationInstitutions.length > 3) {
|
||||
@if (projectTopics.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="institutionsExpanded"
|
||||
(click)="toggleWorkInstitutionsExpansion(work)">
|
||||
{{
|
||||
institutionsExpanded
|
||||
? 'weniger'
|
||||
: '+' + (publicationInstitutions.length - 3)
|
||||
}}
|
||||
[attr.aria-expanded]="isTopicsExpanded"
|
||||
(click)="toggleProjectTopicsExpansion(project)">
|
||||
{{ isTopicsExpanded ? 'weniger' : '+' + (projectTopics.length - 3) }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</ng-template> -->
|
||||
</ng-template>
|
||||
|
||||
@@ -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<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');
|
||||
fundingStartTmp = viewChild.required<TemplateRef<any>>('fundingStartTmp');
|
||||
fundingEndTmp = viewChild.required<TemplateRef<any>>('fundingEndTmp');
|
||||
actionsTmp = viewChild.required<TemplateRef<any>>('actionsTmp');
|
||||
detailRowTmp = viewChild.required<TemplateRef<any>>('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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,18 @@
|
||||
[debounceTime]="300" />
|
||||
}
|
||||
<div class="select-area">
|
||||
@if (showFundingStartFilter()) {
|
||||
<app-searchable-year-select
|
||||
[label]="fundingStartYearLabel()"
|
||||
[selectedYears]="selectedFundingStartYears()"
|
||||
(handleYearSelectChange)="handleFundingStartSelectChange($event)" />
|
||||
}
|
||||
@if (showFundingEndFilter()) {
|
||||
<app-searchable-year-select
|
||||
[label]="fundingEndYearLabel()"
|
||||
[selectedYears]="selectedFundingEndYears()"
|
||||
(handleYearSelectChange)="handleFundingEndSelectChange($event)" />
|
||||
}
|
||||
@if (showInstitutionFilter()) {
|
||||
<app-searchable-dfg-institution-select
|
||||
[label]="institutionLabel()"
|
||||
@@ -15,18 +27,18 @@
|
||||
handleInstitutionSelectChange($event)
|
||||
" />
|
||||
}
|
||||
@if (showYearFilter()) {
|
||||
<app-searchable-year-select
|
||||
[label]="yearLabel()"
|
||||
[selectedYears]="selectedYears()"
|
||||
(handleYearSelectChange)="handleYearSelectChange($event)" />
|
||||
}
|
||||
@if (showAuthorFilter()) {
|
||||
<app-searchable-dfg-author-select
|
||||
[label]="authorLabel()"
|
||||
[selectedAuthors]="selectedAuthors()"
|
||||
(handleAuthorSelectChange)="handleAuthorSelectChange($event)" />
|
||||
}
|
||||
@if (showTopicFilter()) {
|
||||
<app-searchable-topic-select
|
||||
[label]="topicLabel()"
|
||||
[selectedTopics]="selectedTopics()"
|
||||
(handleTopicSelectChange)="handleTopicSelectChange($event)" />
|
||||
}
|
||||
<button mat-stroked-button color="primary" (click)="resetFilters()">
|
||||
<mat-icon>filter_alt_off</mat-icon>
|
||||
Filter zurücksetzen
|
||||
|
||||
+1
-4
@@ -34,11 +34,8 @@ export class SearchableDfgAuthorSelectComponent {
|
||||
};
|
||||
|
||||
getAuthorDescription = (author: DfgPersonSummary): string => {
|
||||
const orcidId = author.orcid_id ?? 'Unbekannt';
|
||||
const roleLabel =
|
||||
(author.role_label_de || author.role_label_en) ?? 'Unbekannt';
|
||||
const rootInstitution = author.institution?.root_name_de ?? 'Unbekannt';
|
||||
const institution = author.institution?.institute_name_de ?? 'Unbekannt';
|
||||
return `ORCID: ${orcidId} - Rolle: ${roleLabel} - Wurzelinstitution: ${rootInstitution} - Institution: ${institution}`;
|
||||
return `${rootInstitution} - ${institution}`;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user