diff --git a/dist/amd/au-table-select.js b/dist/amd/au-table-select.js index 8976fda..7d745a0 100644 --- a/dist/amd/au-table-select.js +++ b/dist/amd/au-table-select.js @@ -73,8 +73,8 @@ define(["exports", "aurelia-framework", "./au-table"], function (exports, _aurel this.element = element; this.bindingEngine = bindingEngine; - this.rowSelectedListener = function (e) { - _this.handleRowSelected(e); + this.rowSelectedListener = function (event) { + _this.handleRowSelected(event); }; } @@ -84,7 +84,7 @@ define(["exports", "aurelia-framework", "./au-table"], function (exports, _aurel this.element.style.cursor = 'pointer'; this.element.addEventListener('click', this.rowSelectedListener); - this.selectedSubscription = this.bindingEngine.propertyObserver(this.row, '$IsSelected').subscribe(function () { + this.selectedSubscription = this.bindingEngine.propertyObserver(this.row, '$isSelected').subscribe(function () { return _this2.isSelectedChanged(); }); @@ -97,14 +97,14 @@ define(["exports", "aurelia-framework", "./au-table"], function (exports, _aurel }; AutSelectCustomAttribute.prototype.setClass = function setClass() { - if (this.row.$IsSelected) { + if (this.row.$isSelected) { this.element.classList.add(this.selectedClass); } else { this.element.classList.remove(this.selectedClass); } }; - AutSelectCustomAttribute.prototype.handleRowSelected = function handleRowSelected(e) { + AutSelectCustomAttribute.prototype.handleRowSelected = function handleRowSelected(event) { var source = event.target || event.srcElement; if (source.tagName.toLowerCase() !== 'td') { return; @@ -114,16 +114,16 @@ define(["exports", "aurelia-framework", "./au-table"], function (exports, _aurel this.deselectAll(); } - this.row.$IsSelected = this.row.$IsSelected ? false : true; + this.row.$isSelected = this.row.$isSelected ? false : true; this.setClass(); - if (this.row.$IsSelected) { + if (this.row.$isSelected) { this.dispatchSelectedEvent(); } }; AutSelectCustomAttribute.prototype.dispatchSelectedEvent = function dispatchSelectedEvent() { - var selectedEvent = {}; + var selectedEvent = void 0; if (window.CustomEvent) { selectedEvent = new CustomEvent('select', { detail: { row: this.row }, @@ -140,6 +140,10 @@ define(["exports", "aurelia-framework", "./au-table"], function (exports, _aurel AutSelectCustomAttribute.prototype.isSelectedChanged = function isSelectedChanged() { this.setClass(); + + if (this.row.$isSelected) { + dispatchSelectedEvent(); + } }; AutSelectCustomAttribute.prototype.deselectAll = function deselectAll() { @@ -147,7 +151,7 @@ define(["exports", "aurelia-framework", "./au-table"], function (exports, _aurel this.auTable.data.forEach(function (item) { if (item !== _this3.row) { - item.$IsSelected = false; + item.$isSelected = false; } }); }; diff --git a/dist/amd/au-table.js b/dist/amd/au-table.js index 610dd1c..32a90f9 100644 --- a/dist/amd/au-table.js +++ b/dist/amd/au-table.js @@ -55,9 +55,9 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) { throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.'); } - var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7; + var _dec, _dec2, _dec3, _dec4, _dec5, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8; - var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = (0, _aureliaFramework.inject)(_aureliaFramework.BindingEngine), _dec2 = (0, _aureliaFramework.bindable)({ defaultBindingMode: _aureliaFramework.bindingMode.twoWay }), _dec3 = (0, _aureliaFramework.bindable)({ defaultBindingMode: _aureliaFramework.bindingMode.twoWay }), _dec4 = (0, _aureliaFramework.bindable)({ defaultBindingMode: _aureliaFramework.bindingMode.twoWay }), _dec(_class = (_class2 = function () { + var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = (0, _aureliaFramework.inject)(_aureliaFramework.BindingEngine), _dec2 = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), _dec3 = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), _dec4 = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), _dec5 = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), _dec(_class = (_class2 = function () { function AureliaTableCustomAttribute(bindingEngine) { _classCallCheck(this, AureliaTableCustomAttribute); @@ -75,8 +75,11 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) { _initDefineProp(this, "totalItems", _descriptor7, this); + _initDefineProp(this, "api", _descriptor8, this); + this.isAttached = false; this.sortChangedListeners = []; + this.beforePagination = []; this.bindingEngine = bindingEngine; } @@ -89,6 +92,12 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) { return _this.applyPlugins(); }); } + + this.api = { + revealItem: function revealItem(item) { + return _this.revealItem(item); + } + }; }; AureliaTableCustomAttribute.prototype.attached = function attached() { @@ -146,6 +155,7 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) { this.totalItems = localData.length; if (this.hasPagination()) { + this.beforePagination = [].concat(localData); localData = this.doPaginate(localData); } @@ -207,8 +217,8 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) { var val2 = void 0; if (typeof sortKey === "function") { - val1 = sortKey(a); - val2 = sortKey(b); + val1 = sortKey(a, sortOrder); + val2 = sortKey(b, sortOrder); } else { val1 = a[sortKey]; val2 = b[sortKey]; @@ -308,6 +318,22 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) { } }; + AureliaTableCustomAttribute.prototype.revealItem = function revealItem(item) { + if (!this.hasPagination()) { + return true; + } + + var index = this.beforePagination.indexOf(item); + + if (index === -1) { + return false; + } + + this.currentPage = Math.ceil((index + 1) / this.pageSize); + + return true; + }; + return AureliaTableCustomAttribute; }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [_aureliaFramework.bindable], { enumerable: true, @@ -330,5 +356,8 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) { }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], { enumerable: true, initializer: null + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], { + enumerable: true, + initializer: null })), _class2)) || _class); }); \ No newline at end of file diff --git a/dist/commonjs/au-table-select.js b/dist/commonjs/au-table-select.js index 007447d..86d0e20 100644 --- a/dist/commonjs/au-table-select.js +++ b/dist/commonjs/au-table-select.js @@ -72,8 +72,8 @@ var AutSelectCustomAttribute = exports.AutSelectCustomAttribute = (_dec = (0, _a this.element = element; this.bindingEngine = bindingEngine; - this.rowSelectedListener = function (e) { - _this.handleRowSelected(e); + this.rowSelectedListener = function (event) { + _this.handleRowSelected(event); }; } @@ -83,7 +83,7 @@ var AutSelectCustomAttribute = exports.AutSelectCustomAttribute = (_dec = (0, _a this.element.style.cursor = 'pointer'; this.element.addEventListener('click', this.rowSelectedListener); - this.selectedSubscription = this.bindingEngine.propertyObserver(this.row, '$IsSelected').subscribe(function () { + this.selectedSubscription = this.bindingEngine.propertyObserver(this.row, '$isSelected').subscribe(function () { return _this2.isSelectedChanged(); }); @@ -96,14 +96,14 @@ var AutSelectCustomAttribute = exports.AutSelectCustomAttribute = (_dec = (0, _a }; AutSelectCustomAttribute.prototype.setClass = function setClass() { - if (this.row.$IsSelected) { + if (this.row.$isSelected) { this.element.classList.add(this.selectedClass); } else { this.element.classList.remove(this.selectedClass); } }; - AutSelectCustomAttribute.prototype.handleRowSelected = function handleRowSelected(e) { + AutSelectCustomAttribute.prototype.handleRowSelected = function handleRowSelected(event) { var source = event.target || event.srcElement; if (source.tagName.toLowerCase() !== 'td') { return; @@ -113,16 +113,16 @@ var AutSelectCustomAttribute = exports.AutSelectCustomAttribute = (_dec = (0, _a this.deselectAll(); } - this.row.$IsSelected = this.row.$IsSelected ? false : true; + this.row.$isSelected = this.row.$isSelected ? false : true; this.setClass(); - if (this.row.$IsSelected) { + if (this.row.$isSelected) { this.dispatchSelectedEvent(); } }; AutSelectCustomAttribute.prototype.dispatchSelectedEvent = function dispatchSelectedEvent() { - var selectedEvent = {}; + var selectedEvent = void 0; if (window.CustomEvent) { selectedEvent = new CustomEvent('select', { detail: { row: this.row }, @@ -139,6 +139,10 @@ var AutSelectCustomAttribute = exports.AutSelectCustomAttribute = (_dec = (0, _a AutSelectCustomAttribute.prototype.isSelectedChanged = function isSelectedChanged() { this.setClass(); + + if (this.row.$isSelected) { + dispatchSelectedEvent(); + } }; AutSelectCustomAttribute.prototype.deselectAll = function deselectAll() { @@ -146,7 +150,7 @@ var AutSelectCustomAttribute = exports.AutSelectCustomAttribute = (_dec = (0, _a this.auTable.data.forEach(function (item) { if (item !== _this3.row) { - item.$IsSelected = false; + item.$isSelected = false; } }); }; diff --git a/dist/commonjs/au-table.js b/dist/commonjs/au-table.js index 90c2d55..4fce0e1 100644 --- a/dist/commonjs/au-table.js +++ b/dist/commonjs/au-table.js @@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.AureliaTableCustomAttribute = undefined; -var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7; +var _dec, _dec2, _dec3, _dec4, _dec5, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8; var _aureliaFramework = require("aurelia-framework"); @@ -54,7 +54,7 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.'); } -var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = (0, _aureliaFramework.inject)(_aureliaFramework.BindingEngine), _dec2 = (0, _aureliaFramework.bindable)({ defaultBindingMode: _aureliaFramework.bindingMode.twoWay }), _dec3 = (0, _aureliaFramework.bindable)({ defaultBindingMode: _aureliaFramework.bindingMode.twoWay }), _dec4 = (0, _aureliaFramework.bindable)({ defaultBindingMode: _aureliaFramework.bindingMode.twoWay }), _dec(_class = (_class2 = function () { +var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = (0, _aureliaFramework.inject)(_aureliaFramework.BindingEngine), _dec2 = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), _dec3 = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), _dec4 = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), _dec5 = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), _dec(_class = (_class2 = function () { function AureliaTableCustomAttribute(bindingEngine) { _classCallCheck(this, AureliaTableCustomAttribute); @@ -72,8 +72,11 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = _initDefineProp(this, "totalItems", _descriptor7, this); + _initDefineProp(this, "api", _descriptor8, this); + this.isAttached = false; this.sortChangedListeners = []; + this.beforePagination = []; this.bindingEngine = bindingEngine; } @@ -86,6 +89,12 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = return _this.applyPlugins(); }); } + + this.api = { + revealItem: function revealItem(item) { + return _this.revealItem(item); + } + }; }; AureliaTableCustomAttribute.prototype.attached = function attached() { @@ -143,6 +152,7 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = this.totalItems = localData.length; if (this.hasPagination()) { + this.beforePagination = [].concat(localData); localData = this.doPaginate(localData); } @@ -204,8 +214,8 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = var val2 = void 0; if (typeof sortKey === "function") { - val1 = sortKey(a); - val2 = sortKey(b); + val1 = sortKey(a, sortOrder); + val2 = sortKey(b, sortOrder); } else { val1 = a[sortKey]; val2 = b[sortKey]; @@ -305,6 +315,22 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = } }; + AureliaTableCustomAttribute.prototype.revealItem = function revealItem(item) { + if (!this.hasPagination()) { + return true; + } + + var index = this.beforePagination.indexOf(item); + + if (index === -1) { + return false; + } + + this.currentPage = Math.ceil((index + 1) / this.pageSize); + + return true; + }; + return AureliaTableCustomAttribute; }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [_aureliaFramework.bindable], { enumerable: true, @@ -327,4 +353,7 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec = }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], { enumerable: true, initializer: null +}), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], { + enumerable: true, + initializer: null })), _class2)) || _class); \ No newline at end of file diff --git a/dist/es2015/au-table-select.js b/dist/es2015/au-table-select.js index d3fd9eb..eaadce5 100644 --- a/dist/es2015/au-table-select.js +++ b/dist/es2015/au-table-select.js @@ -59,8 +59,8 @@ export let AutSelectCustomAttribute = (_dec = inject(AureliaTableCustomAttribute this.element = element; this.bindingEngine = bindingEngine; - this.rowSelectedListener = e => { - this.handleRowSelected(e); + this.rowSelectedListener = event => { + this.handleRowSelected(event); }; } @@ -68,7 +68,7 @@ export let AutSelectCustomAttribute = (_dec = inject(AureliaTableCustomAttribute this.element.style.cursor = 'pointer'; this.element.addEventListener('click', this.rowSelectedListener); - this.selectedSubscription = this.bindingEngine.propertyObserver(this.row, '$IsSelected').subscribe(() => this.isSelectedChanged()); + this.selectedSubscription = this.bindingEngine.propertyObserver(this.row, '$isSelected').subscribe(() => this.isSelectedChanged()); this.setClass(); } @@ -79,14 +79,14 @@ export let AutSelectCustomAttribute = (_dec = inject(AureliaTableCustomAttribute } setClass() { - if (this.row.$IsSelected) { + if (this.row.$isSelected) { this.element.classList.add(this.selectedClass); } else { this.element.classList.remove(this.selectedClass); } } - handleRowSelected(e) { + handleRowSelected(event) { let source = event.target || event.srcElement; if (source.tagName.toLowerCase() !== 'td') { return; @@ -96,16 +96,16 @@ export let AutSelectCustomAttribute = (_dec = inject(AureliaTableCustomAttribute this.deselectAll(); } - this.row.$IsSelected = this.row.$IsSelected ? false : true; + this.row.$isSelected = this.row.$isSelected ? false : true; this.setClass(); - if (this.row.$IsSelected) { + if (this.row.$isSelected) { this.dispatchSelectedEvent(); } } dispatchSelectedEvent() { - let selectedEvent = {}; + let selectedEvent; if (window.CustomEvent) { selectedEvent = new CustomEvent('select', { detail: { row: this.row }, @@ -122,12 +122,16 @@ export let AutSelectCustomAttribute = (_dec = inject(AureliaTableCustomAttribute isSelectedChanged() { this.setClass(); + + if (this.row.$isSelected) { + dispatchSelectedEvent(); + } } deselectAll() { this.auTable.data.forEach(item => { if (item !== this.row) { - item.$IsSelected = false; + item.$isSelected = false; } }); } diff --git a/dist/es2015/au-table.js b/dist/es2015/au-table.js index efec39f..6d25d19 100644 --- a/dist/es2015/au-table.js +++ b/dist/es2015/au-table.js @@ -1,4 +1,4 @@ -var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7; +var _dec, _dec2, _dec3, _dec4, _dec5, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8; function _initDefineProp(target, property, descriptor, context) { if (!descriptor) return; @@ -45,7 +45,7 @@ function _initializerWarningHelper(descriptor, context) { import { inject, bindable, bindingMode, BindingEngine } from "aurelia-framework"; -export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = bindable({ defaultBindingMode: bindingMode.twoWay }), _dec3 = bindable({ defaultBindingMode: bindingMode.twoWay }), _dec4 = bindable({ defaultBindingMode: bindingMode.twoWay }), _dec(_class = (_class2 = class AureliaTableCustomAttribute { +export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec3 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec4 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec5 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec(_class = (_class2 = class AureliaTableCustomAttribute { constructor(bindingEngine) { _initDefineProp(this, "data", _descriptor, this); @@ -62,8 +62,11 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = _initDefineProp(this, "totalItems", _descriptor7, this); + _initDefineProp(this, "api", _descriptor8, this); + this.isAttached = false; this.sortChangedListeners = []; + this.beforePagination = []; this.bindingEngine = bindingEngine; } @@ -72,6 +75,10 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = if (this.data) { this.dataObserver = this.bindingEngine.collectionObserver(this.data).subscribe(() => this.applyPlugins()); } + + this.api = { + revealItem: item => this.revealItem(item) + }; } attached() { @@ -129,6 +136,7 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = this.totalItems = localData.length; if (this.hasPagination()) { + this.beforePagination = [].concat(localData); localData = this.doPaginate(localData); } @@ -162,8 +170,8 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = let val2; if (typeof sortKey === "function") { - val1 = sortKey(a); - val2 = sortKey(b); + val1 = sortKey(a, sortOrder); + val2 = sortKey(b, sortOrder); } else { val1 = a[sortKey]; val2 = b[sortKey]; @@ -246,6 +254,22 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = } } + revealItem(item) { + if (!this.hasPagination()) { + return true; + } + + let index = this.beforePagination.indexOf(item); + + if (index === -1) { + return false; + } + + this.currentPage = Math.ceil((index + 1) / this.pageSize); + + return true; + } + }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [bindable], { enumerable: true, initializer: null @@ -267,4 +291,7 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], { enumerable: true, initializer: null +}), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], { + enumerable: true, + initializer: null })), _class2)) || _class); \ No newline at end of file diff --git a/dist/system/au-table-select.js b/dist/system/au-table-select.js index 94e0f1a..d935d90 100644 --- a/dist/system/au-table-select.js +++ b/dist/system/au-table-select.js @@ -80,8 +80,8 @@ System.register(["aurelia-framework", "./au-table"], function (_export, _context this.element = element; this.bindingEngine = bindingEngine; - this.rowSelectedListener = function (e) { - _this.handleRowSelected(e); + this.rowSelectedListener = function (event) { + _this.handleRowSelected(event); }; } @@ -91,7 +91,7 @@ System.register(["aurelia-framework", "./au-table"], function (_export, _context this.element.style.cursor = 'pointer'; this.element.addEventListener('click', this.rowSelectedListener); - this.selectedSubscription = this.bindingEngine.propertyObserver(this.row, '$IsSelected').subscribe(function () { + this.selectedSubscription = this.bindingEngine.propertyObserver(this.row, '$isSelected').subscribe(function () { return _this2.isSelectedChanged(); }); @@ -104,14 +104,14 @@ System.register(["aurelia-framework", "./au-table"], function (_export, _context }; AutSelectCustomAttribute.prototype.setClass = function setClass() { - if (this.row.$IsSelected) { + if (this.row.$isSelected) { this.element.classList.add(this.selectedClass); } else { this.element.classList.remove(this.selectedClass); } }; - AutSelectCustomAttribute.prototype.handleRowSelected = function handleRowSelected(e) { + AutSelectCustomAttribute.prototype.handleRowSelected = function handleRowSelected(event) { var source = event.target || event.srcElement; if (source.tagName.toLowerCase() !== 'td') { return; @@ -121,16 +121,16 @@ System.register(["aurelia-framework", "./au-table"], function (_export, _context this.deselectAll(); } - this.row.$IsSelected = this.row.$IsSelected ? false : true; + this.row.$isSelected = this.row.$isSelected ? false : true; this.setClass(); - if (this.row.$IsSelected) { + if (this.row.$isSelected) { this.dispatchSelectedEvent(); } }; AutSelectCustomAttribute.prototype.dispatchSelectedEvent = function dispatchSelectedEvent() { - var selectedEvent = {}; + var selectedEvent = void 0; if (window.CustomEvent) { selectedEvent = new CustomEvent('select', { detail: { row: this.row }, @@ -147,6 +147,10 @@ System.register(["aurelia-framework", "./au-table"], function (_export, _context AutSelectCustomAttribute.prototype.isSelectedChanged = function isSelectedChanged() { this.setClass(); + + if (this.row.$isSelected) { + dispatchSelectedEvent(); + } }; AutSelectCustomAttribute.prototype.deselectAll = function deselectAll() { @@ -154,7 +158,7 @@ System.register(["aurelia-framework", "./au-table"], function (_export, _context this.auTable.data.forEach(function (item) { if (item !== _this3.row) { - item.$IsSelected = false; + item.$isSelected = false; } }); }; diff --git a/dist/system/au-table.js b/dist/system/au-table.js index b25f8cc..2f49016 100644 --- a/dist/system/au-table.js +++ b/dist/system/au-table.js @@ -3,7 +3,7 @@ System.register(["aurelia-framework"], function (_export, _context) { "use strict"; - var inject, bindable, bindingMode, BindingEngine, _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, AureliaTableCustomAttribute; + var inject, bindable, bindingMode, BindingEngine, _dec, _dec2, _dec3, _dec4, _dec5, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, AureliaTableCustomAttribute; function _initDefineProp(target, property, descriptor, context) { if (!descriptor) return; @@ -62,7 +62,7 @@ System.register(["aurelia-framework"], function (_export, _context) { BindingEngine = _aureliaFramework.BindingEngine; }], execute: function () { - _export("AureliaTableCustomAttribute", AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = bindable({ defaultBindingMode: bindingMode.twoWay }), _dec3 = bindable({ defaultBindingMode: bindingMode.twoWay }), _dec4 = bindable({ defaultBindingMode: bindingMode.twoWay }), _dec(_class = (_class2 = function () { + _export("AureliaTableCustomAttribute", AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec3 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec4 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec5 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec(_class = (_class2 = function () { function AureliaTableCustomAttribute(bindingEngine) { _classCallCheck(this, AureliaTableCustomAttribute); @@ -80,8 +80,11 @@ System.register(["aurelia-framework"], function (_export, _context) { _initDefineProp(this, "totalItems", _descriptor7, this); + _initDefineProp(this, "api", _descriptor8, this); + this.isAttached = false; this.sortChangedListeners = []; + this.beforePagination = []; this.bindingEngine = bindingEngine; } @@ -94,6 +97,12 @@ System.register(["aurelia-framework"], function (_export, _context) { return _this.applyPlugins(); }); } + + this.api = { + revealItem: function revealItem(item) { + return _this.revealItem(item); + } + }; }; AureliaTableCustomAttribute.prototype.attached = function attached() { @@ -151,6 +160,7 @@ System.register(["aurelia-framework"], function (_export, _context) { this.totalItems = localData.length; if (this.hasPagination()) { + this.beforePagination = [].concat(localData); localData = this.doPaginate(localData); } @@ -212,8 +222,8 @@ System.register(["aurelia-framework"], function (_export, _context) { var val2 = void 0; if (typeof sortKey === "function") { - val1 = sortKey(a); - val2 = sortKey(b); + val1 = sortKey(a, sortOrder); + val2 = sortKey(b, sortOrder); } else { val1 = a[sortKey]; val2 = b[sortKey]; @@ -313,6 +323,22 @@ System.register(["aurelia-framework"], function (_export, _context) { } }; + AureliaTableCustomAttribute.prototype.revealItem = function revealItem(item) { + if (!this.hasPagination()) { + return true; + } + + var index = this.beforePagination.indexOf(item); + + if (index === -1) { + return false; + } + + this.currentPage = Math.ceil((index + 1) / this.pageSize); + + return true; + }; + return AureliaTableCustomAttribute; }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [bindable], { enumerable: true, @@ -335,6 +361,9 @@ System.register(["aurelia-framework"], function (_export, _context) { }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], { enumerable: true, initializer: null + }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], { + enumerable: true, + initializer: null })), _class2)) || _class)); _export("AureliaTableCustomAttribute", AureliaTableCustomAttribute);