return pages;
}
+ // Returns a list of pages numbers with @pivot at the center
+ // or as close to center as possible.
+ // @pivot is 1-based for consistency with page numbers.
+ // pageRange(25, 10) => [21,22,...29,30]
+ pageRange(pivot: number, size: number): number[] {
+
+ const diff = Math.floor(size / 2);
+ let start = pivot <= diff ? 1 : pivot - diff + 1;
+
+ const pcount = this.pageCount();
+
+ if (start + size > pcount) {
+ start = pcount - size + 1;
+ if (start < 1) { start = 1 };
+ }
+
+ if (start + size > pcount) {
+ size = pcount;
+ }
+
+ return this.pageList().slice(start - 1, start - 1 + size);
+ }
+
pageList(): number[] {
const list = [];
for (let i = 1; i <= this.pageCount(); i++) {
</a>
</li>
<li class="page-item"
- *ngFor="let page of searchContext.pager.pageList()"
+ *ngFor="let page of currentPageList()"
[ngClass]="{active : searchContext.pager.currentPage() == page}">
<a class="page-link" (click)="setPage(page)">
{{page}} <span class="sr-only" i18n>(current)</span></a>
searchContext: CatalogSearchContext;
+ // Maximum number of jump-to-page buttons displayed.
+ @Input() numPages: number;
+
constructor(
private cat: CatalogService,
private staffCat: StaffCatalogService
- ) {}
+ ) {
+ this.numPages = 10;
+ }
ngOnInit() {
this.searchContext = this.staffCat.searchContext;
}
+ currentPageList(): number[] {
+ const pgr = this.searchContext.pager;
+ return pgr.pageRange(pgr.currentPage(), this.numPages);
+ }
+
nextPage(): void {
this.searchContext.pager.increment();
this.staffCat.search();
<div class="row pt-2">
<div class="col-lg-12">
<!-- only shows the first icon format -->
- <span *ngIf="summary.attributes.icon_format[0]">
+ <span *ngIf="summary.attributes.icon_format && summary.attributes.icon_format[0]">
<img class="pr-1"
src="/images/format_icons/icon_format/{{summary.attributes.icon_format[0]}}.png"/>
<span>{{iconFormatLabel(summary.attributes.icon_format[0])}}</span>