UNPKG

ng2-bs-table

Version:
45 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var order_event_1 = require("./events/order-event"); var order_by_pipe_1 = require("./pipes/order-by.pipe"); var TableViewSorting = (function () { function TableViewSorting(column, descending) { this.column = column; this.descending = descending; this.sort = new core_1.EventEmitter(); } TableViewSorting.prototype.onEventSort = function () { return this.sort; }; TableViewSorting.prototype.does = function (column) { if (!column.sortable) return; if (this.column == column.variable) { this.descending = !this.descending; } else { this.column = column.variable; this.descending = false; } this.sort.emit(new order_event_1.OrderEvent(this.column, this.descending)); }; TableViewSorting.prototype.orderBy = function () { return { id: 'sorting', priority: 5, params: { pipe: new order_by_pipe_1.OrderByPipe(), args: this.descending ? '-' + this.column : this.column } }; }; TableViewSorting.prototype.getClass = function (column) { if (!column.sortable) return 'ui-not-sortable'; return column.variable == this.column ? 'sort-' + (this.descending ? 'desc' : 'asc') : ''; }; return TableViewSorting; }()); exports.TableViewSorting = TableViewSorting; //# sourceMappingURL=table-view-sorting.js.map