added details row for dfg projects
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<app-data-table
|
||||
[columns]="columns"
|
||||
[data]="elements()"
|
||||
[detailTemplate]="expandedProject"
|
||||
[queryParamSortKey]="queryParamKeys.sortBy"
|
||||
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
|
||||
|
||||
@@ -9,7 +10,9 @@
|
||||
queryParamPageKey="page"
|
||||
queryParamSizeKey="size"
|
||||
[pageSizeOptions]="[10, 25, 50]" />
|
||||
|
||||
<ng-template #titleTmp let-element>
|
||||
<span class="panel-field__text">{{ element.title_de }}</span>
|
||||
</ng-template>
|
||||
<ng-template #fundingEndTmp let-element>
|
||||
<span>
|
||||
{{
|
||||
@@ -42,12 +45,11 @@
|
||||
<span
|
||||
class="publication-institution-tag classification-tag"
|
||||
[matTooltip]="getClassificationTooltipText(classification)"
|
||||
matTooltipPosition="above"
|
||||
[attr.aria-label]="getClassificationTooltipText(classification)">
|
||||
matTooltipPosition="above">
|
||||
<mat-icon class="institution-icon">category</mat-icon>
|
||||
<span class="institution-name">{{
|
||||
getClassificationFullChain(classification)
|
||||
}}</span>
|
||||
<span class="institution-name">
|
||||
{{ getClassificationFullChain(classification) }}</span
|
||||
>
|
||||
</span>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
@@ -60,7 +62,115 @@
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #expandedProject let-project>
|
||||
<section class="project-panel" aria-label="Weitere Projektdetails">
|
||||
<header class="project-panel__header">
|
||||
<div class="language-toggle" role="group" aria-label="Sprache wählen">
|
||||
<button
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'de'"
|
||||
(click)="setPanelLanguage(project, 'de')">
|
||||
DE
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'en'"
|
||||
(click)="setPanelLanguage(project, 'en')">
|
||||
EN
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<mat-divider />
|
||||
<div class="project-panel__content">
|
||||
@if (getPanelLanguage(project) === 'de') {
|
||||
@if (project.title_de) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Titel</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title_de"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.title_de)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (project.abstract_de) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Zusammenfassung</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.abstract_de"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.abstract_de)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
} @else {
|
||||
@if (project.title_en) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Title</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title_en"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.title_en)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (project.abstract_en) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Abstract</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.abstract_en"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.abstract_en)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
}
|
||||
|
||||
@if (!hasAnyPanelContent(project)) {
|
||||
<div class="project-panel__empty">
|
||||
<mat-icon aria-hidden="true">info</mat-icon>
|
||||
<span>Keine weiteren Angaben vorhanden.</span>
|
||||
</div>
|
||||
}
|
||||
@if (getProjectClassifications(project).length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Fachsystematik</h4>
|
||||
@for (
|
||||
classification of getProjectClassifications(project);
|
||||
track $index
|
||||
) {
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="getClassificationFullChain(classification)"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
getClassificationHighlightTerms(project, $index)
|
||||
)
|
||||
" />
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</ng-template>
|
||||
<ng-template #authorsTmp let-project>
|
||||
@let projectAuthors = getProjectAuthors(project);
|
||||
@let isProjectAuthorsExpanded = isProjectPersonsExpanded(project);
|
||||
|
||||
@@ -203,3 +203,249 @@
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
// ------------------------
|
||||
// Expanded project highlights
|
||||
// ------------------------
|
||||
|
||||
.project-highlight-details {
|
||||
width: 100%;
|
||||
padding: 10px 14px 12px;
|
||||
color: var(--sg-text);
|
||||
background: var(--sg-background);
|
||||
border-top: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
.highlight-header {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.highlight-header__title {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 7px;
|
||||
|
||||
> 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: 10px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
}
|
||||
|
||||
.highlight-content-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.highlight-section {
|
||||
min-width: 0;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.highlight-section__header,
|
||||
.classification-highlight-section__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 7px;
|
||||
min-height: 32px;
|
||||
padding: 4px 7px;
|
||||
background: var(--sg-primary-soft);
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
.highlight-section__heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 5px;
|
||||
|
||||
mat-icon {
|
||||
flex: 0 0 auto;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
color: var(--sg-primary);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
h4 {
|
||||
margin: 0;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.language-toggle {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
padding: 1px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 4px;
|
||||
background: var(--sg-background);
|
||||
}
|
||||
|
||||
.language-toggle__button {
|
||||
min-width: 27px;
|
||||
padding: 2px 5px;
|
||||
border: 0;
|
||||
border-radius: 3px;
|
||||
color: var(--sg-text-muted);
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
color: var(--sg-primary);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: var(--sg-background);
|
||||
background: var(--sg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.language-label {
|
||||
flex: 0 0 auto;
|
||||
padding: 2px 5px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 3px;
|
||||
color: var(--sg-text-muted);
|
||||
background: var(--sg-background);
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.highlight-section__body {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding: 6px 7px;
|
||||
}
|
||||
|
||||
.highlight-snippet {
|
||||
margin: 0;
|
||||
padding: 4px 6px;
|
||||
border-left: 2px solid var(--sg-primary);
|
||||
border-radius: 0 3px 3px 0;
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--sg-primary-soft) 55%,
|
||||
var(--sg-background)
|
||||
);
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
// ------------------------
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,15 @@ import { MatTooltip } from '@angular/material/tooltip';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
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 { TopicHierarchyColorInput } from '../../../resolvers/utils/topic-colors';
|
||||
import {
|
||||
HighlightedTextComponent,
|
||||
HighlightTerm,
|
||||
} from '../highlighted-text/highlighted-text.component';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
type HighlightLanguage = 'de' | 'en';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dfg-project-table',
|
||||
imports: [
|
||||
@@ -37,6 +46,8 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl
|
||||
MatTooltip,
|
||||
AppTopicChipComponent,
|
||||
SkTextDirective,
|
||||
HighlightedTextComponent,
|
||||
MatDividerModule,
|
||||
],
|
||||
templateUrl: './dfg-project-table.component.html',
|
||||
styleUrl: './dfg-project-table.component.scss',
|
||||
@@ -44,7 +55,10 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl
|
||||
export class DfgProjectTableComponent implements OnInit {
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
private readonly searchResultsStateService = inject(
|
||||
SearchResultsStateService,
|
||||
{ optional: true },
|
||||
);
|
||||
page = input.required<DfgProjectPage>();
|
||||
authorFilterEnabled = input<boolean>(false);
|
||||
institutionFilterEnabled = input<boolean>(false);
|
||||
@@ -99,10 +113,21 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
selectedTopicMatchesQueryParams = computed(() => {
|
||||
return this.queryParamMap().get('topics')?.split(',') || [];
|
||||
});
|
||||
|
||||
keywordTopicMap = computed(() => {
|
||||
return (
|
||||
this.searchResultsStateService?.keywordTopicMap() ??
|
||||
new Map<string, Topic>()
|
||||
);
|
||||
});
|
||||
ngOnInit(): void {
|
||||
this.columns = [
|
||||
{ id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' },
|
||||
{
|
||||
id: 'title',
|
||||
header: 'Titel',
|
||||
type: 'accessor',
|
||||
accessorKey: 'title_de',
|
||||
cellTemplate: this.titleTmp(),
|
||||
},
|
||||
{
|
||||
id: 'funding_start',
|
||||
header: 'Förderbeginn',
|
||||
@@ -130,7 +155,7 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
cellTemplate: this.institutionsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'professional_classification',
|
||||
id: 'subject_classifications_raw',
|
||||
header: 'Fachsystematik',
|
||||
type: 'display',
|
||||
cellTemplate: this.detailRowTmp(),
|
||||
@@ -426,4 +451,117 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
getClassificationTooltipText(classification: any): string {
|
||||
return this.getClassificationFullChain(classification);
|
||||
}
|
||||
|
||||
private readonly selectedPanelLanguage = new Map<string, HighlightLanguage>();
|
||||
|
||||
getPanelLanguage(project: DfgProjectSummary): HighlightLanguage {
|
||||
if (!project.id) return 'de';
|
||||
return this.selectedPanelLanguage.get(project.id) ?? 'de';
|
||||
}
|
||||
|
||||
setPanelLanguage(
|
||||
project: DfgProjectSummary,
|
||||
language: HighlightLanguage,
|
||||
): void {
|
||||
if (!project.id) return;
|
||||
this.selectedPanelLanguage.set(project.id, language);
|
||||
}
|
||||
|
||||
hasAnyPanelContent(project: DfgProjectSummary): boolean {
|
||||
const language = this.getPanelLanguage(project);
|
||||
|
||||
const hasLocalizedContent =
|
||||
language === 'de'
|
||||
? !!project.title_de || !!project.abstract_de
|
||||
: !!project.title_en || !!project.abstract_en;
|
||||
|
||||
return hasLocalizedContent || !!project.subject_classifications_raw?.length;
|
||||
}
|
||||
getClassificationHighlightTerms(
|
||||
project: DfgProjectSummary,
|
||||
index: number,
|
||||
): string[] {
|
||||
const classificationHighlights =
|
||||
project.highlight?.subject_classifications ?? [];
|
||||
const terms = new Set<string>();
|
||||
|
||||
for (const highlight of classificationHighlights) {
|
||||
if (highlight.offset !== index) continue;
|
||||
|
||||
for (const fragments of [
|
||||
highlight.wissenschaftsbereich,
|
||||
highlight.fachkollegium,
|
||||
highlight.fachgebiet,
|
||||
highlight.fachgebiet_de,
|
||||
highlight.fach,
|
||||
]) {
|
||||
for (const term of this.extractHighlightTerms(fragments)) {
|
||||
terms.add(term);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(terms);
|
||||
}
|
||||
/**
|
||||
* 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.resolveTopicForTerm(term),
|
||||
}));
|
||||
}
|
||||
|
||||
private resolveTopicForTerm(term: string): TopicHierarchyColorInput | null {
|
||||
const topic =
|
||||
this.keywordTopicMap().get(term) ??
|
||||
this.keywordTopicMap().get(term.toLowerCase());
|
||||
//Attempt to find a topic for the term by checking if the term is a substring of any keyword in the keywordTopicMap
|
||||
if (!topic) {
|
||||
for (const [keyword, mappedTopic] of this.keywordTopicMap()) {
|
||||
if (
|
||||
keyword.toLowerCase().includes(term.toLowerCase()) ||
|
||||
term.toLowerCase().includes(keyword.toLowerCase())
|
||||
) {
|
||||
return {
|
||||
id: mappedTopic.id,
|
||||
name: mappedTopic.display_name,
|
||||
field_id: mappedTopic.field?.id,
|
||||
field_name: mappedTopic.field?.display_name,
|
||||
domain_id: mappedTopic.domain?.id,
|
||||
domain_name: mappedTopic.domain?.display_name,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!topic) return null;
|
||||
return {
|
||||
id: topic.id,
|
||||
name: topic.display_name,
|
||||
field_id: topic.field?.id,
|
||||
field_name: topic.field?.display_name,
|
||||
domain_id: topic.domain?.id,
|
||||
domain_name: topic.domain?.display_name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user