Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering of data when some keyed columns contain null #2

Merged
merged 3 commits into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/amd/au-table-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {

var _dec, _desc, _value, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4;

var AutPaginationCustomElement = exports.AutPaginationCustomElement = (_dec = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), (_class = function () {
var AutPaginationCustomElement = exports.AutPaginationCustomElement = (_dec = (0, _aureliaFramework.bindable)({ defaultBindingMode: _aureliaFramework.bindingMode.twoWay }), (_class = function () {
function AutPaginationCustomElement() {
_classCallCheck(this, AutPaginationCustomElement);

Expand Down
11 changes: 7 additions & 4 deletions dist/amd/au-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,14 @@ define(["exports", "aurelia-framework"], function (exports, _aureliaFramework) {

var key = _ref2;

var value = next[key].toString();

if (value.toLowerCase().indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
if (next[key]) {
var value = next[key].toString().toLowerCase();

if (value.indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/commonjs/au-table-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function _initializerWarningHelper(descriptor, context) {
throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
}

var AutPaginationCustomElement = exports.AutPaginationCustomElement = (_dec = (0, _aureliaFramework.bindable)({defaultBindingMode: _aureliaFramework.bindingMode.twoWay}), (_class = function () {
var AutPaginationCustomElement = exports.AutPaginationCustomElement = (_dec = (0, _aureliaFramework.bindable)({ defaultBindingMode: _aureliaFramework.bindingMode.twoWay }), (_class = function () {
function AutPaginationCustomElement() {
_classCallCheck(this, AutPaginationCustomElement);

Expand Down
11 changes: 7 additions & 4 deletions dist/commonjs/au-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,14 @@ var AureliaTableCustomAttribute = exports.AureliaTableCustomAttribute = (_dec =

var key = _ref2;

var value = next[key].toString();

if (value.toLowerCase().indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
if (next[key]) {
var value = next[key].toString().toLowerCase();

if (value.indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/es2015/au-table-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function _initializerWarningHelper(descriptor, context) {

import { bindable, bindingMode } from "aurelia-framework";

export let AutPaginationCustomElement = (_dec = bindable({defaultBindingMode: bindingMode.twoWay}), (_class = class AutPaginationCustomElement {
export let AutPaginationCustomElement = (_dec = bindable({ defaultBindingMode: bindingMode.twoWay }), (_class = class AutPaginationCustomElement {
constructor() {
_initDefineProp(this, "currentPage", _descriptor, this);

Expand Down
11 changes: 7 additions & 4 deletions dist/es2015/au-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ export let AureliaTableCustomAttribute = (_dec = inject(BindingEngine), _dec2 =

for (let next of toFilter) {
for (let key of this.filterKeys) {
let value = next[key].toString();

if (value.toLowerCase().indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
if (next[key]) {
let value = next[key].toString().toLowerCase();

if (value.indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/system/au-table-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ System.register(["aurelia-framework"], function (_export, _context) {
bindingMode = _aureliaFramework.bindingMode;
}],
execute: function () {
_export("AutPaginationCustomElement", AutPaginationCustomElement = (_dec = bindable({defaultBindingMode: bindingMode.twoWay}), (_class = function () {
_export("AutPaginationCustomElement", AutPaginationCustomElement = (_dec = bindable({ defaultBindingMode: bindingMode.twoWay }), (_class = function () {
function AutPaginationCustomElement() {
_classCallCheck(this, AutPaginationCustomElement);

Expand Down
11 changes: 7 additions & 4 deletions dist/system/au-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,14 @@ System.register(["aurelia-framework"], function (_export, _context) {

var key = _ref2;

var value = next[key].toString();

if (value.toLowerCase().indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
if (next[key]) {
var value = next[key].toString().toLowerCase();

if (value.indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
}
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/au-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,17 @@ export class AureliaTableCustomAttribute {

doFilter(toFilter) {
let filteredData = [];

for (let next of toFilter) {
for (let key of this.filterKeys) {
let value = next[key].toString();

if (value.toLowerCase().indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
if( next[key]){
Copy link
Owner

@tochoromero tochoromero Aug 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the property in question has a value of 0, it will evaluate to false.

We need to check if next[key] != null && next[key] != undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great point, although next[key] != null also checks for undefined due to coercion. I'll fix this in the pull request.

let value = next[key].toString().toLowerCase();

if (value.indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
}
}
}
}
Expand Down