From fd09c5e08c5d4e9be783c6c88be8c1845424f95b Mon Sep 17 00:00:00 2001 From: taguesokoudjou Date: Wed, 3 Jun 2026 09:14:46 +0200 Subject: [PATCH] Improve funding view pagination and UI styling --- .../person-funding.component.html | 42 +++++++-- .../person-funding.component.scss | 80 ++++++++++------ .../person-funding.component.ts | 94 ++++++++++++++++++- 3 files changed, 177 insertions(+), 39 deletions(-) diff --git a/webapp/src/app/modules/person-funding/person-funding.component.html b/webapp/src/app/modules/person-funding/person-funding.component.html index 8469b157..a93080b6 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.html +++ b/webapp/src/app/modules/person-funding/person-funding.component.html @@ -5,16 +5,16 @@ } @else if (funders.length === 0) {

Keine Förderungen gefunden.

} @else { -
- Einzigartige Publikationen: - {{ getUniquePublicationCount() }} -
-
- Förderer: - {{ filteredFunders.length }} +

+ Einzigartige Publikationen: + {{ getUniquePublicationCount() }} +

+

+ Förderer: + {{ filteredFunders.length }} +

-
@@ -40,7 +40,7 @@ - @for (funder of filteredFunders; track funder.funder_id) { + @for (funder of getPagedFunders(); track funder.funder_id) { + @if (hasFunderListPagination()) { +
+ + Seite {{ selectedFunderListPage }} von {{ getFunderListPageCount() }} + +
+ }
@@ -81,12 +92,23 @@

Publikationen

+ @if (hasPublicationPagination()) { +
+ + Seite {{ selectedPublicationPage }} von {{ getSelectedPublicationPageCount() }} + +
+ } } @else {
diff --git a/webapp/src/app/modules/person-funding/person-funding.component.scss b/webapp/src/app/modules/person-funding/person-funding.component.scss index f9337e9d..b9f511c9 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.scss +++ b/webapp/src/app/modules/person-funding/person-funding.component.scss @@ -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; + } } diff --git a/webapp/src/app/modules/person-funding/person-funding.component.ts b/webapp/src/app/modules/person-funding/person-funding.component.ts index 76861ca0..5e9662ea 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.ts +++ b/webapp/src/app/modules/person-funding/person-funding.component.ts @@ -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(); 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 { 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; + } }