expanded row view adjusted for DFG project table
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
<header class="project-panel__header">
|
||||
<div class="language-toggle" role="group" aria-label="Sprache wählen">
|
||||
<button
|
||||
[disabled]="!hasDePanelContent(project)"
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'de'"
|
||||
@@ -74,6 +75,7 @@
|
||||
DE
|
||||
</button>
|
||||
<button
|
||||
[disabled]="!hasEnPanelContent(project)"
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'en'"
|
||||
@@ -85,7 +87,7 @@
|
||||
<mat-divider />
|
||||
<div class="project-panel__content">
|
||||
@if (getPanelLanguage(project) === 'de') {
|
||||
@if (project.title_de) {
|
||||
@if (project.highlight?.title_de.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Titel</h4>
|
||||
<app-highlighted-text
|
||||
@@ -99,7 +101,7 @@
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (project.abstract_de) {
|
||||
@if (project.highlight?.abstract_de.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Zusammenfassung</h4>
|
||||
<app-highlighted-text
|
||||
@@ -113,7 +115,7 @@
|
||||
</article>
|
||||
}
|
||||
} @else {
|
||||
@if (project.title_en) {
|
||||
@if (project.highlight?.title_en.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Title</h4>
|
||||
<app-highlighted-text
|
||||
@@ -127,7 +129,7 @@
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (project.abstract_en) {
|
||||
@if (project.highlight?.abstract_en.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Abstract</h4>
|
||||
<app-highlighted-text
|
||||
@@ -141,14 +143,7 @@
|
||||
</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) {
|
||||
@if (project.highlight.subject_classifications?.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Fachsystematik</h4>
|
||||
@for (
|
||||
|
||||
@@ -26,7 +26,6 @@ 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,
|
||||
@@ -455,8 +454,12 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
private readonly selectedPanelLanguage = new Map<string, HighlightLanguage>();
|
||||
|
||||
getPanelLanguage(project: DfgProjectSummary): HighlightLanguage {
|
||||
if (!project.id) return 'de';
|
||||
return this.selectedPanelLanguage.get(project.id) ?? 'de';
|
||||
if (this.hasDePanelContent(project)) {
|
||||
return this.selectedPanelLanguage.get(project.id) ?? 'de';
|
||||
} else if (this.hasEnPanelContent(project)) {
|
||||
return this.selectedPanelLanguage.get(project.id) ?? 'en';
|
||||
}
|
||||
return 'de'; // default to German if no content is available'
|
||||
}
|
||||
|
||||
setPanelLanguage(
|
||||
@@ -467,15 +470,23 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
this.selectedPanelLanguage.set(project.id, language);
|
||||
}
|
||||
|
||||
hasAnyPanelContent(project: DfgProjectSummary): boolean {
|
||||
const language = this.getPanelLanguage(project);
|
||||
|
||||
hasDePanelContent(project: DfgProjectSummary): boolean {
|
||||
const hasLocalizedContent =
|
||||
language === 'de'
|
||||
? !!project.title_de || !!project.abstract_de
|
||||
: !!project.title_en || !!project.abstract_en;
|
||||
project.highlight?.title_de?.length ||
|
||||
project.highlight?.abstract_de?.length
|
||||
? true
|
||||
: false;
|
||||
|
||||
return hasLocalizedContent || !!project.subject_classifications_raw?.length;
|
||||
return hasLocalizedContent;
|
||||
}
|
||||
hasEnPanelContent(project: DfgProjectSummary): boolean {
|
||||
const hasLocalizedContent =
|
||||
project.highlight?.title_en?.length ||
|
||||
project.highlight?.abstract_en?.length
|
||||
? true
|
||||
: false;
|
||||
|
||||
return hasLocalizedContent;
|
||||
}
|
||||
getClassificationHighlightTerms(
|
||||
project: DfgProjectSummary,
|
||||
@@ -528,40 +539,7 @@ export class DfgProjectTableComponent implements OnInit {
|
||||
getHighlightTerms(terms: string[] | null | undefined): HighlightTerm[] {
|
||||
return (terms ?? []).map((term) => ({
|
||||
term,
|
||||
topic: this.resolveTopicForTerm(term),
|
||||
topic: this.searchResultsStateService?.resolveTopicForTerm(term) ?? null,
|
||||
}));
|
||||
}
|
||||
|
||||
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