- @for (topic of visibleTopics; track topic.id ?? $index) {
+ @for (topic of visibleTopics; track $index) {
{
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();
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))
);
}