added expanded Row for bund project table

This commit is contained in:
2026-08-16 20:47:03 +02:00
parent f4656fcf39
commit a0fdc8799b
3 changed files with 187 additions and 1 deletions
@@ -1,6 +1,7 @@
<app-data-table
[columns]="columns"
[data]="elements()"
[detailTemplate]="expandedProject"
[queryParamSortKey]="queryParamKeys.sortBy"
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
@@ -106,3 +107,60 @@
}
</div>
</ng-template>
<ng-template #expandedProject let-project>
<section class="project-panel" aria-label="Weitere Projektdetails">
<div class="project-panel__content">
@if (project.highlight?.topic.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.topic"
[highlights]="
getHighlightTerms(extractHighlightTerms(project.highlight?.topic))
" />
</article>
}
@if (project.highlight?.recipient.length > 0) {
<article class="panel-field panel-field--full">
<h4 class="panel-field__label">Zuwendungsempfänger</h4>
<app-highlighted-text
class="panel-field__text"
[content]="project.recipient"
[highlights]="
getHighlightTerms(
extractHighlightTerms(project.highlight?.recipient)
)
" />
</article>
}
@if (project.highlight?.joint_project.length > 0) {
<article class="panel-field panel-field--full">
<h4 class="panel-field__label">Verbundprojekt</h4>
<app-highlighted-text
class="panel-field__text"
[content]="project.joint_project"
[highlights]="
getHighlightTerms(
extractHighlightTerms(project.highlight?.joint_project)
)
" />
</article>
}
@if (project.highlight?.executing_agency.length > 0) {
<article class="panel-field panel-field--full">
<h4 class="panel-field__label">Ausführende Stelle</h4>
<app-highlighted-text
class="panel-field__text"
[content]="project.executing_agency"
[highlights]="
getHighlightTerms(
extractHighlightTerms(project.highlight?.executing_agency)
)
" />
</article>
}
</div>
</section>
</ng-template>
@@ -205,6 +205,97 @@
}
}
}
// ------------------------
// 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;
}
}
// ------------------------
// Responsive adjustments
@@ -27,6 +27,12 @@ import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
import { bundProjectQueryParamKeys } from '../../../resolvers/bund-projects.resolver';
import { SkTextDirective } from '../../../custom-directives/sk-text.directive';
import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component';
import { SearchResultsStateService } from '../../../modules/keywords-search/search-results/search-results-state.service';
import {
HighlightedTextComponent,
HighlightTerm,
} from '../highlighted-text/highlighted-text.component';
import { MatDividerModule } from '@angular/material/divider';
@Component({
selector: 'app-bund-project-table',
imports: [
@@ -42,6 +48,7 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl
ChipComponent,
AppTopicChipComponent,
SkTextDirective,
HighlightedTextComponent,
],
templateUrl: './bund-project-table.component.html',
styleUrl: './bund-project-table.component.scss',
@@ -49,7 +56,10 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl
export class BundProjectTableComponent implements OnInit {
private readonly activatedRoute = inject(ActivatedRoute);
private readonly router = inject(Router);
private readonly searchResultsStateService = inject(
SearchResultsStateService,
{ optional: true },
);
page = input.required<BundProjectPage>();
authorFilterEnabled = input<boolean>(false);
institutionFilterEnabled = input<boolean>(false);
@@ -353,4 +363,31 @@ export class BundProjectTableComponent implements OnInit {
return this.expandedProjectTopicsId.includes(project.funding_code);
}
/**
* 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,
}));
}
}