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
Prev Previous commit
Next Next commit
Slight re-structure to viewer filter validation
  • Loading branch information
Ro4052 committed Jan 8, 2019
commit cfe06cb3e3b7ac1cf61894ad196468d971332f0c
35 changes: 20 additions & 15 deletions packages/perspective-viewer/src/js/viewer/perspective_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,31 @@ export class PerspectiveElement extends StateElement {
}
}

async _validate_filters() {
const filters = [];
const filterNodes = this._get_view_filter_nodes();
for (let i = 0; i < filterNodes.length; i++) {
const node = filterNodes[i];
const name = node.getAttribute("name");
const {operator, operand} = JSON.parse(node.getAttribute("filter"));
const filter = [name, operator, operand];
if (await this._table.valid_filter(filter)) {
filters.push(filter);
node.className = "";
} else {
node.className = "invalid-filter";
}
}

return filters;
}

async _new_view(ignore_size_check = false) {
if (!this._table) return;
this._check_responsive_layout();
const row_pivots = this._get_view_row_pivots();
const column_pivots = this._get_view_column_pivots();
const filters = await this._validate_filters();
const aggregates = this._get_view_aggregates();
if (aggregates.length === 0) return;
const sort = this._get_view_sorts();
Expand All @@ -229,21 +249,6 @@ export class PerspectiveElement extends StateElement {
}
}

const filters = [];
const filterNodes = this._get_view_filter_nodes();
for (let i = 0; i < filterNodes.length; i++) {
const node = filterNodes[i];
const name = node.getAttribute("name");
const {operator, operand} = JSON.parse(node.getAttribute("filter"));
const filter = [name, operator, operand];
if (await this._table.valid_filter(filter)) {
filters.push(filter);
node.className = "";
} else {
node.className = "invalid-filter"
}
}

if (this._view) {
this._view.delete();
this._view.remove_update(this._view_updater);
Expand Down