Skip to content

Commit 56698e8

Browse files
author
Hector Romero
committed
Allow both custom filter and normal key values on the same filter
1 parent 9e9efc3 commit 56698e8

File tree

6 files changed

+88
-72
lines changed

6 files changed

+88
-72
lines changed

dist/amd/au-table.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {
2-
"use strict";
1+
define(['exports', 'aurelia-framework'], function (exports, _aureliaFramework) {
2+
'use strict';
33

44
Object.defineProperty(exports, "__esModule", {
55
value: true
@@ -61,19 +61,19 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {
6161
function AureliaTableCustomAttribute(bindingEngine) {
6262
_classCallCheck(this, AureliaTableCustomAttribute);
6363

64-
_initDefineProp(this, "data", _descriptor, this);
64+
_initDefineProp(this, 'data', _descriptor, this);
6565

66-
_initDefineProp(this, "displayData", _descriptor2, this);
66+
_initDefineProp(this, 'displayData', _descriptor2, this);
6767

68-
_initDefineProp(this, "filters", _descriptor3, this);
68+
_initDefineProp(this, 'filters', _descriptor3, this);
6969

70-
_initDefineProp(this, "currentPage", _descriptor4, this);
70+
_initDefineProp(this, 'currentPage', _descriptor4, this);
7171

72-
_initDefineProp(this, "pageSize", _descriptor5, this);
72+
_initDefineProp(this, 'pageSize', _descriptor5, this);
7373

74-
_initDefineProp(this, "totalItems", _descriptor6, this);
74+
_initDefineProp(this, 'totalItems', _descriptor6, this);
7575

76-
_initDefineProp(this, "api", _descriptor7, this);
76+
_initDefineProp(this, 'api', _descriptor7, this);
7777

7878
this.isAttached = false;
7979
this.sortChangedListeners = [];
@@ -241,7 +241,11 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {
241241
};
242242

243243
AureliaTableCustomAttribute.prototype.passFilter = function passFilter(item, filter) {
244-
if (filter.value === null || filter.value === undefined) {
244+
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
245+
return false;
246+
}
247+
248+
if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
245249
return true;
246250
}
247251

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

416420
return AureliaTableCustomAttribute;
417-
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [_aureliaFramework.bindable], {
421+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'data', [_aureliaFramework.bindable], {
418422
enumerable: true,
419423
initializer: null
420-
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "displayData", [_dec2], {
424+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'displayData', [_dec2], {
421425
enumerable: true,
422426
initializer: null
423-
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filters", [_aureliaFramework.bindable], {
427+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'filters', [_aureliaFramework.bindable], {
424428
enumerable: true,
425429
initializer: null
426-
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "currentPage", [_dec3], {
430+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'currentPage', [_dec3], {
427431
enumerable: true,
428432
initializer: null
429-
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageSize", [_aureliaFramework.bindable], {
433+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'pageSize', [_aureliaFramework.bindable], {
430434
enumerable: true,
431435
initializer: null
432-
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], {
436+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'totalItems', [_dec4], {
433437
enumerable: true,
434438
initializer: null
435-
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], {
439+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'api', [_dec5], {
436440
enumerable: true,
437441
initializer: null
438442
})), _class2)) || _class);

dist/commonjs/au-table.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use strict";
1+
'use strict';
22

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

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

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

1212
function _initDefineProp(target, property, descriptor, context) {
1313
if (!descriptor) return;
@@ -58,19 +58,19 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec =
5858
function AureliaTableCustomAttribute(bindingEngine) {
5959
_classCallCheck(this, AureliaTableCustomAttribute);
6060

61-
_initDefineProp(this, "data", _descriptor, this);
61+
_initDefineProp(this, 'data', _descriptor, this);
6262

63-
_initDefineProp(this, "displayData", _descriptor2, this);
63+
_initDefineProp(this, 'displayData', _descriptor2, this);
6464

65-
_initDefineProp(this, "filters", _descriptor3, this);
65+
_initDefineProp(this, 'filters', _descriptor3, this);
6666

67-
_initDefineProp(this, "currentPage", _descriptor4, this);
67+
_initDefineProp(this, 'currentPage', _descriptor4, this);
6868

69-
_initDefineProp(this, "pageSize", _descriptor5, this);
69+
_initDefineProp(this, 'pageSize', _descriptor5, this);
7070

71-
_initDefineProp(this, "totalItems", _descriptor6, this);
71+
_initDefineProp(this, 'totalItems', _descriptor6, this);
7272

73-
_initDefineProp(this, "api", _descriptor7, this);
73+
_initDefineProp(this, 'api', _descriptor7, this);
7474

7575
this.isAttached = false;
7676
this.sortChangedListeners = [];
@@ -238,7 +238,11 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec =
238238
};
239239

240240
AureliaTableCustomAttribute.prototype.passFilter = function passFilter(item, filter) {
241-
if (filter.value === null || filter.value === undefined) {
241+
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
242+
return false;
243+
}
244+
245+
if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
242246
return true;
243247
}
244248

@@ -411,25 +415,25 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec =
411415
};
412416

413417
return AureliaTableCustomAttribute;
414-
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [_aureliaFramework.bindable], {
418+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'data', [_aureliaFramework.bindable], {
415419
enumerable: true,
416420
initializer: null
417-
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "displayData", [_dec2], {
421+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'displayData', [_dec2], {
418422
enumerable: true,
419423
initializer: null
420-
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filters", [_aureliaFramework.bindable], {
424+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'filters', [_aureliaFramework.bindable], {
421425
enumerable: true,
422426
initializer: null
423-
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "currentPage", [_dec3], {
427+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'currentPage', [_dec3], {
424428
enumerable: true,
425429
initializer: null
426-
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageSize", [_aureliaFramework.bindable], {
430+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'pageSize', [_aureliaFramework.bindable], {
427431
enumerable: true,
428432
initializer: null
429-
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], {
433+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'totalItems', [_dec4], {
430434
enumerable: true,
431435
initializer: null
432-
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], {
436+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'api', [_dec5], {
433437
enumerable: true,
434438
initializer: null
435439
})), _class2)) || _class);

dist/es2015/au-table.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ import { inject, bindable, bindingMode, BindingEngine } from "aurelia-framework"
4848
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 {
4949

5050
constructor(bindingEngine) {
51-
_initDefineProp(this, "data", _descriptor, this);
51+
_initDefineProp(this, 'data', _descriptor, this);
5252

53-
_initDefineProp(this, "displayData", _descriptor2, this);
53+
_initDefineProp(this, 'displayData', _descriptor2, this);
5454

55-
_initDefineProp(this, "filters", _descriptor3, this);
55+
_initDefineProp(this, 'filters', _descriptor3, this);
5656

57-
_initDefineProp(this, "currentPage", _descriptor4, this);
57+
_initDefineProp(this, 'currentPage', _descriptor4, this);
5858

59-
_initDefineProp(this, "pageSize", _descriptor5, this);
59+
_initDefineProp(this, 'pageSize', _descriptor5, this);
6060

61-
_initDefineProp(this, "totalItems", _descriptor6, this);
61+
_initDefineProp(this, 'totalItems', _descriptor6, this);
6262

63-
_initDefineProp(this, "api", _descriptor7, this);
63+
_initDefineProp(this, 'api', _descriptor7, this);
6464

6565
this.isAttached = false;
6666
this.sortChangedListeners = [];
@@ -168,7 +168,11 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 =
168168
}
169169

170170
passFilter(item, filter) {
171-
if (filter.value === null || filter.value === undefined) {
171+
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
172+
return false;
173+
}
174+
175+
if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
172176
return true;
173177
}
174178

@@ -308,25 +312,25 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 =
308312
return true;
309313
}
310314

311-
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [bindable], {
315+
}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'data', [bindable], {
312316
enumerable: true,
313317
initializer: null
314-
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "displayData", [_dec2], {
318+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'displayData', [_dec2], {
315319
enumerable: true,
316320
initializer: null
317-
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filters", [bindable], {
321+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'filters', [bindable], {
318322
enumerable: true,
319323
initializer: null
320-
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "currentPage", [_dec3], {
324+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'currentPage', [_dec3], {
321325
enumerable: true,
322326
initializer: null
323-
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageSize", [bindable], {
327+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'pageSize', [bindable], {
324328
enumerable: true,
325329
initializer: null
326-
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], {
330+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'totalItems', [_dec4], {
327331
enumerable: true,
328332
initializer: null
329-
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], {
333+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'api', [_dec5], {
330334
enumerable: true,
331335
initializer: null
332336
})), _class2)) || _class);

dist/system/au-table.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"use strict";
1+
'use strict';
22

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

66
var inject, bindable, bindingMode, BindingEngine, _dec, _dec2, _dec3, _dec4, _dec5, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, AureliaTableCustomAttribute;
@@ -62,23 +62,23 @@ System.register(["aurelia-framework"], function (_export, _context) {
6262
BindingEngine = _aureliaFramework.BindingEngine;
6363
}],
6464
execute: function () {
65-
_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 () {
65+
_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 () {
6666
function AureliaTableCustomAttribute(bindingEngine) {
6767
_classCallCheck(this, AureliaTableCustomAttribute);
6868

69-
_initDefineProp(this, "data", _descriptor, this);
69+
_initDefineProp(this, 'data', _descriptor, this);
7070

71-
_initDefineProp(this, "displayData", _descriptor2, this);
71+
_initDefineProp(this, 'displayData', _descriptor2, this);
7272

73-
_initDefineProp(this, "filters", _descriptor3, this);
73+
_initDefineProp(this, 'filters', _descriptor3, this);
7474

75-
_initDefineProp(this, "currentPage", _descriptor4, this);
75+
_initDefineProp(this, 'currentPage', _descriptor4, this);
7676

77-
_initDefineProp(this, "pageSize", _descriptor5, this);
77+
_initDefineProp(this, 'pageSize', _descriptor5, this);
7878

79-
_initDefineProp(this, "totalItems", _descriptor6, this);
79+
_initDefineProp(this, 'totalItems', _descriptor6, this);
8080

81-
_initDefineProp(this, "api", _descriptor7, this);
81+
_initDefineProp(this, 'api', _descriptor7, this);
8282

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

248248
AureliaTableCustomAttribute.prototype.passFilter = function passFilter(item, filter) {
249-
if (filter.value === null || filter.value === undefined) {
249+
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
250+
return false;
251+
}
252+
253+
if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
250254
return true;
251255
}
252256

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

421425
return AureliaTableCustomAttribute;
422-
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "data", [bindable], {
426+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'data', [bindable], {
423427
enumerable: true,
424428
initializer: null
425-
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "displayData", [_dec2], {
429+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'displayData', [_dec2], {
426430
enumerable: true,
427431
initializer: null
428-
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "filters", [bindable], {
432+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'filters', [bindable], {
429433
enumerable: true,
430434
initializer: null
431-
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "currentPage", [_dec3], {
435+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'currentPage', [_dec3], {
432436
enumerable: true,
433437
initializer: null
434-
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageSize", [bindable], {
438+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'pageSize', [bindable], {
435439
enumerable: true,
436440
initializer: null
437-
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "totalItems", [_dec4], {
441+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'totalItems', [_dec4], {
438442
enumerable: true,
439443
initializer: null
440-
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "api", [_dec5], {
444+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'api', [_dec5], {
441445
enumerable: true,
442446
initializer: null
443447
})), _class2)) || _class));
444448

445-
_export("AureliaTableCustomAttribute", AureliaTableCustomAttribute);
449+
_export('AureliaTableCustomAttribute', AureliaTableCustomAttribute);
446450
}
447451
};
448452
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aurelia-table",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "A simple data table for Aurelia.",
55
"keywords": [
66
"aurelia",

src/au-table.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ export class AureliaTableCustomAttribute {
132132
}
133133

134134
passFilter(item, filter) {
135-
if (typeof filter.custom === 'function') {
136-
return filter.custom(filter.value, item);
135+
if (typeof filter.custom === 'function' && !filter.custom(filter.value, item)) {
136+
return false;
137137
}
138138

139-
if (filter.value === null || filter.value === undefined) {
139+
if (filter.value === null || filter.value === undefined || !Array.isArray(filter.keys)) {
140140
return true;
141141
}
142142

0 commit comments

Comments
 (0)