UNPKG

@neoprospecta/angular-data-box

Version:

Data table with REST implementation.

48 lines 2.35 kB
import { Component, Output, Input, EventEmitter } from '@angular/core'; var Paginator = (function () { function Paginator() { this.pageChanged = new EventEmitter(); } Paginator.prototype.ngDoCheck = function () { this.totalOfPagesRoundedUp = Math.ceil(this.totalItems / this.amountPerPage); // arredonda pra cima this.totalOfPagesRoundedDown = Math.floor(this.totalItems / this.amountPerPage); // arredonda pra baixo }; Paginator.prototype.emitPageChange = function (direction) { this.pageChanged.emit({ event: direction }); }; Paginator.prototype.getCurrentPages = function () { if (this.totalItems === 0) { return '0'; } return this.getFirstPageIndex() + ' - ' + this.getLastPageIndex(); }; Paginator.prototype.getFirstPageIndex = function () { return ((this.currentPage - 1) * this.amountPerPage) + 1; }; Paginator.prototype.getLastPageIndex = function () { if ((this.currentPage === this.totalOfPagesRoundedUp) && (this.totalOfPagesRoundedDown < this.totalOfPagesRoundedUp)) { return this.totalItems; } else { return (this.currentPage * this.amountPerPage); } }; Paginator.decorators = [ { type: Component, args: [{ selector: 'np-paginator', styles: [".pagination{float:right} "], template: "<div class=\"pagination\"> <span>{{getCurrentPages()}} de {{totalItems}}</span> <button md-icon-button (click)=\"emitPageChange('left')\" [disabled]=\"currentPage === 1\"> <md-icon fontSet=\"fa\" fontIcon=\"fa-angle-left\" color=\"primary\"></md-icon> </button> <button md-icon-button (click)=\"emitPageChange('right')\" [disabled]=\"currentPage === totalOfPagesRoundedUp\"> <md-icon fontSet=\"fa\" fontIcon=\"fa-angle-right\" color=\"primary\"></md-icon> </button> </div> " },] }, ]; /** @nocollapse */ Paginator.ctorParameters = function () { return []; }; Paginator.propDecorators = { 'totalItems': [{ type: Input },], 'currentPage': [{ type: Input },], 'amountPerPage': [{ type: Input },], 'pageChanged': [{ type: Output },], }; return Paginator; }()); export { Paginator }; //# sourceMappingURL=paginator.component.js.map