diff --git a/webapp/src/app/modules/news-detail/news-detail.component.html b/webapp/src/app/modules/news-detail/news-detail.component.html index 4f7a14b7..24307372 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.html +++ b/webapp/src/app/modules/news-detail/news-detail.component.html @@ -230,8 +230,8 @@ »{{ topic.source_keyword }}«

- Im Artikel hervorgehoben · klicken zum Suche zu - öffnen + Im Artikel hervorgehoben - klicken, um zum + ersten Vorkommen zu springen.

} @else {

diff --git a/webapp/src/app/modules/news-detail/news-detail.component.ts b/webapp/src/app/modules/news-detail/news-detail.component.ts index 707f191f..fdbb74f9 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.ts +++ b/webapp/src/app/modules/news-detail/news-detail.component.ts @@ -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, - `$1`, - ); - }); - } + [...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 = '(?$1`, + ); + }); return this.sanitizer.bypassSecurityTrustHtml(html); } diff --git a/webapp/src/app/modules/news/news.component.html b/webapp/src/app/modules/news/news.component.html index c5fcd597..e0848c56 100644 --- a/webapp/src/app/modules/news/news.component.html +++ b/webapp/src/app/modules/news/news.component.html @@ -18,18 +18,24 @@

- - - Relevant - Nicht relevant - - + + + + @if (!isSearching()) { + + } +
diff --git a/webapp/src/app/modules/news/news.component.scss b/webapp/src/app/modules/news/news.component.scss index d668b89a..14ecda37 100644 --- a/webapp/src/app/modules/news/news.component.scss +++ b/webapp/src/app/modules/news/news.component.scss @@ -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) { diff --git a/webapp/src/app/modules/news/news.component.ts b/webapp/src/app/modules/news/news.component.ts index 9d916390..13b99041 100644 --- a/webapp/src/app/modules/news/news.component.ts +++ b/webapp/src/app/modules/news/news.component.ts @@ -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([], { 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(() => - this.isSearching() ? [] : this.sortingDirectionOptionsAll, - ); readonly page = computed(() => ({ page: this.currentPage, diff --git a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts index 52d86a73..40d4bfb6 100644 --- a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts +++ b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts @@ -107,7 +107,7 @@ export class AppMenuComponent { disabled: false, }, { - label: 'News', + label: 'Nachrichten', icon: NEWS_ICON, route: '/news', disabled: false,