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

Invalid filters #375

Merged
merged 15 commits into from
Jan 14, 2019
Merged
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
Next Next commit
Moved filter validation into a separate function
  • Loading branch information
Ro4052 committed Jan 4, 2019
commit 6ba022a32a697eee154f01fb04dde17f42d85d23
9 changes: 7 additions & 2 deletions packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,11 @@ export default function(Module) {
return computed_schema;
};

table.prototype._valid_filter = function(filter, isDateFilter) {
const value = isDateFilter(filter[0]) ? new DateParser().parse(filter[2]) : filter[2];
return typeof value !== "undefined" && value !== null;
};

/**
* The computed schema of this {@link table}. Returns a schema of only computed
* columns added by the user, the keys of which are computed columns and the values an
Expand Down Expand Up @@ -972,10 +977,10 @@ export default function(Module) {
if (config.filter) {
let schema = this._schema();
let isDateFilter = key => schema[key] === "datetime" || schema[key] === "date";
let validFilter = this._valid_filter;
filters = config.filter
.filter(filter => {
const value = isDateFilter(filter[0]) ? new DateParser().parse(filter[2]) : filter[2];
return typeof value !== "undefined" && value !== null;
return validFilter(filter, isDateFilter);
})
.map(filter => {
if (isDateFilter(filter[0])) {
Expand Down