UNPKG

@itexpert-dev/base-universal-table

Version:

base universal table for build tables

53 lines 2.48 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var baseUniversalTableComponent_1 = require("../common/baseUniversalTableComponent"); var tiny_helpers_1 = require("@itexpert-dev/tiny-helpers"); var BaseUniversalTablePaginator = (function (_super) { __extends(BaseUniversalTablePaginator, _super); function BaseUniversalTablePaginator(tableCtrl) { var _this = _super.call(this, tableCtrl) || this; _this.page = null; _this.limitSteps = _this.tableCtrl.config.getDefaultLimitSteps(); var stateStream = _this.tableCtrl.stateStream; stateStream.filter(function (next) { return next.hasOwnProperty('offset'); }) .subscribe(function (next) { _this.offset = next.offset; }); stateStream.filter(function (next) { return next.hasOwnProperty('limit'); }) .subscribe(function (next) { _this.limit = next.limit; }); stateStream.filter(function (next) { return next.hasOwnProperty('totalResult'); }) .subscribe(function (next) { _this.count = next.totalResult; }); return _this; } BaseUniversalTablePaginator.prototype.changeLimit = function (newValue) { this.limit = parseInt(newValue); this.changePage(1); }; BaseUniversalTablePaginator.prototype.changePage = function (newPage) { if (!tiny_helpers_1.isNullOrUndefined(this.limit)) { this.page = newPage; this.offset = ((newPage - 1) * this.limit); this.tableCtrl.updateState({ offset: this.offset, limit: this.limit }).subscribe(); } }; return BaseUniversalTablePaginator; }(baseUniversalTableComponent_1.BaseUniversalTableComponent)); exports.BaseUniversalTablePaginator = BaseUniversalTablePaginator; //# sourceMappingURL=BaseUniversalTablePaginator.js.map