diff --git a/webapp/src/app/modules/news-detail/news-detail.component.scss b/webapp/src/app/modules/news-detail/news-detail.component.scss
index 82f7b1ac..17d325bb 100644
--- a/webapp/src/app/modules/news-detail/news-detail.component.scss
+++ b/webapp/src/app/modules/news-detail/news-detail.component.scss
@@ -180,6 +180,9 @@ main {
display: flex;
flex-direction: column;
gap: 8px;
+ max-height: 375px;
+ overflow-y: auto;
+ padding-right: 4px;
}
.person-item {
diff --git a/webapp/src/app/modules/news/news.component.html b/webapp/src/app/modules/news/news.component.html
index aff9aadc..7eadac9a 100644
--- a/webapp/src/app/modules/news/news.component.html
+++ b/webapp/src/app/modules/news/news.component.html
@@ -4,107 +4,26 @@
Aktuelle Nachrichten aus Campus-Aktuell.
-
-
- search
-
-
-
- @if (!isSearching) {
-
-
- Neueste zuerst
- Älteste zuerst
-
-
+
+ @if (article.snippet) {
+
+ } @else {
+ —
}
-
+
-
- @if (loading) {
-
-
-
- }
-
-
-
- | Titel |
-
- {{
- article.maintitle || 'Kein Titel'
- }}
- |
-
-
-
- Fundstelle |
-
- @if (article.snippet) {
-
- } @else {
- —
- }
- |
-
-
-
- Relevanz |
-
- @if (article.relevant === true) {
-
- check_circle
- Relevant
-
- } @else if (article.relevant === false) {
-
- cancel
- Nicht relevant
-
- } @else {
-
- help
- Nicht bestimmt
-
- }
- |
-
-
-
- Datum |
-
- {{ formatDate(article.date) }}
- |
-
-
-
-
-
-
- @if (!loading && articles.length === 0) {
-
- @if (isSearching) {
- Keine Ergebnisse für „{{ searchControl.value.trim() }}" gefunden.
- } @else {
- Keine Nachrichten gefunden.
- }
-
- }
-
-
-
+
+
diff --git a/webapp/src/app/modules/news/news.component.scss b/webapp/src/app/modules/news/news.component.scss
index 100dead9..8cc7660b 100644
--- a/webapp/src/app/modules/news/news.component.scss
+++ b/webapp/src/app/modules/news/news.component.scss
@@ -17,103 +17,6 @@ h6 {
font-size: 14px;
}
-.news-toolbar {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 12px;
- padding-top: 10px;
- padding-bottom: 25px;
-}
-
-.search-field {
- max-width: 480px;
-}
-
-::ng-deep .news-toolbar .mat-mdc-form-field-subscript-wrapper {
- display: none;
-}
-
-::ng-deep .news-toolbar .mat-mdc-text-field-wrapper {
- height: 42px;
- background: #fff;
- border-radius: var(--sg-radius-sm);
-}
-
-::ng-deep .news-toolbar .mat-mdc-form-field-infix {
- min-height: unset;
- height: 42px;
- padding: 0;
- display: flex;
- align-items: center;
-}
-
-::ng-deep .news-toolbar .mdc-notched-outline__leading,
-::ng-deep .news-toolbar .mdc-notched-outline__notch,
-::ng-deep .news-toolbar .mdc-notched-outline__trailing {
- border-color: #d9e2f0;
-}
-
-::ng-deep .news-toolbar input.mat-mdc-input-element {
- color: var(--sg-text);
- font-size: 14px;
-}
-
-::ng-deep .news-toolbar input.mat-mdc-input-element::placeholder {
- color: var(--sg-text-muted);
- opacity: 1;
- font-size: 14px;
-}
-
-.sort-field {
- width: 180px;
-}
-
-.table-wrap {
- position: relative;
- overflow-x: auto;
-}
-
-table {
- width: 100%;
- min-width: 600px;
- border-collapse: separate;
- border-spacing: 0 10px;
- background: transparent;
- box-shadow: none;
-}
-
-.article-title {
- display: inline-block;
- max-width: 520px;
- line-height: 1.35;
- color: var(--sg-text);
- font-size: 14px;
- font-weight: 700;
- text-decoration: none;
-
- &:hover {
- color: var(--sg-text);
- text-decoration: underline;
- }
-}
-
-.loading {
- position: absolute;
- inset: 0;
- z-index: 1;
- display: grid;
- place-items: center;
- background: rgba(255, 255, 255, 0.65);
-}
-
-.empty-state {
- padding: 28px;
- text-align: center;
- color: rgba(0, 0, 0, 0.6);
- background: transparent;
-}
-
.snippet {
color: var(--sg-text-muted);
font-size: 13px;
@@ -131,79 +34,8 @@ table {
color: var(--sg-text-muted);
}
-.relevance-badge {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 5px 12px;
- border-radius: 999px;
- font-size: 13px;
- font-weight: 600;
- line-height: 1;
- white-space: nowrap;
-
- mat-icon {
- font-size: 16px;
- width: 16px;
- height: 16px;
- }
-
- &.is-relevant {
- background: #effaf3;
- border: 1px solid #bdebcf;
- color: #24834f;
- }
-
- &.not-relevant {
- background: var(--sg-surface-muted);
- border: 1px solid #e2e2e2;
- color: var(--sg-text-muted);
- }
-
- &.undetermined {
- background: #fff7e8;
- border: 1px solid #ffd796;
- color: #c67500;
- }
-}
-
-::ng-deep .mat-mdc-header-cell {
- color: var(--sg-text-muted);
- font-size: 12px;
- font-weight: 700;
-}
-
-::ng-deep .mat-mdc-row {
- height: 72px;
-}
-
-::ng-deep .mat-mdc-cell {
- color: var(--sg-text);
- border-bottom-color: var(--sg-border);
- font-size: 13px;
-}
-
-mat-paginator {
- background: transparent;
-}
-
-.table-footer {
- display: flex;
- align-items: center;
- justify-content: space-between;
- min-height: 66px;
- padding: 0 22px 0 28px;
- color: var(--sg-text-muted);
- font-size: 13px;
-}
-
@media (max-width: 600px) {
.page {
padding: 16px;
}
-
- .table-footer {
- align-items: stretch;
- flex-direction: column;
- }
}
diff --git a/webapp/src/app/modules/news/news.component.ts b/webapp/src/app/modules/news/news.component.ts
index 3c1ff74c..dc78da38 100644
--- a/webapp/src/app/modules/news/news.component.ts
+++ b/webapp/src/app/modules/news/news.component.ts
@@ -1,27 +1,21 @@
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
-import { ActivatedRoute, Router, RouterLink } from '@angular/router';
-import { MatIconModule } from '@angular/material/icon';
-import { MatSelectModule } from '@angular/material/select';
-import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
-import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
-import { MatTableModule } from '@angular/material/table';
-import { MatFormFieldModule } from '@angular/material/form-field';
-import { MatInputModule } from '@angular/material/input';
+import { ActivatedRoute, Router } from '@angular/router';
+import { PageEvent } from '@angular/material/paginator';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { debounceTime, distinctUntilChanged } from 'rxjs';
import { WorksService } from '../../api';
import { PaginationService } from '../../shared/services/pagination.service';
+import {
+ NewsArticleBase,
+ NewsListComponent,
+ SortOrder,
+} from '../../shared/ui/news-list/news-list.component';
-interface NewsArticle {
- id: string;
- date?: string | null;
- maintitle?: string | null;
+interface NewsArticle extends NewsArticleBase {
author?: string | null;
- url?: string | null;
- relevant?: boolean | null;
snippet?: string | null;
}
@@ -32,22 +26,11 @@ interface NewsPage {
results: NewsArticle[];
}
-type SortOrder = 'desc' | 'asc';
const DEFAULT_SORT_ORDER: SortOrder = 'desc';
@Component({
selector: 'app-news',
- imports: [
- MatIconModule,
- MatSelectModule,
- MatFormFieldModule,
- MatInputModule,
- MatPaginatorModule,
- MatProgressSpinnerModule,
- MatTableModule,
- ReactiveFormsModule,
- RouterLink,
- ],
+ imports: [ReactiveFormsModule, NewsListComponent],
templateUrl: './news.component.html',
styleUrl: './news.component.scss',
})
@@ -179,21 +162,6 @@ export class NewsComponent implements OnInit {
});
}
- formatDate(dateStr?: string | null): string {
- if (!dateStr) return '-';
- const date = new Date(dateStr);
- if (isNaN(date.getTime())) return dateStr;
- return new Intl.DateTimeFormat('de-DE').format(date);
- }
-
- articleRange(): string {
- if (this.total === 0) return 'Keine Nachrichten gefunden';
- const pageSize = this.paginationService.selection;
- const start = (this.currentPage - 1) * pageSize + 1;
- const end = Math.min(start + this.articles.length - 1, this.total);
- return `Zeige ${start} bis ${end} von ${this.total} Nachrichten`;
- }
-
private parsePage(value: string | null): number {
const page = Number.parseInt(value ?? '', 10);
if (Number.isNaN(page) || page < 1) {
diff --git a/webapp/src/app/modules/person-news/person-news.component.html b/webapp/src/app/modules/person-news/person-news.component.html
index b4f717db..651e39d4 100644
--- a/webapp/src/app/modules/person-news/person-news.component.html
+++ b/webapp/src/app/modules/person-news/person-news.component.html
@@ -4,79 +4,15 @@
Aktuelle Nachrichten zu dieser Person.
-
-
- search
-
-
-
-
-
- Neueste zuerst
- Älteste zuerst
-
-
-
-
-
- @if (loading) {
-
-
-
- }
-
-
-
- @if (!loading && articles.length === 0) {
-
- @if (isSearching) {
- Keine Ergebnisse für „{{ searchControl.value.trim() }}" gefunden.
- } @else {
- Keine Nachrichten gefunden.
- }
-
- }
-
-
-
+
+
diff --git a/webapp/src/app/modules/person-news/person-news.component.scss b/webapp/src/app/modules/person-news/person-news.component.scss
index 68a1899f..6cad4cdb 100644
--- a/webapp/src/app/modules/person-news/person-news.component.scss
+++ b/webapp/src/app/modules/person-news/person-news.component.scss
@@ -17,140 +17,8 @@ h6 {
font-size: 14px;
}
-.news-toolbar {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 12px;
- padding-top: 10px;
- padding-bottom: 25px;
-}
-
-.search-field {
- max-width: 480px;
-}
-
-::ng-deep .news-toolbar .mat-mdc-form-field-subscript-wrapper {
- display: none;
-}
-
-::ng-deep .news-toolbar .mat-mdc-text-field-wrapper {
- height: 42px;
- background: #fff;
- border-radius: var(--sg-radius-sm);
-}
-
-::ng-deep .news-toolbar .mat-mdc-form-field-infix {
- min-height: unset;
- height: 42px;
- padding: 0;
- display: flex;
- align-items: center;
-}
-
-::ng-deep .news-toolbar .mdc-notched-outline__leading,
-::ng-deep .news-toolbar .mdc-notched-outline__notch,
-::ng-deep .news-toolbar .mdc-notched-outline__trailing {
- border-color: #d9e2f0;
-}
-
-::ng-deep .news-toolbar input.mat-mdc-input-element {
- color: var(--sg-text);
- font-size: 14px;
-}
-
-::ng-deep .news-toolbar input.mat-mdc-input-element::placeholder {
- color: var(--sg-text-muted);
- opacity: 1;
- font-size: 14px;
-}
-
-.sort-field {
- width: 180px;
-}
-
-.table-wrap {
- position: relative;
- overflow-x: auto;
-}
-
-table {
- width: 100%;
- min-width: 600px;
- border-collapse: separate;
- border-spacing: 0 10px;
- background: transparent;
- box-shadow: none;
-}
-
-.article-title {
- display: inline-block;
- max-width: 520px;
- line-height: 1.35;
- color: var(--sg-text);
- font-size: 14px;
- font-weight: 700;
- text-decoration: none;
-
- &:hover {
- color: var(--sg-text);
- text-decoration: underline;
- }
-}
-
-.loading {
- position: absolute;
- inset: 0;
- z-index: 1;
- display: grid;
- place-items: center;
- background: rgba(255, 255, 255, 0.65);
-}
-
-.empty-state {
- padding: 28px;
- text-align: center;
- color: rgba(0, 0, 0, 0.6);
- background: transparent;
-}
-
-::ng-deep .mat-mdc-header-cell {
- color: var(--sg-text-muted);
- font-size: 12px;
- font-weight: 700;
-}
-
-::ng-deep .mat-mdc-row {
- height: 72px;
-}
-
-::ng-deep .mat-mdc-cell {
- color: var(--sg-text);
- border-bottom-color: var(--sg-border);
- font-size: 13px;
-}
-
-mat-paginator {
- background: transparent;
-}
-
-.table-footer {
- display: flex;
- align-items: center;
- justify-content: space-between;
- min-height: 66px;
- padding: 0 22px 0 28px;
- color: var(--sg-text-muted);
- font-size: 13px;
-}
-
@media (max-width: 600px) {
.page {
padding: 16px;
}
-
- .table-footer {
- align-items: stretch;
- flex-direction: column;
- }
}
diff --git a/webapp/src/app/modules/person-news/person-news.component.ts b/webapp/src/app/modules/person-news/person-news.component.ts
index b0e6356b..f05391e9 100644
--- a/webapp/src/app/modules/person-news/person-news.component.ts
+++ b/webapp/src/app/modules/person-news/person-news.component.ts
@@ -1,33 +1,21 @@
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
-import { ActivatedRoute, Router, RouterLink } from '@angular/router';
-import { MatIconModule } from '@angular/material/icon';
-import { MatSelectModule } from '@angular/material/select';
-import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
-import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
-import { MatTableModule } from '@angular/material/table';
-import { MatFormFieldModule } from '@angular/material/form-field';
-import { MatInputModule } from '@angular/material/input';
+import { ActivatedRoute, Router } from '@angular/router';
+import { PageEvent } from '@angular/material/paginator';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { debounceTime, distinctUntilChanged } from 'rxjs';
import { PaginationService } from '../../shared/services/pagination.service';
import { ResolverStateService } from '../../shared/services/resolver-state.service';
import { NewsArticle, NewsPage } from '../../resolvers/person-news.resolver';
+import {
+ NewsListComponent,
+ SortOrder,
+} from '../../shared/ui/news-list/news-list.component';
@Component({
selector: 'app-person-news',
- imports: [
- MatIconModule,
- MatSelectModule,
- MatFormFieldModule,
- MatInputModule,
- MatPaginatorModule,
- MatProgressSpinnerModule,
- MatTableModule,
- ReactiveFormsModule,
- RouterLink,
- ],
+ imports: [ReactiveFormsModule, NewsListComponent],
templateUrl: './person-news.component.html',
styleUrl: './person-news.component.scss',
})
@@ -40,11 +28,11 @@ export class PersonNewsComponent implements OnInit {
readonly searchControl = new FormControl('', { nonNullable: true });
- displayedColumns = ['maintitle', 'author', 'date'];
+ displayedColumns = ['maintitle', 'relevance', 'date'];
articles: NewsArticle[] = [];
total = 0;
- currentPageIndex = 0;
- sortOrder: 'desc' | 'asc' = 'desc';
+ currentPage = 1;
+ sortOrder: SortOrder = 'desc';
get loading(): boolean {
return this.resolverStateService.isResolving();
@@ -75,7 +63,7 @@ export class PersonNewsComponent implements OnInit {
const sortOrder = params.get('sortOrder');
const query = params.get('query') ?? '';
- this.currentPageIndex = page - 1;
+ this.currentPage = page;
this.paginationService.selection = pageSize;
this.sortOrder = sortOrder === 'asc' ? 'asc' : 'desc';
this.searchControl.setValue(query, { emitEvent: false });
@@ -103,30 +91,13 @@ export class PersonNewsComponent implements OnInit {
});
}
- onSortChange(order: 'desc' | 'asc'): void {
+ onSortChange(order: SortOrder): void {
this.updateQueryParams({
sortOrder: order,
page: 1,
});
}
- formatDate(dateStr?: string | null): string {
- if (!dateStr) return '-';
- const date = new Date(dateStr);
- if (isNaN(date.getTime())) return dateStr;
- return new Intl.DateTimeFormat('de-DE').format(date);
- }
-
- articleRange(): string {
- if (this.total === 0) return 'Keine Nachrichten gefunden';
- const start = this.currentPageIndex * this.paginationService.selection + 1;
- const end = Math.min(
- start + this.paginationService.selection - 1,
- this.total,
- );
- return `Zeige ${start} bis ${end} von ${this.total} Nachrichten`;
- }
-
private updateQueryParams(
overrides: Record,
): void {
diff --git a/webapp/src/app/resolvers/person-news.resolver.ts b/webapp/src/app/resolvers/person-news.resolver.ts
index 9d361534..6c4bde29 100644
--- a/webapp/src/app/resolvers/person-news.resolver.ts
+++ b/webapp/src/app/resolvers/person-news.resolver.ts
@@ -11,6 +11,7 @@ export interface NewsArticle {
maintitle?: string | null;
author?: string | null;
url?: string | null;
+ relevant?: boolean | null;
}
export interface NewsPage {
diff --git a/webapp/src/app/shared/ui/news-list/news-list.component.html b/webapp/src/app/shared/ui/news-list/news-list.component.html
new file mode 100644
index 00000000..91f290ea
--- /dev/null
+++ b/webapp/src/app/shared/ui/news-list/news-list.component.html
@@ -0,0 +1,103 @@
+
+
+ search
+
+
+
+
+
+ Neueste zuerst
+ Älteste zuerst
+
+
+
+
+
+ @if (loading) {
+
+
+
+ }
+
+
+
+ | Titel |
+
+ {{
+ article.maintitle || 'Kein Titel'
+ }}
+ |
+
+
+
+ Relevanz |
+
+ @if (article.relevant === true) {
+
+ check_circle
+ Relevant
+
+ } @else if (article.relevant === false) {
+
+ cancel
+ Nicht relevant
+
+ } @else {
+
+ help
+ Nicht bestimmt
+
+ }
+ |
+
+
+
+ Datum |
+
+ {{ formatDate(article.date) }}
+ |
+
+
+ @if (extraColumnId && extraColumnTemplate) {
+
+ {{ extraColumnHeader }} |
+
+
+ |
+
+ }
+
+
+
+
+
+ @if (!loading && articles.length === 0) {
+
+ @if (isSearching) {
+ Keine Ergebnisse für „{{ searchControl.value.trim() }}" gefunden.
+ } @else {
+ Keine Nachrichten gefunden.
+ }
+
+ }
+
+
+
diff --git a/webapp/src/app/shared/ui/news-list/news-list.component.scss b/webapp/src/app/shared/ui/news-list/news-list.component.scss
new file mode 100644
index 00000000..a8eafe84
--- /dev/null
+++ b/webapp/src/app/shared/ui/news-list/news-list.component.scss
@@ -0,0 +1,169 @@
+.news-toolbar {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 12px;
+ padding-top: 10px;
+ padding-bottom: 25px;
+}
+
+.search-field {
+ max-width: 480px;
+}
+
+::ng-deep .news-toolbar .mat-mdc-form-field-subscript-wrapper {
+ display: none;
+}
+
+::ng-deep .news-toolbar .mat-mdc-text-field-wrapper {
+ height: 42px;
+ background: #fff;
+ border-radius: var(--sg-radius-sm);
+}
+
+::ng-deep .news-toolbar .mat-mdc-form-field-infix {
+ min-height: unset;
+ height: 42px;
+ padding: 0;
+ display: flex;
+ align-items: center;
+}
+
+::ng-deep .news-toolbar .mdc-notched-outline__leading,
+::ng-deep .news-toolbar .mdc-notched-outline__notch,
+::ng-deep .news-toolbar .mdc-notched-outline__trailing {
+ border-color: #d9e2f0;
+}
+
+::ng-deep .news-toolbar input.mat-mdc-input-element {
+ color: var(--sg-text);
+ font-size: 14px;
+}
+
+::ng-deep .news-toolbar input.mat-mdc-input-element::placeholder {
+ color: var(--sg-text-muted);
+ opacity: 1;
+ font-size: 14px;
+}
+
+.sort-field {
+ width: 180px;
+}
+
+.table-wrap {
+ position: relative;
+ overflow-x: auto;
+}
+
+table {
+ width: 100%;
+ min-width: 600px;
+ border-collapse: separate;
+ border-spacing: 0 10px;
+ background: transparent;
+ box-shadow: none;
+}
+
+.article-title {
+ display: inline-block;
+ max-width: 520px;
+ line-height: 1.35;
+ color: var(--sg-text);
+ font-size: 14px;
+ font-weight: 700;
+ text-decoration: none;
+
+ &:hover {
+ color: var(--sg-text);
+ text-decoration: underline;
+ }
+}
+
+.loading {
+ position: absolute;
+ inset: 0;
+ z-index: 1;
+ display: grid;
+ place-items: center;
+ background: rgba(255, 255, 255, 0.65);
+}
+
+.empty-state {
+ padding: 28px;
+ text-align: center;
+ color: rgba(0, 0, 0, 0.6);
+ background: transparent;
+}
+
+.relevance-badge {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 5px 12px;
+ border-radius: 999px;
+ font-size: 13px;
+ font-weight: 600;
+ line-height: 1;
+ white-space: nowrap;
+
+ mat-icon {
+ font-size: 16px;
+ width: 16px;
+ height: 16px;
+ }
+
+ &.is-relevant {
+ background: #effaf3;
+ border: 1px solid #bdebcf;
+ color: #24834f;
+ }
+
+ &.not-relevant {
+ background: var(--sg-surface-muted);
+ border: 1px solid #e2e2e2;
+ color: var(--sg-text-muted);
+ }
+
+ &.undetermined {
+ background: #fff7e8;
+ border: 1px solid #ffd796;
+ color: #c67500;
+ }
+}
+
+::ng-deep .mat-mdc-header-cell {
+ color: var(--sg-text-muted);
+ font-size: 12px;
+ font-weight: 700;
+}
+
+::ng-deep .mat-mdc-row {
+ height: 72px;
+}
+
+::ng-deep .mat-mdc-cell {
+ color: var(--sg-text);
+ border-bottom-color: var(--sg-border);
+ font-size: 13px;
+}
+
+mat-paginator {
+ background: transparent;
+}
+
+.table-footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ min-height: 66px;
+ padding: 0 22px 0 28px;
+ color: var(--sg-text-muted);
+ font-size: 13px;
+}
+
+@media (max-width: 600px) {
+ .table-footer {
+ align-items: stretch;
+ flex-direction: column;
+ }
+}
diff --git a/webapp/src/app/shared/ui/news-list/news-list.component.ts b/webapp/src/app/shared/ui/news-list/news-list.component.ts
new file mode 100644
index 00000000..ceddb449
--- /dev/null
+++ b/webapp/src/app/shared/ui/news-list/news-list.component.ts
@@ -0,0 +1,95 @@
+import {
+ Component,
+ EventEmitter,
+ Input,
+ Output,
+ TemplateRef,
+ inject,
+} from '@angular/core';
+import { NgTemplateOutlet } from '@angular/common';
+import { FormControl, ReactiveFormsModule } from '@angular/forms';
+import { RouterLink } from '@angular/router';
+import { MatIconModule } from '@angular/material/icon';
+import { MatSelectModule } from '@angular/material/select';
+import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
+import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
+import { MatTableModule } from '@angular/material/table';
+import { MatFormFieldModule } from '@angular/material/form-field';
+import { MatInputModule } from '@angular/material/input';
+
+import { PaginationService } from '../../services/pagination.service';
+
+export interface NewsArticleBase {
+ id: string;
+ date?: string | null;
+ maintitle?: string | null;
+ url?: string | null;
+ relevant?: boolean | null;
+}
+
+export type SortOrder = 'desc' | 'asc';
+
+@Component({
+ selector: 'app-news-list',
+ imports: [
+ MatIconModule,
+ MatSelectModule,
+ MatFormFieldModule,
+ MatInputModule,
+ MatPaginatorModule,
+ MatProgressSpinnerModule,
+ MatTableModule,
+ NgTemplateOutlet,
+ ReactiveFormsModule,
+ RouterLink,
+ ],
+ templateUrl: './news-list.component.html',
+ styleUrl: './news-list.component.scss',
+})
+export class NewsListComponent {
+ readonly paginationService = inject(PaginationService);
+
+ @Input({ required: true }) articles: NewsArticleBase[] = [];
+ @Input({ required: true }) displayedColumns: string[] = [];
+ @Input() total = 0;
+ @Input() loading = false;
+ @Input() currentPage = 1;
+ @Input() sortOrder: SortOrder = 'desc';
+ @Input({ required: true }) searchControl!: FormControl;
+
+ @Input() extraColumnId: string | null = null;
+ @Input() extraColumnHeader = '';
+ @Input() extraColumnTemplate: TemplateRef<{
+ $implicit: NewsArticleBase;
+ }> | null = null;
+
+ @Output() sortChange = new EventEmitter();
+ @Output() pageChange = new EventEmitter();
+
+ get isSearching(): boolean {
+ return this.searchControl.value.trim().length > 0;
+ }
+
+ onSortChange(order: SortOrder): void {
+ this.sortChange.emit(order);
+ }
+
+ onPage(event: PageEvent): void {
+ this.pageChange.emit(event);
+ }
+
+ formatDate(dateStr?: string | null): string {
+ if (!dateStr) return '-';
+ const date = new Date(dateStr);
+ if (isNaN(date.getTime())) return dateStr;
+ return new Intl.DateTimeFormat('de-DE').format(date);
+ }
+
+ articleRange(): string {
+ if (this.total === 0) return 'Keine Nachrichten gefunden';
+ const pageSize = this.paginationService.selection;
+ const start = (this.currentPage - 1) * pageSize + 1;
+ const end = Math.min(start + this.articles.length - 1, this.total);
+ return `Zeige ${start} bis ${end} von ${this.total} Nachrichten`;
+ }
+}