added expanded row for EU projects table

This commit is contained in:
2026-08-16 20:47:23 +02:00
parent a0fdc8799b
commit 6e0acb9cde
3 changed files with 208 additions and 2 deletions
@@ -1,6 +1,7 @@
<app-data-table
[columns]="columns()"
[data]="projects()"
[detailTemplate]="expandedProject"
[queryParamSortKey]="queryParamKeys.sortBy"
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
@@ -146,3 +147,73 @@
<mat-icon>open_in_new</mat-icon>
</a>
</ng-template>
<ng-template #expandedProject let-project>
<section class="project-panel" aria-label="Weitere Projektdetails">
<div class="project-panel__content">
@if (project.highlight?.title.length > 0) {
<article class="panel-field panel-field--full">
<h4 class="panel-field__label">Titel</h4>
<app-highlighted-text
class="panel-field__text"
[content]="project.title"
[highlights]="
getHighlightTerms(extractHighlightTerms(project.highlight?.title))
" />
</article>
}
@if (project.highlight?.objective.length > 0) {
<article class="panel-field panel-field--full">
<h4 class="panel-field__label">Zusammenfassung</h4>
<app-highlighted-text
class="panel-field__text"
[content]="project.objective"
[highlights]="
getHighlightTerms(
extractHighlightTerms(project.highlight?.objective)
)
" />
</article>
}
@if (project.highlight?.acronym.length > 0) {
<article class="panel-field panel-field--full">
<h4 class="panel-field__label">Akronym</h4>
<app-highlighted-text
class="panel-field__text"
[content]="project.acronym"
[highlights]="
getHighlightTerms(
extractHighlightTerms(project.highlight?.acronym)
)
" />
</article>
}
@if (project.highlight?.cordis_topic_text.length > 0) {
<article class="panel-field panel-field--full">
<h4 class="panel-field__label">Cordis-Thema</h4>
<app-highlighted-text
class="panel-field__text"
[content]="project.cordis_topic_text"
[highlights]="
getHighlightTerms(
extractHighlightTerms(project.highlight?.cordis_topic_text)
)
" />
</article>
}
@if (project.highlight?.keywords.length > 0) {
<article class="panel-field panel-field--full">
<h4 class="panel-field__label">Schlüsselwörter</h4>
<app-highlighted-text
class="panel-field__text"
[content]="project.keywords"
[highlights]="
getHighlightTerms(
extractHighlightTerms(project.highlight?.keywords)
)
" />
</article>
}
</div>
</section>
</ng-template>
@@ -142,7 +142,97 @@
.classification-container {
max-width: 200px;
}
// ------------------------
// Expanded project panel
// ------------------------
.project-panel {
width: 100%;
padding: 12px 16px 14px;
color: var(--sg-text);
background: var(--sg-background);
border-top: 1px solid var(--sg-border);
}
.project-panel__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 10px;
}
.project-panel__heading {
display: flex;
align-items: flex-start;
gap: 8px;
> mat-icon {
flex: 0 0 auto;
width: 19px;
height: 19px;
color: var(--sg-primary);
font-size: 19px;
}
h3 {
margin: 0;
font-size: 13px;
font-weight: 700;
line-height: 1.2;
}
p {
margin: 1px 0 0;
color: var(--sg-text-muted);
font-size: 11px;
line-height: 1.3;
}
}
.project-panel__content {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
gap: 10px;
}
.panel-field {
min-width: 0;
&--full {
grid-column: 1 / -1;
}
}
.panel-field__label {
color: var(--sg-text-muted);
font-size: 10px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.02em;
}
.panel-field__text {
margin: 0;
font-size: 12px;
line-height: 1.5;
overflow-wrap: anywhere;
}
.project-panel__empty {
display: flex;
align-items: center;
gap: 6px;
grid-column: 1 / -1;
color: var(--sg-text-muted);
font-size: 12px;
mat-icon {
width: 16px;
height: 16px;
font-size: 16px;
}
}
// ------------------------
// Data table overrides (applied via ::ng-deep)
// ------------------------
@@ -33,6 +33,12 @@ import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
import { ChipComponent } from '../chip/chip.component';
import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.component';
import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component';
import {
HighlightedTextComponent,
HighlightTerm,
} from '../highlighted-text/highlighted-text.component';
import { MatDividerModule } from '@angular/material/divider';
import { SearchResultsStateService } from '../../../modules/keywords-search/search-results/search-results-state.service';
@Component({
selector: 'app-eu-project-table',
imports: [
@@ -49,6 +55,8 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl
ChipComponent,
AppAuthorChipComponent,
SkTextDirective,
MatDividerModule,
HighlightedTextComponent,
],
templateUrl: './eu-project-table.component.html',
styleUrl: './eu-project-table.component.scss',
@@ -56,7 +64,10 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl
export class EuProjectTableComponent {
private readonly activatedRoute = inject(ActivatedRoute);
private readonly router = inject(Router);
private readonly searchResultsStateService = inject(
SearchResultsStateService,
{ optional: true },
);
queryParamKeys = euProjectQueryParamKeys;
page = input<EuCordisProjectSearchPage | undefined>();
@@ -94,7 +105,12 @@ export class EuProjectTableComponent {
selectedTypesQueryParams = computed(() => {
return this.queryParamMap().getAll(this.queryParamKeys.projectType);
});
keywordTopicMap = computed(() => {
return (
this.searchResultsStateService?.keywordTopicMap() ??
new Map<string, Topic>()
);
});
projectTypeTmp = viewChild.required<TemplateRef<unknown>>('projectTypeTmp');
fundingStartTmp = viewChild.required<TemplateRef<unknown>>('fundingStartTmp');
fundingEndTmp = viewChild.required<TemplateRef<unknown>>('fundingEndTmp');
@@ -507,4 +523,33 @@ export class EuProjectTableComponent {
? this.expandedProjectTopicsIds.filter((id) => id !== projectId)
: [...this.expandedProjectTopicsIds, projectId];
}
// Highlighted Text
/**
* Extracts the distinct matched terms out of Elasticsearch-style
* highlight fragments (terms wrapped in <em>...</em>).
*/
extractHighlightTerms(fragments: string[] | null | undefined): string[] {
const terms = new Set<string>();
for (const fragment of fragments ?? []) {
if (typeof fragment !== 'string') continue;
const matches = fragment.matchAll(/<em>(.*?)<\/em>/gi);
for (const match of matches) {
const term = match[1]?.trim();
if (term) {
terms.add(term);
}
}
}
return Array.from(terms);
}
getHighlightTerms(terms: string[] | null | undefined): HighlightTerm[] {
return (terms ?? []).map((term) => ({
term,
topic: this.searchResultsStateService?.resolveTopicForTerm(term) ?? null,
}));
}
}