1 import {Component, OnInit, Input} from '@angular/core';
2 import {CatalogService} from '@eg/share/catalog/catalog.service';
3 import {CatalogSearchContext} from '@eg/share/catalog/search-context';
4 import {StaffCatalogService} from '../catalog.service';
7 selector: 'eg-catalog-result-pagination',
8 styleUrls: ['pagination.component.css'],
9 templateUrl: 'pagination.component.html'
11 export class ResultPaginationComponent implements OnInit {
13 searchContext: CatalogSearchContext;
15 // Maximum number of jump-to-page buttons displayed.
16 @Input() numPages: number;
19 private cat: CatalogService,
20 private staffCat: StaffCatalogService
26 this.searchContext = this.staffCat.searchContext;
29 currentPageList(): number[] {
30 const pgr = this.searchContext.pager;
31 return pgr.pageRange(pgr.currentPage(), this.numPages);
35 this.searchContext.pager.increment();
36 this.staffCat.search();
40 this.searchContext.pager.decrement();
41 this.staffCat.search();
44 setPage(page: number): void {
45 if (this.searchContext.pager.currentPage() === page) { return; }
46 this.searchContext.pager.setPage(page);
47 this.staffCat.search();