Skip to content

Commit

Permalink
Allow both custom filter and normal key values on the same filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Hector Romero committed Oct 2, 2016
1 parent 9e9efc3 commit 56698e8
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 72 deletions.
38 changes: 21 additions & 17 deletions dist/amd/au-table.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {
"use strict";
define(['exports', 'aurelia-framework'], function (exports, _aureliaFramework) {
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
Expand Down Expand Up @@ -61,19 +61,19 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {
function AureliaTableCustomAttribute(bindingEngine) {
_classCallCheck(this, AureliaTableCustomAttribute);

_initDefineProp(this, "data", _descriptor, this);
_initDefineProp(this, 'data', _descriptor, this);

_initDefineProp(this, "displayData", _descriptor2, this);
_initDefineProp(this, 'displayData', _descriptor2, this);

_initDefineProp(this, "filters", _descriptor3, this);
_initDefineProp(this, 'filters', _descriptor3, this);

_initDefineProp(this, "currentPage", _descriptor4, this);
_initDefineProp(this, 'currentPage', _descriptor4, this);

_initDefineProp(this, "pageSize", _descriptor5, this);
_initDefineProp(this, 'pageSize', _descriptor5, this);

_initDefineProp(this, "totalItems", _descriptor6, this);
_initDefineProp(this, 'totalItems', _descriptor6, this);

_initDefineProp(this, "api", _descriptor7, this);
_initDefineProp(this, 'api', _descriptor7, this);

this.isAttached = false;
this.sortChangedListeners = [];
Expand Down Expand Up @@ -241,7 +241,11 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {
};

AureliaTableCustomAttribute.prototype.passFilter = function passFilter(item, filter) {
if (filter.value === null || filter.value === undefined) {
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
return false;
}

if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
return true;
}

Expand Down Expand Up @@ -414,25 +418,25 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {
};

return AureliaTableCustomAttribute;
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [_aureliaFramework.bindable], {
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'data', [_aureliaFramework.bindable], {
enumerable: true,
initializer: null
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "displayData", [_dec2], {
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'displayData', [_dec2], {
enumerable: true,
initializer: null
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filters", [_aureliaFramework.bindable], {
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'filters', [_aureliaFramework.bindable], {
enumerable: true,
initializer: null
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "currentPage", [_dec3], {
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'currentPage', [_dec3], {
enumerable: true,
initializer: null
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageSize", [_aureliaFramework.bindable], {
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'pageSize', [_aureliaFramework.bindable], {
enumerable: true,
initializer: null
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], {
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'totalItems', [_dec4], {
enumerable: true,
initializer: null
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], {
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'api', [_dec5], {
enumerable: true,
initializer: null
})), _class2)) || _class);
Expand Down
38 changes: 21 additions & 17 deletions dist/commonjs/au-table.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
Expand All @@ -7,7 +7,7 @@ exports.AureliaTableCustomAttribute = undefined;

var _dec, _dec2, _dec3, _dec4, _dec5, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;

var _aureliaFramework = require("aurelia-framework");
var _aureliaFramework = require('aurelia-framework');

function _initDefineProp(target, property, descriptor, context) {
if (!descriptor) return;
Expand Down Expand Up @@ -58,19 +58,19 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec =
function AureliaTableCustomAttribute(bindingEngine) {
_classCallCheck(this, AureliaTableCustomAttribute);

_initDefineProp(this, "data", _descriptor, this);
_initDefineProp(this, 'data', _descriptor, this);

_initDefineProp(this, "displayData", _descriptor2, this);
_initDefineProp(this, 'displayData', _descriptor2, this);

_initDefineProp(this, "filters", _descriptor3, this);
_initDefineProp(this, 'filters', _descriptor3, this);

_initDefineProp(this, "currentPage", _descriptor4, this);
_initDefineProp(this, 'currentPage', _descriptor4, this);

_initDefineProp(this, "pageSize", _descriptor5, this);
_initDefineProp(this, 'pageSize', _descriptor5, this);

_initDefineProp(this, "totalItems", _descriptor6, this);
_initDefineProp(this, 'totalItems', _descriptor6, this);

_initDefineProp(this, "api", _descriptor7, this);
_initDefineProp(this, 'api', _descriptor7, this);

this.isAttached = false;
this.sortChangedListeners = [];
Expand Down Expand Up @@ -238,7 +238,11 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec =
};

AureliaTableCustomAttribute.prototype.passFilter = function passFilter(item, filter) {
if (filter.value === null || filter.value === undefined) {
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
return false;
}

if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
return true;
}

Expand Down Expand Up @@ -411,25 +415,25 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec =
};

return AureliaTableCustomAttribute;
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [_aureliaFramework.bindable], {
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'data', [_aureliaFramework.bindable], {
enumerable: true,
initializer: null
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "displayData", [_dec2], {
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'displayData', [_dec2], {
enumerable: true,
initializer: null
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filters", [_aureliaFramework.bindable], {
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'filters', [_aureliaFramework.bindable], {
enumerable: true,
initializer: null
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "currentPage", [_dec3], {
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'currentPage', [_dec3], {
enumerable: true,
initializer: null
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageSize", [_aureliaFramework.bindable], {
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'pageSize', [_aureliaFramework.bindable], {
enumerable: true,
initializer: null
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], {
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'totalItems', [_dec4], {
enumerable: true,
initializer: null
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], {
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'api', [_dec5], {
enumerable: true,
initializer: null
})), _class2)) || _class);
34 changes: 19 additions & 15 deletions dist/es2015/au-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ 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}), _dec5 = bindable({defaultBindingMode: bindingMode.twoWay}), _dec(_class = (_class2 = class AureliaTableCustomAttribute {

constructor(bindingEngine) {
_initDefineProp(this, "data", _descriptor, this);
_initDefineProp(this, 'data', _descriptor, this);

_initDefineProp(this, "displayData", _descriptor2, this);
_initDefineProp(this, 'displayData', _descriptor2, this);

_initDefineProp(this, "filters", _descriptor3, this);
_initDefineProp(this, 'filters', _descriptor3, this);

_initDefineProp(this, "currentPage", _descriptor4, this);
_initDefineProp(this, 'currentPage', _descriptor4, this);

_initDefineProp(this, "pageSize", _descriptor5, this);
_initDefineProp(this, 'pageSize', _descriptor5, this);

_initDefineProp(this, "totalItems", _descriptor6, this);
_initDefineProp(this, 'totalItems', _descriptor6, this);

_initDefineProp(this, "api", _descriptor7, this);
_initDefineProp(this, 'api', _descriptor7, this);

this.isAttached = false;
this.sortChangedListeners = [];
Expand Down Expand Up @@ -168,7 +168,11 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 =
}

passFilter(item, filter) {
if (filter.value === null || filter.value === undefined) {
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
return false;
}

if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
return true;
}

Expand Down Expand Up @@ -308,25 +312,25 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 =
return true;
}

}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [bindable], {
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'data', [bindable], {
enumerable: true,
initializer: null
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "displayData", [_dec2], {
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'displayData', [_dec2], {
enumerable: true,
initializer: null
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filters", [bindable], {
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'filters', [bindable], {
enumerable: true,
initializer: null
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "currentPage", [_dec3], {
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'currentPage', [_dec3], {
enumerable: true,
initializer: null
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageSize", [bindable], {
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'pageSize', [bindable], {
enumerable: true,
initializer: null
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], {
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'totalItems', [_dec4], {
enumerable: true,
initializer: null
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], {
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'api', [_dec5], {
enumerable: true,
initializer: null
})), _class2)) || _class);
42 changes: 23 additions & 19 deletions dist/system/au-table.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
'use strict';

System.register(["aurelia-framework"], function (_export, _context) {
System.register(['aurelia-framework'], function (_export, _context) {
"use strict";

var inject, bindable, bindingMode, BindingEngine, _dec, _dec2, _dec3, _dec4, _dec5, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, AureliaTableCustomAttribute;
Expand Down Expand Up @@ -62,23 +62,23 @@ 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}), _dec5 = 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);

_initDefineProp(this, "data", _descriptor, this);
_initDefineProp(this, 'data', _descriptor, this);

_initDefineProp(this, "displayData", _descriptor2, this);
_initDefineProp(this, 'displayData', _descriptor2, this);

_initDefineProp(this, "filters", _descriptor3, this);
_initDefineProp(this, 'filters', _descriptor3, this);

_initDefineProp(this, "currentPage", _descriptor4, this);
_initDefineProp(this, 'currentPage', _descriptor4, this);

_initDefineProp(this, "pageSize", _descriptor5, this);
_initDefineProp(this, 'pageSize', _descriptor5, this);

_initDefineProp(this, "totalItems", _descriptor6, this);
_initDefineProp(this, 'totalItems', _descriptor6, this);

_initDefineProp(this, "api", _descriptor7, this);
_initDefineProp(this, 'api', _descriptor7, this);

this.isAttached = false;
this.sortChangedListeners = [];
Expand Down Expand Up @@ -246,7 +246,11 @@ System.register(["aurelia-framework"], function (_export, _context) {
};

AureliaTableCustomAttribute.prototype.passFilter = function passFilter(item, filter) {
if (filter.value === null || filter.value === undefined) {
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
return false;
}

if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
return true;
}

Expand Down Expand Up @@ -419,30 +423,30 @@ System.register(["aurelia-framework"], function (_export, _context) {
};

return AureliaTableCustomAttribute;
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [bindable], {
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'data', [bindable], {
enumerable: true,
initializer: null
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "displayData", [_dec2], {
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'displayData', [_dec2], {
enumerable: true,
initializer: null
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filters", [bindable], {
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'filters', [bindable], {
enumerable: true,
initializer: null
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "currentPage", [_dec3], {
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'currentPage', [_dec3], {
enumerable: true,
initializer: null
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageSize", [bindable], {
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'pageSize', [bindable], {
enumerable: true,
initializer: null
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], {
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'totalItems', [_dec4], {
enumerable: true,
initializer: null
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], {
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'api', [_dec5], {
enumerable: true,
initializer: null
})), _class2)) || _class));

_export("AureliaTableCustomAttribute", AureliaTableCustomAttribute);
_export('AureliaTableCustomAttribute', AureliaTableCustomAttribute);
}
};
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-table",
"version": "0.1.5",
"version": "0.1.6",
"description": "A simple data table for Aurelia.",
"keywords": [
"aurelia",
Expand Down
6 changes: 3 additions & 3 deletions src/au-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ export class AureliaTableCustomAttribute {
}

passFilter(item, filter) {
if (typeof filter.custom === 'function') {
return filter.custom(filter.value, item);
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
return false;
}

if (filter.value === null || filter.value === undefined) {
if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
return true;
}

Expand Down

0 comments on commit 56698e8

Please sign in to comment.