Implement pagination for author list in persons results

This commit is contained in:
Steven Tischer
2026-07-16 20:58:55 +02:00
parent afd45a98bd
commit 3609376c78
2 changed files with 24 additions and 1 deletions
@@ -24,7 +24,7 @@
</button>
</div>
<ul class="author-list">
@for (author of authors(); track author.author_id) {
@for (author of paginatedAuthors(); track author.author_id) {
<li class="author-item">
<mat-checkbox
class="author-select"
@@ -41,6 +41,8 @@
</li>
}
</ul>
<app-query-param-paginator [total]="authors().length" />
}
</mat-card-content>
</mat-card>
@@ -1,4 +1,5 @@
import { Component, OnInit, computed, inject, signal } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { DecimalPipe } from '@angular/common';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
@@ -15,6 +16,7 @@ import {
WeightsSlidersComponent,
WeightsSlidersValue,
} from '../../../../shared/ui/weights-sliders/weights-sliders.component';
import { QueryParamPaginatorComponent } from '../../../../shared/ui/query-param-paginator/query-param-paginator.component';
import {
KeywordToAuthorRequest,
@@ -35,6 +37,7 @@ import { SearchResultsStateService } from '../search-results-state.service';
MatCheckboxModule,
MatIconModule,
MatSliderModule,
QueryParamPaginatorComponent,
WeightsSlidersComponent,
],
templateUrl: './persons-results.component.html',
@@ -48,6 +51,24 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
private readonly router = inject(Router);
private readonly snackBar = inject(MatSnackBar);
private readonly queryParams = toSignal(this.route.queryParams);
readonly pageIndex = computed(() => {
const p = this.queryParams();
return p && p['page'] ? +p['page'] || 0 : 0;
});
readonly pageSize = computed(() => {
const p = this.queryParams();
return p && p['size'] ? +p['size'] || 10 : 10;
});
readonly paginatedAuthors = computed(() => {
const all = this.authors();
const start = this.pageIndex() * this.pageSize();
return all.slice(start, start + this.pageSize());
});
// author selection for the compare view (max 4)
readonly MAX_SELECTED = 4;
readonly selectedIds = signal<string[]>([]);