Implement pagination for author list in persons results
This commit is contained in:
+3
-1
@@ -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>
|
||||
|
||||
+21
@@ -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[]>([]);
|
||||
|
||||
Reference in New Issue
Block a user