import {Component, Input, Output, EventEmitter} from '@angular/core'; import{EnvProperties} from './properties/env-properties'; import {properties} from "../../../environments/environment"; @Component({ selector: 'paging-no-load', template: ` ` }) export class pagingFormatterNoLoad { @Input() public currentPage: number = 1; @Input() public customClasses: string = 'uk-flex-center'; @Input() public term: string=''; @Input() public size: number=10; @Input() public totalResults: number = 10; @Input() public limitPaging: boolean = false; @Output() pageChange = new EventEmitter(); public properties:EnvProperties = properties; private limit: number = this.properties.pagingLimit; @Input() public loading:boolean = false; getTotalPages(){ let total: number = 0; let i= this.totalResults/this.size; let integerI=parseInt(''+i); total = parseInt(''+((i==integerI)?i:i+1)); if(this.limitPaging) { if((this.currentPage == this.limit) && (total > this.limit)) { total = this.limit; } else if((this.currentPage > this.limit) && (total > this.limit)) { total = this.currentPage; } } return total; } onPrev(){ this.currentPage=this.currentPage-1; this.pageChange.emit({ value: this.currentPage }); } onNext(){ this.currentPage=this.currentPage+1; this.pageChange.emit({ value: this.currentPage }); } onPage(pageNum: number){ if(!this.loading) { this.currentPage = pageNum; this.pageChange.emit({ value: this.currentPage }); } } }