fix/news-details-ui #269
@@ -230,8 +230,8 @@
|
||||
»{{ topic.source_keyword }}«
|
||||
</button>
|
||||
<p class="kw-hint">
|
||||
Im Artikel hervorgehoben · klicken zum Suche zu
|
||||
öffnen
|
||||
Im Artikel hervorgehoben - klicken, um zum
|
||||
ersten Vorkommen zu springen.
|
||||
</p>
|
||||
} @else {
|
||||
<p class="placeholder">
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
ViewChild,
|
||||
inject,
|
||||
} from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
@@ -66,7 +65,6 @@ export class NewsDetailComponent implements OnInit {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly httpClient = inject(HttpClient);
|
||||
private readonly worksService = inject(WorksService);
|
||||
private readonly location = inject(Location);
|
||||
private readonly sanitizer = inject(DomSanitizer);
|
||||
|
||||
article: NewsArticleDetail | null = null;
|
||||
@@ -150,7 +148,7 @@ export class NewsDetailComponent implements OnInit {
|
||||
}
|
||||
|
||||
navigateBack(): void {
|
||||
this.location.back();
|
||||
this.router.navigate(['/news']);
|
||||
}
|
||||
|
||||
formatDate(dateStr?: string | null): string {
|
||||
@@ -200,36 +198,30 @@ export class NewsDetailComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
}
|
||||
const orphanColors = [
|
||||
'var(--sg-primary)',
|
||||
'var(--sg-blue-highlight)',
|
||||
'var(--sg-success)',
|
||||
'var(--sg-warning)',
|
||||
'var(--sg-error)',
|
||||
];
|
||||
let orphanIdx = 0;
|
||||
|
||||
let html = this.escapeHtml(text);
|
||||
if (keywords.length) {
|
||||
[...keywords]
|
||||
.sort((a, b) => b.length - a.length)
|
||||
.forEach((kw) => {
|
||||
let color = keywordColorMap.get(kw.toLowerCase());
|
||||
if (!color) {
|
||||
color = orphanColors[orphanIdx % orphanColors.length];
|
||||
orphanIdx++;
|
||||
}
|
||||
const kwHtml = this.escapeHtml(kw);
|
||||
const re = new RegExp(
|
||||
`(${this.escapeRegex(kwHtml)}[\\w\\u00C0-\\u024F]*)`,
|
||||
'gi',
|
||||
);
|
||||
html = html.replace(
|
||||
re,
|
||||
`<mark class="kw-mark" style="--t:${color}" data-kw="${kwHtml}">$1</mark>`,
|
||||
);
|
||||
});
|
||||
}
|
||||
[...keywords]
|
||||
.sort((a, b) => b.length - a.length)
|
||||
.forEach((kw) => {
|
||||
const color = keywordColorMap.get(kw.toLowerCase());
|
||||
if (!color) return;
|
||||
const kwHtml = this.escapeHtml(kw);
|
||||
const escaped = this.escapeRegex(kwHtml);
|
||||
const before = '(?<![\\w\\u00C0-\\u024F])';
|
||||
const acronymLike =
|
||||
kw.length <= 3 ||
|
||||
(kw === kw.toUpperCase() && kw !== kw.toLowerCase());
|
||||
const re = new RegExp(
|
||||
acronymLike
|
||||
? `${before}(${escaped})(?![\\w\\u00C0-\\u024F])`
|
||||
: `${before}(${escaped}[\\w\\u00C0-\\u024F]*)`,
|
||||
'gi',
|
||||
);
|
||||
html = html.replace(
|
||||
re,
|
||||
`<mark class="kw-mark" style="--t:${color}" data-kw="${kwHtml}">$1</mark>`,
|
||||
);
|
||||
});
|
||||
return this.sanitizer.bypassSecurityTrustHtml(html);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,18 +18,24 @@
|
||||
|
||||
<ng-template #additionalFiltersTmp>
|
||||
<div class="additional-filters">
|
||||
<mat-form-field
|
||||
appearance="outline"
|
||||
subscriptSizing="dynamic"
|
||||
class="relevance-field">
|
||||
<mat-select
|
||||
[formControl]="relevanceFilter"
|
||||
placeholder="Relevanz"
|
||||
multiple>
|
||||
<mat-option value="relevant">Relevant</mat-option>
|
||||
<mat-option value="not_relevant">Nicht relevant</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<app-filter-card>
|
||||
<app-query-param-selector
|
||||
class="relevance-field"
|
||||
[options]="relevanceOptions"
|
||||
queryParamKey="relevance"
|
||||
label="Relevanz"
|
||||
icon="check_circle"
|
||||
[multiple]="true" />
|
||||
|
||||
@if (!isSearching()) {
|
||||
<app-query-param-selector
|
||||
class="sort-order-field"
|
||||
[options]="sortingDirectionOptionsAll"
|
||||
queryParamKey="sorting_order"
|
||||
label="Sortierung"
|
||||
icon="sort" />
|
||||
}
|
||||
</app-filter-card>
|
||||
|
||||
<app-year-range-slider
|
||||
class="year-field"
|
||||
@@ -59,7 +65,5 @@
|
||||
[additionalFiltersTmp]="additionalFiltersTmp"
|
||||
[noResultsTmp]="noResultsTmp"
|
||||
[cardMinWidth]="380"
|
||||
[sortingDirectionOptions]="sortingDirectionOptions()"
|
||||
sortingDirectionLabel="Sortierung"
|
||||
searchLabel="Nachrichten durchsuchen" />
|
||||
</div>
|
||||
|
||||
@@ -44,20 +44,36 @@
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
$card-min-width: 380px;
|
||||
|
||||
.additional-filters {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 40px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax($card-min-width, 1fr));
|
||||
align-items: stretch;
|
||||
gap: 1.5rem;
|
||||
padding: 0 1rem 1rem;
|
||||
|
||||
app-year-range-slider {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
::ng-deep app-year-range-slider .year-filter {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-form-field-subscript-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-form-field-icon-prefix {
|
||||
padding: 0 4px 0 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.relevance-field {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.year-field {
|
||||
min-width: 280px;
|
||||
.relevance-field,
|
||||
.sort-order-field {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
|
||||
@@ -7,12 +7,10 @@ import {
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { debounceTime, merge } from 'rxjs';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
|
||||
import { WorksService } from '../../api';
|
||||
import {
|
||||
@@ -24,7 +22,11 @@ import {
|
||||
NewsCardComponent,
|
||||
NEWS_MIN_YEAR,
|
||||
} from '../../shared/ui/news-card/news-card.component';
|
||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import {
|
||||
QueryParamSelectorComponent,
|
||||
SelectorOption,
|
||||
} from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import { FilterCardComponent } from '../../shared/ui/filter-card/filter-card.component';
|
||||
import { YearRangeSliderComponent } from '../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
|
||||
interface NewsArticle extends NewsArticleBase {
|
||||
@@ -44,11 +46,10 @@ type SortOrder = 'desc' | 'asc';
|
||||
@Component({
|
||||
selector: 'app-news',
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
MatFormFieldModule,
|
||||
MatSelectModule,
|
||||
CardSearchComponent,
|
||||
NewsCardComponent,
|
||||
FilterCardComponent,
|
||||
QueryParamSelectorComponent,
|
||||
YearRangeSliderComponent,
|
||||
],
|
||||
templateUrl: './news.component.html',
|
||||
@@ -64,11 +65,16 @@ export class NewsComponent implements OnInit {
|
||||
readonly minYear = NEWS_MIN_YEAR;
|
||||
readonly maxYear = new Date().getFullYear();
|
||||
|
||||
private readonly sortingDirectionOptionsAll: SelectorOption[] = [
|
||||
readonly sortingDirectionOptionsAll: SelectorOption[] = [
|
||||
{ value: 'desc', display_name: 'Neueste zuerst' },
|
||||
{ value: 'asc', display_name: 'Älteste zuerst' },
|
||||
];
|
||||
|
||||
readonly relevanceOptions: SelectorOption[] = [
|
||||
{ value: 'relevant', display_name: 'Relevant' },
|
||||
{ value: 'not_relevant', display_name: 'Nicht relevant' },
|
||||
];
|
||||
|
||||
readonly relevanceFilter = new FormControl<string[]>([], {
|
||||
nonNullable: true,
|
||||
});
|
||||
@@ -85,9 +91,6 @@ export class NewsComponent implements OnInit {
|
||||
readonly searchQuery = signal('');
|
||||
|
||||
readonly isSearching = computed(() => this.searchQuery().trim().length > 0);
|
||||
readonly sortingDirectionOptions = computed<SelectorOption[]>(() =>
|
||||
this.isSearching() ? [] : this.sortingDirectionOptionsAll,
|
||||
);
|
||||
|
||||
readonly page = computed<Page>(() => ({
|
||||
page: this.currentPage,
|
||||
|
||||
@@ -107,7 +107,7 @@ export class AppMenuComponent {
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'News',
|
||||
label: 'Nachrichten',
|
||||
icon: NEWS_ICON,
|
||||
route: '/news',
|
||||
disabled: false,
|
||||
|
||||
Reference in New Issue
Block a user