Move filtered subject to top of subject list
This commit is contained in:
@@ -82,7 +82,7 @@
|
||||
</ng-template>
|
||||
|
||||
<ng-template #topicsTmp let-project>
|
||||
@let projectTopics = project.oa_topics ?? [];
|
||||
@let projectTopics = getProjectTopics(project);
|
||||
@let isTopicsExpanded = isProjectTopicsExpanded(project);
|
||||
@let visibleTopics =
|
||||
isTopicsExpanded ? projectTopics : projectTopics.slice(0, 3);
|
||||
|
||||
@@ -102,6 +102,9 @@ export class BundProjectTableComponent implements OnInit {
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.topicId);
|
||||
});
|
||||
selectedTopicMatchesQueryParams = computed(() => {
|
||||
return this.queryParamMap().get('topics')?.split(',') || [];
|
||||
});
|
||||
selectedFundingTypesQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.funding_type);
|
||||
});
|
||||
@@ -225,7 +228,19 @@ export class BundProjectTableComponent implements OnInit {
|
||||
getProjectInstitutions(project: BundProjectSummary): any[] {
|
||||
return project.institution ? [project.institution] : [];
|
||||
}
|
||||
|
||||
getProjectTopics(project: BundProjectSummary): Topic[] {
|
||||
const topics = (project as any).oa_topics ?? [];
|
||||
const activeTopics = topics.filter((topic: Topic) =>
|
||||
this.isTopicActive(topic),
|
||||
);
|
||||
return topics.sort((a: Topic, b: Topic) =>
|
||||
activeTopics.includes(a) && !activeTopics.includes(b)
|
||||
? -1
|
||||
: !activeTopics.includes(a) && activeTopics.includes(b)
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
isInstitutionActive(
|
||||
institution_name: string | number | null | undefined,
|
||||
): boolean {
|
||||
@@ -293,8 +308,9 @@ export class BundProjectTableComponent implements OnInit {
|
||||
isTopicActive(topic: Topic): boolean {
|
||||
return (
|
||||
!!topic.id &&
|
||||
this.authorFilterEnabled() &&
|
||||
this.selectedTopicIdsQueryParams().includes(topic.id)
|
||||
this.topicFilterEnabled() &&
|
||||
(this.selectedTopicIdsQueryParams().includes(topic.id) ||
|
||||
this.selectedTopicMatchesQueryParams().includes(topic.id))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
</ng-template>
|
||||
|
||||
<ng-template #topicsTmp let-project>
|
||||
@let projectTopics = project.topics ?? [];
|
||||
@let projectTopics = getProjectTopics(project);
|
||||
@let isTopicsExpanded = isProjectTopicsExpanded(project);
|
||||
@let visibleTopics =
|
||||
isTopicsExpanded ? projectTopics : projectTopics.slice(0, 3);
|
||||
|
||||
@@ -96,6 +96,9 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.topicId);
|
||||
});
|
||||
selectedTopicMatchesQueryParams = computed(() => {
|
||||
return this.queryParamMap().get('topics')?.split(',') || [];
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
this.columns = [
|
||||
@@ -159,7 +162,15 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
getProjectAuthors(project: DfgProjectSummary): DfgPersonSummary[] {
|
||||
return project.persons?.filter((a): a is DfgPersonSummary => !!a) || [];
|
||||
const selectedAuthorIds = this.selectedAuthorIdsQueryParams();
|
||||
const authors = project.persons || [];
|
||||
return authors.sort((a, b) => {
|
||||
const aActive = selectedAuthorIds.includes(String(a.person_id));
|
||||
const bActive = selectedAuthorIds.includes(String(b.person_id));
|
||||
if (aActive && !bActive) return -1;
|
||||
if (!aActive && bActive) return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
toggleProjectAuthorsExpansion(project: DfgProjectSummary): void {
|
||||
@@ -230,7 +241,7 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
|
||||
getProjectInstitutions(project: DfgProjectSummary): any[] {
|
||||
const institutions = new Map<string, any>();
|
||||
|
||||
const selectedInstitutionIds = this.selectedInstitutionIdsQueryParams();
|
||||
for (const institution of project.institutions ?? []) {
|
||||
const id = this.getProjectInstitutionId(institution);
|
||||
if (!id) continue;
|
||||
@@ -239,9 +250,11 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
}
|
||||
|
||||
return Array.from(institutions.values()).sort((a, b) =>
|
||||
this.getProjectInstitutionName(a).localeCompare(
|
||||
this.getProjectInstitutionName(b),
|
||||
),
|
||||
selectedInstitutionIds.includes(this.getProjectInstitutionId(a) ?? '')
|
||||
? -1
|
||||
: selectedInstitutionIds.includes(this.getProjectInstitutionId(b) ?? '')
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -320,8 +333,9 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
isTopicActive(topic: Topic): boolean {
|
||||
return (
|
||||
!!topic.id &&
|
||||
this.authorFilterEnabled() &&
|
||||
this.selectedTopicIdsQueryParams().includes(topic.id)
|
||||
this.topicFilterEnabled() &&
|
||||
(this.selectedTopicIdsQueryParams().includes(topic.id) ||
|
||||
this.selectedTopicMatchesQueryParams().includes(topic.id))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -364,6 +378,19 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
|
||||
return this.expandedProjectTopicsId.includes(project.id);
|
||||
}
|
||||
getProjectTopics(project: DfgProjectSummary): Topic[] {
|
||||
const topics = (project as any).topics ?? [];
|
||||
const activeTopics = topics.filter((topic: Topic) =>
|
||||
this.isTopicActive(topic),
|
||||
);
|
||||
return topics.sort((a: Topic, b: Topic) =>
|
||||
activeTopics.includes(a) && !activeTopics.includes(b)
|
||||
? -1
|
||||
: !activeTopics.includes(a) && activeTopics.includes(b)
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
expandedProjectClassificationsId: string[] = [];
|
||||
//classifications
|
||||
getProjectClassifications(project: DfgProjectSummary): any[] {
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
@let visibleTopics = isExpanded ? projectTopics : projectTopics.slice(0, 3);
|
||||
|
||||
<div class="topic-chips" aria-label="Themen" style="padding: 0.5rem 0">
|
||||
@for (topic of visibleTopics; track topic.id ?? $index) {
|
||||
@for (topic of visibleTopics; track $index) {
|
||||
<app-topic-chip-2
|
||||
size="mini"
|
||||
[topic]="topic"
|
||||
|
||||
@@ -88,6 +88,9 @@ export class EuProjectTableComponent {
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.topicId);
|
||||
});
|
||||
selectedTopicMatchesQueryParams = computed(() => {
|
||||
return this.queryParamMap().get('topics')?.split(',') || [];
|
||||
});
|
||||
selectedTypesQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.projectType);
|
||||
});
|
||||
@@ -238,7 +241,15 @@ export class EuProjectTableComponent {
|
||||
// -------------------------
|
||||
|
||||
getProjectAuthors(project: EuCordisProjectSummary): Author[] {
|
||||
return project.authors?.elements ?? [];
|
||||
const selectedAuthorIds = this.selectedAuthorIdsQueryParams();
|
||||
const authors = project.authors?.elements ?? [];
|
||||
return authors.sort((a, b) => {
|
||||
const aActive = selectedAuthorIds.includes(String(a.id));
|
||||
const bActive = selectedAuthorIds.includes(String(b.id));
|
||||
if (aActive && !bActive) return -1;
|
||||
if (!aActive && bActive) return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
getAuthorTrackId(author: any, index: number): string {
|
||||
return String(
|
||||
@@ -334,7 +345,7 @@ export class EuProjectTableComponent {
|
||||
if (!Array.isArray(organizations)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const selectedOrganizationIds = this.selectedOrganizationIdsQueryParams();
|
||||
const byId = new Map<string, EuCordisOrganizationSummary>();
|
||||
|
||||
for (const organization of organizations) {
|
||||
@@ -345,7 +356,11 @@ export class EuProjectTableComponent {
|
||||
}
|
||||
|
||||
return Array.from(byId.values()).sort((a, b) =>
|
||||
this.getOrganizationName(a).localeCompare(this.getOrganizationName(b)),
|
||||
selectedOrganizationIds.includes(this.getOrganizationId(a) ?? '')
|
||||
? -1
|
||||
: selectedOrganizationIds.includes(this.getOrganizationId(b) ?? '')
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -427,7 +442,16 @@ export class EuProjectTableComponent {
|
||||
|
||||
getProjectTopics(project: EuCordisProjectSummary): Topic[] {
|
||||
const topics = (project as any).topics ?? [];
|
||||
return Array.isArray(topics) ? topics : [];
|
||||
const activeTopics = topics.filter((topic: Topic) =>
|
||||
this.isTopicActive(topic),
|
||||
);
|
||||
return topics.sort((a: Topic, b: Topic) =>
|
||||
activeTopics.includes(a) && !activeTopics.includes(b)
|
||||
? -1
|
||||
: !activeTopics.includes(a) && activeTopics.includes(b)
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
|
||||
getWorkTopicColor(topic: Topic): string {
|
||||
@@ -445,7 +469,8 @@ export class EuProjectTableComponent {
|
||||
return (
|
||||
!!topic.id &&
|
||||
this.topicFilterEnabled() &&
|
||||
this.selectedTopicIdsQueryParams().includes(topic.id)
|
||||
(this.selectedTopicIdsQueryParams().includes(topic.id) ||
|
||||
this.selectedTopicMatchesQueryParams().includes(topic.id))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user