filters fixed
This commit is contained in:
@@ -11,11 +11,17 @@
|
||||
<mat-tab label="DFG">
|
||||
<app-project-filters
|
||||
[selectedInstitutionsPage]="selectedDfgInstitutionsPage()"
|
||||
[selectedAuthorsPage]="selectedDfgAuthorsPage()"
|
||||
[selectedTopicsPage]="selectedTopicsPage()"
|
||||
[showFundingStartFilter]="true"
|
||||
[showTopicFilter]="true"
|
||||
[showFundingEndFilter]="true"
|
||||
[showAuthorFilter]="true"
|
||||
[showInstitutionFilter]="true" />
|
||||
<app-dfg-project-table
|
||||
[page]="dfgProjectPage()"
|
||||
[authorFilterEnabled]="true"
|
||||
[topicFilterEnabled]="true"
|
||||
[institutionFilterEnabled]="true" />
|
||||
</mat-tab>
|
||||
<mat-tab label="EU">
|
||||
|
||||
@@ -5,10 +5,10 @@ import { DfgInstitutionSummaryPage } from '../../api/model/dfgInstitutionSummary
|
||||
import {
|
||||
CordisEuProjectPage,
|
||||
DfgProjectPage,
|
||||
Author,
|
||||
Institution,
|
||||
AuthorPage,
|
||||
InstitutionPageV2,
|
||||
TopicPageV2,
|
||||
DfgPersonSummaryPage,
|
||||
} from '../../api';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
@@ -37,9 +37,10 @@ export class PersonProjectsComponent {
|
||||
personCordisEuProjectPage = input.required<CordisEuProjectPage>();
|
||||
|
||||
selectedDfgInstitutionsPage = input.required<DfgInstitutionSummaryPage>();
|
||||
selectedDfgAuthorsPage = input.required<AuthorPage>();
|
||||
selectedDfgAuthorsPage = input.required<DfgPersonSummaryPage>();
|
||||
selectedEuInstitutionsPage = input.required<InstitutionPageV2>();
|
||||
selectedEuAuthorsPage = input.required<AuthorPage>();
|
||||
selectedTopicsPage = input.required<TopicPageV2>();
|
||||
|
||||
readonly dfgQueryParamKeys = projectQueryParamKeys;
|
||||
readonly euQueryParamKeys = euProjectQueryParamKeys;
|
||||
|
||||
@@ -6,12 +6,10 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
import { DfgInstitutionSummaryPage } from '../../../api/model/dfgInstitutionSummaryPage';
|
||||
import { DfgInstitutionSummary } from '../../../api/model/dfgInstitutionSummary';
|
||||
import {
|
||||
Author,
|
||||
AuthorPage,
|
||||
DfgPersonSummary,
|
||||
DfgPersonSummaryPage,
|
||||
Institution,
|
||||
InstitutionPageV2,
|
||||
Topic,
|
||||
TopicPageV2,
|
||||
} from '../../../api';
|
||||
import { QueryParamInputComponent } from '../query-param-input/query-param-input.component';
|
||||
import { SearchableDfgInstitutionSelectComponent } from '../searchable-dfg-institution-select/searchable-dfg-institution-select.component';
|
||||
@@ -24,6 +22,7 @@ import {
|
||||
} from '../selected-filters/selected-filters.component';
|
||||
import { map } from 'rxjs/internal/operators/map';
|
||||
import { SearchableDfgAuthorSelectComponent } from '../searchable-dfg-author-select/searchable-dfg-author-select.component';
|
||||
import { SearchableTopicSelectComponent } from '../searchable-topic-select/searchable-topic-select.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project-filters',
|
||||
@@ -35,6 +34,7 @@ import { SearchableDfgAuthorSelectComponent } from '../searchable-dfg-author-sel
|
||||
SearchableDfgAuthorSelectComponent,
|
||||
SearchableYearSelectComponent,
|
||||
SelectedFiltersComponent,
|
||||
SearchableTopicSelectComponent,
|
||||
],
|
||||
templateUrl: './project-filters.component.html',
|
||||
styleUrl: './project-filters.component.scss',
|
||||
@@ -45,8 +45,6 @@ export class ProjectFilterComponent {
|
||||
// Each tab (DFG / EU) passes its OWN key set so they never collide.
|
||||
queryParamKeys = projectQueryParamKeys;
|
||||
|
||||
selectedTopics = input<string[]>([]);
|
||||
|
||||
// selectedAuthorsPage = input<AuthorPage>();
|
||||
// selectedAuthors = computed<Author[]>(
|
||||
// () => this.selectedAuthorsPage()?.elements || [],
|
||||
@@ -59,12 +57,17 @@ export class ProjectFilterComponent {
|
||||
selectedInstitutions = computed<DfgInstitutionSummary[]>(
|
||||
() => this.selectedInstitutionsPage()?.elements || [],
|
||||
);
|
||||
selectedTopicsPage = input<TopicPageV2>();
|
||||
selectedTopics = computed<Topic[]>(
|
||||
() => this.selectedTopicsPage()?.elements || [],
|
||||
);
|
||||
|
||||
showTitleFilter = input<boolean>(true);
|
||||
showInstitutionFilter = input<boolean>(true);
|
||||
showAuthorFilter = input<boolean>(true);
|
||||
showYearFilter = input<boolean>(true);
|
||||
|
||||
showFundingStartFilter = input<boolean>(true);
|
||||
showFundingEndFilter = input<boolean>(false);
|
||||
showTopicFilter = input<boolean>(true);
|
||||
queryParamMap = toSignal(this.router.routerState.root.queryParamMap, {
|
||||
initialValue: this.router.routerState.snapshot.root.queryParamMap,
|
||||
});
|
||||
@@ -77,17 +80,31 @@ export class ProjectFilterComponent {
|
||||
this.queryParamMap().getAll(this.queryParamKeys.authorId),
|
||||
);
|
||||
|
||||
selectedYears = computed(() =>
|
||||
this.queryParamMap().getAll(this.queryParamKeys.years).map(Number),
|
||||
selectedFundingStartYears = computed(() =>
|
||||
this.queryParamMap().getAll(this.queryParamKeys.funding_start).map(Number),
|
||||
);
|
||||
yearLabel = computed(() => {
|
||||
const selectedYears = this.selectedYears();
|
||||
selectedFundingEndYears = computed(() =>
|
||||
this.queryParamMap().getAll(this.queryParamKeys.funding_end).map(Number),
|
||||
);
|
||||
fundingStartYearLabel = computed(() => {
|
||||
const selectedYears = this.selectedFundingStartYears();
|
||||
if (selectedYears.length === 0) {
|
||||
return 'Jahr';
|
||||
return 'Förderbeginn';
|
||||
} else if (selectedYears.length === 1) {
|
||||
return selectedYears[0].toString();
|
||||
} else {
|
||||
return `${selectedYears.length} Jahre`;
|
||||
return `${selectedYears.join(', ')} Jahre`;
|
||||
}
|
||||
});
|
||||
|
||||
fundingEndYearLabel = computed(() => {
|
||||
const selectedYears = this.selectedFundingEndYears();
|
||||
if (selectedYears.length === 0) {
|
||||
return 'Förderende';
|
||||
} else if (selectedYears.length === 1) {
|
||||
return selectedYears[0].toString();
|
||||
} else {
|
||||
return `${selectedYears.join(', ')} Jahre`;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -115,9 +132,16 @@ export class ProjectFilterComponent {
|
||||
return [
|
||||
{ id: 'search', queryParamKey: keys.title, icon: 'search' },
|
||||
{
|
||||
id: 'years',
|
||||
queryParamKey: projectQueryParamKeys.years,
|
||||
id: 'fundingStart',
|
||||
queryParamKey: projectQueryParamKeys.funding_start,
|
||||
icon: 'calendar_today',
|
||||
valueFormatter: (value: string) => `Förderbeginn ${value}`,
|
||||
},
|
||||
{
|
||||
id: 'fundingEnd',
|
||||
queryParamKey: projectQueryParamKeys.funding_end,
|
||||
icon: 'event_busy',
|
||||
valueFormatter: (value: string) => `Förderende ${value}`,
|
||||
},
|
||||
{
|
||||
id: 'institutions',
|
||||
@@ -135,24 +159,57 @@ export class ProjectFilterComponent {
|
||||
this.selectedAuthors().find((a) => String(a.person_id) === value)
|
||||
?.full_name ?? value,
|
||||
},
|
||||
{
|
||||
id: 'topics',
|
||||
queryParamKey: keys.topicId,
|
||||
icon: 'topic',
|
||||
valueFormatter: (value: string) => {
|
||||
const topic = this.selectedTopics().find((t) => t.id === value);
|
||||
return topic ? topic.display_name : value;
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
handleYearSelectChange = (selectedYear: number): void => {
|
||||
if (this.selectedYears().includes(selectedYear)) {
|
||||
handleFundingStartSelectChange = (selectedYear: number): void => {
|
||||
if (this.selectedFundingStartYears().includes(selectedYear)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[projectQueryParamKeys.years]: this.selectedYears().filter(
|
||||
(year) => year !== selectedYear,
|
||||
),
|
||||
[projectQueryParamKeys.funding_start]:
|
||||
this.selectedFundingStartYears().filter(
|
||||
(year) => year !== selectedYear,
|
||||
),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[projectQueryParamKeys.years]: [
|
||||
...this.selectedYears(),
|
||||
[projectQueryParamKeys.funding_start]: [
|
||||
...this.selectedFundingStartYears(),
|
||||
selectedYear,
|
||||
],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
handleFundingEndSelectChange = (selectedYear: number): void => {
|
||||
if (this.selectedFundingEndYears().includes(selectedYear)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[projectQueryParamKeys.funding_end]:
|
||||
this.selectedFundingEndYears().filter(
|
||||
(year) => year !== selectedYear,
|
||||
),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[projectQueryParamKeys.funding_end]: [
|
||||
...this.selectedFundingEndYears(),
|
||||
selectedYear,
|
||||
],
|
||||
},
|
||||
@@ -190,6 +247,41 @@ export class ProjectFilterComponent {
|
||||
});
|
||||
};
|
||||
|
||||
topicLabel = computed(() => {
|
||||
const selectedTopicIds = this.selectedTopics().map((t) => t.id);
|
||||
if (selectedTopicIds.length === 0) {
|
||||
return 'Thema';
|
||||
} else if (selectedTopicIds.length === 1) {
|
||||
const topic = this.selectedTopics()[0];
|
||||
return topic.display_name || 'Thema';
|
||||
} else {
|
||||
return `${selectedTopicIds.length} Themen`;
|
||||
}
|
||||
});
|
||||
|
||||
handleTopicSelectChange = (selectedTopic: Topic): void => {
|
||||
if (this.selectedTopics().some((t) => t.id === selectedTopic.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.topicId]: this.selectedTopics()
|
||||
.filter((t) => t.id !== selectedTopic.id)
|
||||
.map((t) => t.id),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.topicId]: [
|
||||
...this.selectedTopics().map((t) => t.id!),
|
||||
selectedTopic.id,
|
||||
],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
resetFilters = (): void => {
|
||||
const keys = this.queryParamKeys;
|
||||
this.router.navigate([], {
|
||||
@@ -197,7 +289,8 @@ export class ProjectFilterComponent {
|
||||
[keys.title]: null,
|
||||
[keys.institutionId]: null,
|
||||
[keys.authorId]: null,
|
||||
[keys.years]: null,
|
||||
[keys.funding_start]: null,
|
||||
[keys.funding_end]: null,
|
||||
[keys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
|
||||
Reference in New Issue
Block a user