UNPKG

ferngully-aurelia-tools

Version:

Ferngully Tools for Aurelia

91 lines 4.42 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { SortDataType } from "../resources/valueConverters/sort"; import { computedFrom, transient, inject } from "aurelia-framework"; var SortColumnService = (function () { function SortColumnService() { this.columns = new Map(); this.toggleDirection = true; this.sortEnabled = true; } Object.defineProperty(SortColumnService.prototype, "currentSortColumn", { get: function () { return this._currentSortColumn ? this._currentSortColumn : this.columns.values().next().value; }, set: function (columnSortState) { if (columnSortState) { this._currentSortColumn = Object.assign({}, columnSortState); Object.defineProperty(this._currentSortColumn, "sortEnabled", Object.getOwnPropertyDescriptor(Object.getPrototypeOf(columnSortState), "sortEnabled")); } else { this._currentSortColumn = undefined; } }, enumerable: true, configurable: true }); SortColumnService.prototype.registerColumnState = function (descending, columnName, valueResolver, dataType, setToDefault, tieBreakerColumnName, tieBreakerDataType, ordinalPositionPropertyName) { if (!this.columns.has(columnName)) { var columnState = new ColumnState(columnName, valueResolver, this, descending, dataType, tieBreakerColumnName, tieBreakerDataType, ordinalPositionPropertyName); this.columns.set(columnName, columnState); if (setToDefault) { this.currentSortColumn = columnState; } } return this; }; SortColumnService.prototype.setSort = function (columnName) { if (!this.sortEnabled) { return; } var column = this.columns.get(columnName); if (column) { var changingColumn = (!this.currentSortColumn) || (this.currentSortColumn.columnName !== columnName); var toggleDirection = this.toggleDirection && !changingColumn; if (toggleDirection) { column.descending = !column.descending; } this.currentSortColumn = column; } }; __decorate([ computedFrom("_currentSortColumn"), __metadata("design:type", Object), __metadata("design:paramtypes", [Object]) ], SortColumnService.prototype, "currentSortColumn", null); SortColumnService = __decorate([ transient(), inject() ], SortColumnService); return SortColumnService; }()); export { SortColumnService }; var ColumnState = (function () { function ColumnState(columnName, valueResolver, sortColumnService, descending, dataType, tieBreakerColumnName, tieBreakerDataType, ordinalPositionPropertyName) { this.columnName = columnName; this.valueResolver = valueResolver; this.descending = descending; this.dataType = dataType ? dataType : SortDataType.number; this.tieBreakerColumnName = tieBreakerColumnName; this.tieBreakerDataType = tieBreakerDataType; this.ordinalPositionPropertyName = ordinalPositionPropertyName; this.sortColumnService = sortColumnService; } Object.defineProperty(ColumnState.prototype, "sortEnabled", { get: function () { return this.sortColumnService.sortEnabled; }, enumerable: true, configurable: true }); return ColumnState; }()); export { SortDataType } from "../resources/valueConverters/sort"; //# sourceMappingURL=sort-column-service.js.map