Skip to content

Commit

Permalink
Filter fix (refs #7559)
Browse files Browse the repository at this point in the history
  • Loading branch information
mazinvit committed Jun 5, 2019
1 parent 59d483f commit bd03aa5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ class FilterModalWindow extends ModalWindow {
});
app.deletedVertexList.forEach(vertex => {
v.push(vertex);
app.viewportComponent.addNode(vertex);
});
app.deletedEdgeList.forEach(edge => {
e.push(edge);
Expand Down Expand Up @@ -500,12 +501,23 @@ class FilterModalWindow extends ModalWindow {
}

nodeFilter.run(app.nodeList).forEach(node => {
node._rootElement.style.display = 'none';
app.edgeList.forEach(edge => {
if(edge.from.id === node.id || edge.to.id === node.id) {
edge._rootElement.style.display = 'none';
if(node instanceof Group) {
let outEdges = node.outEdgeList;
let inEdges = node.inEdgeList;
this._hideEdges(outEdges);
this._hideEdges(inEdges);
node._rootElement.style.display = 'none';
} else {
if(node._group === null) {
node._rootElement.style.display = 'none';
app.edgeList.forEach(edge => {
if(edge.from.id === node.id || edge.to.id === node.id) {
edge._rootElement.style.display = 'none';
}
});
}
});
}
app.viewportComponent.removeNode(node);
});

var newNodeList = [];
Expand Down Expand Up @@ -539,6 +551,12 @@ class FilterModalWindow extends ModalWindow {
app.edgeList = newEdgeList;
}

_hideEdges(edges) {
edges.forEach(edge => {
edge._rootElement.style.display = 'none';
});
}

setDateBounds(minDate, maxDate) {
if(minDate !== null && maxDate !== null) {
this._showSlider = DOM.h('script', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class NodeTypeFilter extends AbstractFilter {
switch (this._operation) {
case EnumFilterOperation.EQ:
filterFn = node => {
return (node instanceof Vertex && filterValues.indexOf(NodeTypeFilter.VERTEX) > -1)
|| (node instanceof Group && filterValues.indexOf(NodeTypeFilter.GROUP) > -1);
return (node instanceof Vertex && filterValues.indexOf(NodeTypeFilter.VERTEX) < 0)
|| (node instanceof Group && filterValues.indexOf(NodeTypeFilter.GROUP) < 0);
};
break;

case EnumFilterOperation.NEQ:
filterFn = node => {
return (node instanceof Vertex && filterValues.indexOf(NodeTypeFilter.VERTEX) < 0)
|| (node instanceof Group && filterValues.indexOf(NodeTypeFilter.GROUP) < 0);
return (node instanceof Vertex && filterValues.indexOf(NodeTypeFilter.VERTEX) > -1)
|| (node instanceof Group && filterValues.indexOf(NodeTypeFilter.GROUP) > -1);
};
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class VertexArchetypeFilter extends AbstractFilter {
switch (this._operation) {
case EnumFilterOperation.EQ:
filterFn = vertex => {
return filterValues.indexOf(vertex.archetype) > -1;
return filterValues.indexOf(vertex.archetype) < 0;
};
break;

case EnumFilterOperation.NEQ:
filterFn = vertex => {
return filterValues.indexOf(vertex.archetype) < 0;
return filterValues.indexOf(vertex.archetype) > -1;
};
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ class VertexAttributeFilter extends AbstractFilter {
let comparatorFn;
switch (operation) {
case StringFilterOperation.EQ:
comparatorFn = (a, b) => a === b;
comparatorFn = (a, b) => a !== b;
break;

case StringFilterOperation.NEQ:
comparatorFn = (a, b) => a !== b;
comparatorFn = (a, b) => a === b;
break;

case StringFilterOperation.CONTAINS:
comparatorFn = (a, b) => a.includes(b);
comparatorFn = (a, b) => !(a.includes(b));
break;

case StringFilterOperation.STARTS_WITH:
comparatorFn = (a, b) => a.startsWith(b);
comparatorFn = (a, b) => !(a.startsWith(b));
break;

case StringFilterOperation.ENDS_WITH:
comparatorFn = (a, b) => a.endsWith(b);
comparatorFn = (a, b) => !(a.endsWith(b));
break;

case StringFilterOperation.REGEXP:
comparatorFn = (a, b) => a.match(new RegExp(b, 'i'));
comparatorFn = (a, b) => !(a.match(new RegExp(b, 'i')));
break;

default:
Expand All @@ -110,9 +110,14 @@ class VertexAttributeFilter extends AbstractFilter {
const attributeValues = attribute[1].split(', ');

// some (at least one) of the attribute items should be contained in the filters
return attributeValues.some(attributeValue => {
return filterValues.indexOf(attributeValue) > -1;
});
let count = 0;
attributeValues.forEach(value => {
if(filterValues.indexOf(value) > -1) {
count++;
}
});

return count === 0;
};
break;

Expand All @@ -122,9 +127,14 @@ class VertexAttributeFilter extends AbstractFilter {
const attributeValues = attribute[1].split(', ');

// every of the attribute items should not be contained in the filters (translated: none of the items should be contained in the filters)
return attributeValues.every(attributeValue => {
return filterValues.indexOf(attributeValue) < 0;
let count = 0;
attributeValues.forEach(value => {
if(filterValues.indexOf(value) > -1) {
count++;
}
});

return count > 0;
};
break;

Expand Down Expand Up @@ -153,11 +163,11 @@ class VertexAttributeFilter extends AbstractFilter {

let comparatorFn;
switch (operation) {
case DateFilterOperation.EQ:
case DateFilterOperation.NEQ:
comparatorFn = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
break;

case DateFilterOperation.NEQ:
case DateFilterOperation.EQ:
comparatorFn = (a, b) => a.getFullYear() !== b.getFullYear() || a.getMonth() !== b.getMonth() || a.getDate() !== b.getDate();
break;

Expand Down

0 comments on commit bd03aa5

Please sign in to comment.