Improve funding view pagination and UI styling
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
2026-06-03 09:14:46 +02:00
parent b2996b07c6
commit fd09c5e08c
3 changed files with 177 additions and 39 deletions
@@ -5,16 +5,16 @@
} @else if (funders.length === 0) {
<p class="message">Keine Förderungen gefunden.</p>
} @else {
<div class="summary-card">
<span class="summary-label">Einzigartige Publikationen: </span>
<span class="summary-value">{{ getUniquePublicationCount() }}</span>
</div>
<div class="funding-summary">
<div class="summary-card">
<span class="summary-label">Förderer: </span>
<span class="summary-value">{{ filteredFunders.length }}</span>
<p class="summary-line">
<span class="summary-label">Einzigartige Publikationen: </span>
<span class="summary-value">{{ getUniquePublicationCount() }}</span>
</p>
<p class="summary-line">
<span class="summary-label">Förderer: </span>
<span class="summary-value">{{ filteredFunders.length }}</span>
</p>
</div>
</div>
<div class="funding-container">
@@ -40,7 +40,7 @@
</tr>
</thead>
<tbody>
@for (funder of filteredFunders; track funder.funder_id) {
@for (funder of getPagedFunders(); track funder.funder_id) {
<tr
[class.selected]="selectedFunder === funder"
(click)="selectFunder(funder)"
@@ -51,6 +51,17 @@
}
</tbody>
</table>
@if (hasFunderListPagination()) {
<div class="publication-pagination">
<button [disabled]="selectedFunderListPage === 1" (click)="setFunderListPage(selectedFunderListPage - 1)">
Zurück
</button>
<span>Seite {{ selectedFunderListPage }} von {{ getFunderListPageCount() }}</span>
<button [disabled]="selectedFunderListPage === getFunderListPageCount()" (click)="setFunderListPage(selectedFunderListPage + 1)">
Weiter
</button>
</div>
}
</div>
<!-- Rechte Seite: Details -->
@@ -81,12 +92,23 @@
<h4>Publikationen</h4>
<ul class="publication-list">
@for (id of getPublicationIds(selectedFunder); track id) {
@for (id of getSelectedPublicationIdsPage(); track id) {
<li>
<a [href]="id" target="_blank" rel="noopener" (click)="openPublication($event, id)">{{ id }}</a>
</li>
}
</ul>
@if (hasPublicationPagination()) {
<div class="publication-pagination">
<button [disabled]="selectedPublicationPage === 1" (click)="setPublicationPage(selectedPublicationPage - 1)">
Zurück
</button>
<span>Seite {{ selectedPublicationPage }} von {{ getSelectedPublicationPageCount() }}</span>
<button [disabled]="selectedPublicationPage === getSelectedPublicationPageCount()" (click)="setPublicationPage(selectedPublicationPage + 1)">
Weiter
</button>
</div>
}
</div>
} @else {
<div class="funding-detail empty">
@@ -35,9 +35,13 @@
}
&.active {
background: #3f51b5;
color: white;
border-color: #3f51b5;
background:
radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.78), transparent 34%),
linear-gradient(145deg, #c8d9ff, #f7faff 48%, #88a9ee);
color: var(--sg-primary);
border-color: var(--sg-border);
font-weight: 600;
box-shadow: var(--sg-shadow-sm);
}
}
}
@@ -72,7 +76,7 @@
}
&.selected {
background: #e8eaf6;
background: #f0f0f0;
}
}
@@ -82,7 +86,7 @@
}
.funder-name {
color: #3f51b5;
color: #333;
font-weight: 500;
}
}
@@ -140,7 +144,7 @@
display: block;
font-size: 22px;
font-weight: bold;
color: #3f51b5;
color: #333;
}
}
}
@@ -158,40 +162,60 @@
font-size: 13px;
a {
color: #3f51b5;
color: #2563eb;
text-decoration: none;
word-break: break-all;
&:hover {
color: #1d4ed8;
text-decoration: underline;
}
}
}
.funding-summary {
}
.publication-pagination {
display: flex;
gap: 16px;
margin-bottom: 16px;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: 12px;
.summary-card {
background: #e8eaf6;
border-radius: 8px;
padding: 16px 24px;
text-align: center;
min-width: 150px;
button {
padding: 4px 10px;
border: 1px solid #d0d0d0;
border-radius: 6px;
background: white;
cursor: pointer;
font-size: 12px;
.summary-value {
display: block;
font-size: 32px;
font-weight: bold;
color: #3f51b5;
}
.summary-label {
display: block;
font-size: 14px;
color: #555;
margin-top: 4px;
&:disabled {
opacity: 0.5;
cursor: default;
}
}
span {
font-size: 12px;
color: #666;
}
}
.funding-summary {
margin-bottom: 16px;
.summary-line {
margin: 0 0 4px 0;
font-size: 14px;
color: #333;
}
.summary-label {
color: #333;
}
.summary-value {
font-weight: 600;
color: #333;
}
}
@@ -15,11 +15,17 @@ export class PersonFundingComponent implements OnInit {
private router = inject(Router);
private personsApi = inject(PersonsOpenApiService);
private initialSelectedFunderKey: string | null = null;
private initialPublicationPage = 1;
private initialFunderListPage = 1;
private publicationUrlCache = new Map<string, string>();
funders: any[] = [];
filteredFunders: any[] = [];
selectedFunder: any = null;
selectedFunderListPage = 1;
selectedPublicationPage = 1;
readonly funderListPageSize = 10;
readonly publicationPageSize = 10;
activeFilter: 'all' | 'first' | 'middle' | 'last' = 'all';
loading = true;
error = false;
@@ -28,6 +34,10 @@ export class PersonFundingComponent implements OnInit {
const authorId = this.route.parent?.snapshot.paramMap.get('id') ?? '';
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
this.initialSelectedFunderKey = this.route.snapshot.queryParamMap.get('funder');
this.initialPublicationPage = this.parsePageParam(
this.route.snapshot.queryParamMap.get('publicationPage') ?? this.route.snapshot.queryParamMap.get('page')
);
this.initialFunderListPage = this.parsePageParam(this.route.snapshot.queryParamMap.get('funderPage'));
if (this.isValidFilter(filterFromUrl)) {
this.activeFilter = filterFromUrl;
}
@@ -37,6 +47,7 @@ export class PersonFundingComponent implements OnInit {
next: (result) => {
this.funders = result.funders ?? [];
this.applyFilter();
this.selectedFunderListPage = this.clampPage(this.initialFunderListPage, this.getFunderListPageCount());
this.restoreSelectedFunderFromUrl();
this.loading = false;
},
@@ -50,6 +61,7 @@ export class PersonFundingComponent implements OnInit {
selectFunder(funder: any): void {
this.selectedFunder = funder;
this.selectedPublicationPage = 1;
this.updateQueryParams();
}
@@ -61,6 +73,8 @@ export class PersonFundingComponent implements OnInit {
private applyFilter(): void {
this.selectedFunder = null;
this.selectedFunderListPage = 1;
this.selectedPublicationPage = 1;
if (this.activeFilter === 'all') {
this.filteredFunders = this.funders;
} else {
@@ -81,6 +95,17 @@ export class PersonFundingComponent implements OnInit {
if (matchedFunder) {
this.selectedFunder = matchedFunder;
const matchedIndex = this.filteredFunders.findIndex(
(funder: any) => this.getFunderKey(funder) === this.getFunderKey(matchedFunder)
);
if (matchedIndex >= 0) {
this.selectedFunderListPage = Math.floor(matchedIndex / this.funderListPageSize) + 1;
}
this.selectedPublicationPage = this.clampPublicationPage(
this.initialPublicationPage,
this.getPublicationPageCountForFunder(matchedFunder),
);
this.updateQueryParams();
} else {
this.updateQueryParams();
}
@@ -91,7 +116,9 @@ export class PersonFundingComponent implements OnInit {
relativeTo: this.route,
queryParams: {
filter: this.activeFilter,
funder: this.selectedFunder ? this.getFunderKey(this.selectedFunder) : null
funder: this.selectedFunder ? this.getFunderKey(this.selectedFunder) : null,
publicationPage: this.selectedFunder ? this.selectedPublicationPage : null,
funderPage: this.selectedFunderListPage
},
queryParamsHandling: 'merge',
replaceUrl: true
@@ -125,6 +152,50 @@ export class PersonFundingComponent implements OnInit {
return funder.publication_ids[this.activeFilter] ?? [];
}
getPagedFunders(): any[] {
const startIndex = (this.selectedFunderListPage - 1) * this.funderListPageSize;
return this.filteredFunders.slice(startIndex, startIndex + this.funderListPageSize);
}
hasFunderListPagination(): boolean {
return this.getFunderListPageCount() > 1;
}
getFunderListPageCount(): number {
return Math.max(1, Math.ceil(this.filteredFunders.length / this.funderListPageSize));
}
setFunderListPage(page: number): void {
this.selectedFunderListPage = this.clampPage(page, this.getFunderListPageCount());
this.updateQueryParams();
}
getSelectedPublicationIdsPage(): string[] {
if (!this.selectedFunder) {
return [];
}
const allPublicationIds = this.getPublicationIds(this.selectedFunder);
const startIndex = (this.selectedPublicationPage - 1) * this.publicationPageSize;
return allPublicationIds.slice(startIndex, startIndex + this.publicationPageSize);
}
hasPublicationPagination(): boolean {
return this.getSelectedPublicationPageCount() > 1;
}
getSelectedPublicationPageCount(): number {
if (!this.selectedFunder) {
return 1;
}
return this.getPublicationPageCountForFunder(this.selectedFunder);
}
setPublicationPage(page: number): void {
const totalPages = this.getSelectedPublicationPageCount();
this.selectedPublicationPage = this.clampPublicationPage(page, totalPages);
this.updateQueryParams();
}
async openPublication(event: MouseEvent, publicationId: string): Promise<void> {
event.preventDefault();
const url = await this.resolvePreferredPublicationUrl(publicationId);
@@ -198,4 +269,25 @@ export class PersonFundingComponent implements OnInit {
return fallbackUrl;
}
}
private getPublicationPageCountForFunder(funder: any): number {
const publicationCount = this.getPublicationIds(funder).length;
return Math.max(1, Math.ceil(publicationCount / this.publicationPageSize));
}
private clampPublicationPage(page: number, totalPages: number): number {
return this.clampPage(page, totalPages);
}
private clampPage(page: number, totalPages: number): number {
return Math.min(Math.max(page, 1), totalPages);
}
private parsePageParam(value: string | null): number {
const parsed = Number(value);
if (!Number.isInteger(parsed) || parsed < 1) {
return 1;
}
return parsed;
}
}