commit 4d6d7dea42e999559b0c96bfd8fdc9497afb6aa1
Author: Vít Mazín <n5ver@seznam.cz>
Date:   Sun Jun 9 21:44:04 2019 +0200

    Filter - rework (refs #7559)

diff --git a/sources/imiger-core/src/main/webapp/js/components/filterModalWindow.js b/sources/imiger-core/src/main/webapp/js/components/filterModalWindow.js
index 431b02b..d11bdd4 100644
--- a/sources/imiger-core/src/main/webapp/js/components/filterModalWindow.js
+++ b/sources/imiger-core/src/main/webapp/js/components/filterModalWindow.js
@@ -500,29 +500,34 @@ class FilterModalWindow extends ModalWindow {
 				break;
 		}
 
-		const filterValues = formData.getAll('value').map(value => parseInt(value));
+		let foundNodes = [];
 		nodeFilter.run(app.nodeList).forEach(node => {
+				foundNodes.push(node);
+		});
+
+		const filterValues = formData.getAll('value').map(value => parseInt(value));
+		app.nodeList.filter(node => foundNodes.indexOf(node) === -1).forEach(node => {
 			if(node instanceof Group) {
-				let outEdges = node.outEdgeList;
-				let inEdges = node.inEdgeList;
-				this._hideEdges(outEdges);
-				this._hideEdges(inEdges);
+			let outEdges = node.outEdgeList;
+			let inEdges = node.inEdgeList;
+			this._hideEdges(outEdges);
+			this._hideEdges(inEdges);
+			node._rootElement.style.display = 'none';
+		} else {
+			if(node._group !== null) {
+				if(baseFilter !== 'nodeType' || (filterValues[0] === 1 && operation === "NEQ") || (filterValues[0] === 0 && operation === "EQ")) {
+					node._group._rootElement.style.display = 'none';
+					this._hideEdges(node._group.outEdgeList);
+					this._hideEdges(node._group.inEdgeList);
+				}
 				node._rootElement.style.display = 'none';
 			} else {
-				if(node._group !== null) {
-					if(baseFilter !== 'nodeType' || filterValues[0] !== 1) {
-						node._group._rootElement.style.display = 'none';
-						this._hideEdges(node._group.outEdgeList);
-						this._hideEdges(node._group.inEdgeList);
-					}
-					node._rootElement.style.display = 'none';
-				} else {
-					node._rootElement.style.display = 'none';
-					app.edgeList.forEach(edge => {
-						if(edge.from.id === node.id || edge.to.id === node.id) {
+				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);
@@ -561,7 +566,7 @@ class FilterModalWindow extends ModalWindow {
 
 	_hideEdges(edges) {
 		edges.forEach(edge => {
-			edge._rootElement.style.display = 'none';
+				edge._rootElement.style.display = 'none';
 		});
 	}
 
diff --git a/sources/imiger-core/src/main/webapp/js/services/filters/NodeTypeFilter.js b/sources/imiger-core/src/main/webapp/js/services/filters/NodeTypeFilter.js
index 21d698a..5577fb4 100644
--- a/sources/imiger-core/src/main/webapp/js/services/filters/NodeTypeFilter.js
+++ b/sources/imiger-core/src/main/webapp/js/services/filters/NodeTypeFilter.js
@@ -28,16 +28,16 @@ class NodeTypeFilter extends AbstractFilter {
 		switch (this._operation) {
 			case EnumFilterOperation.EQ:
 				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;
 
 			case EnumFilterOperation.NEQ:
 				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;
 
 			default:
@@ -49,4 +49,4 @@ class NodeTypeFilter extends AbstractFilter {
 }
 
 NodeTypeFilter.VERTEX = 0;
-NodeTypeFilter.GROUP = 1;
+NodeTypeFilter.GROUP = 1;
\ No newline at end of file
diff --git a/sources/imiger-core/src/main/webapp/js/services/filters/VertexArchetypeFilter.js b/sources/imiger-core/src/main/webapp/js/services/filters/VertexArchetypeFilter.js
index e568a02..7f23316 100644
--- a/sources/imiger-core/src/main/webapp/js/services/filters/VertexArchetypeFilter.js
+++ b/sources/imiger-core/src/main/webapp/js/services/filters/VertexArchetypeFilter.js
@@ -17,7 +17,7 @@ class VertexArchetypeFilter extends AbstractFilter {
 	run(nodeList) {
 		// prefilter
 		nodeList = nodeList.filter(node => {
-			return node instanceof Vertex;
+				return node instanceof Vertex;
 		});
 
 		// filter
@@ -34,14 +34,14 @@ class VertexArchetypeFilter extends AbstractFilter {
 		switch (this._operation) {
 			case EnumFilterOperation.EQ:
 				filterFn = vertex => {
-					return filterValues.indexOf(vertex.archetype) < 0;
-				};
+				return filterValues.indexOf(vertex.archetype) > -1;
+			};
 				break;
 
 			case EnumFilterOperation.NEQ:
 				filterFn = vertex => {
-					return filterValues.indexOf(vertex.archetype) > -1;
-				};
+				return filterValues.indexOf(vertex.archetype) < 0;
+			};
 				break;
 
 			default:
diff --git a/sources/imiger-core/src/main/webapp/js/services/filters/VertexAttributeFilter.js b/sources/imiger-core/src/main/webapp/js/services/filters/VertexAttributeFilter.js
index 489128b..59f10a9 100644
--- a/sources/imiger-core/src/main/webapp/js/services/filters/VertexAttributeFilter.js
+++ b/sources/imiger-core/src/main/webapp/js/services/filters/VertexAttributeFilter.js
@@ -1,8 +1,8 @@
 class VertexAttributeFilter extends AbstractFilter {
 	/**
 	 * @constructor
-	 * @param {string} additionalFilter 
-	 * @param {string} dataType 
+	 * @param {string} additionalFilter
+	 * @param {string} dataType
 	 * @param {string} operation Filtering operation.
 	 * @param {FormData} formData Raw, unprocessed form content.
 	 */
@@ -23,9 +23,9 @@ class VertexAttributeFilter extends AbstractFilter {
 		// prefilter
 		nodeList = nodeList.filter(node => {
 			return node instanceof Vertex;
-		}).filter(vertex => {
+	}).filter(vertex => {
 			return vertex.attributes.some(attribute => attribute[0] === this._filterAttributeName);
-		});
+	});
 
 		// filter
 		return nodeList.filter(this._getFilterFunction());
@@ -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:
@@ -106,36 +106,26 @@ class VertexAttributeFilter extends AbstractFilter {
 		switch (operation) {
 			case EnumFilterOperation.EQ:
 				filterFn = vertex => {
-					const attribute = vertex.attributes.find(attribute => attribute[0] === filterAttributeName);
-					const attributeValues = attribute[1].split(', ');
-
-					// some (at least one) of the attribute items should be contained in the filters
-					 let count = 0;
-					 attributeValues.forEach(value => {
-						if(filterValues.indexOf(value) > -1) {
-							count++;
-						}
-					 });
-
-					 return count === 0;
-				};
+				const attribute = vertex.attributes.find(attribute => attribute[0] === filterAttributeName);
+				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;
+			});
+			};
 				break;
 
 			case EnumFilterOperation.NEQ:
 				filterFn = vertex => {
-					const attribute = vertex.attributes.find(attribute => attribute[0] === filterAttributeName);
-					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)
-					let count = 0;
-					attributeValues.forEach(value => {
-						if(filterValues.indexOf(value) > -1) {
-						count++;
-					}
-					});
-
-					return count > 0;
-				};
+				const attribute = vertex.attributes.find(attribute => attribute[0] === filterAttributeName);
+				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;
+			});
+			};
 				break;
 
 			default:
@@ -154,8 +144,7 @@ class VertexAttributeFilter extends AbstractFilter {
 			filterFn = vertex => {
 				const attribute = vertex.attributes.find(attribute => attribute[0] === filterAttributeName);
 				const attributeValue = parseInt(attribute[1]);
-
-				return (attributeValue < filterValueFrom) || (attributeValue > filterValueTo);
+				return (attributeValue >= filterValueFrom) && (attributeValue <= filterValueTo);
 			};
 
 		} else {
@@ -163,11 +152,11 @@ class VertexAttributeFilter extends AbstractFilter {
 
 			let comparatorFn;
 			switch (operation) {
-				case DateFilterOperation.NEQ:
+				case DateFilterOperation.EQ:
 					comparatorFn = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
 					break;
 
-				case DateFilterOperation.EQ:
+				case DateFilterOperation.NEQ:
 					comparatorFn = (a, b) => a.getFullYear() !== b.getFullYear() || a.getMonth() !== b.getMonth() || a.getDate() !== b.getDate();
 					break;
 
@@ -194,7 +183,7 @@ class VertexAttributeFilter extends AbstractFilter {
 			filterFn = vertex => {
 				const attribute = vertex.attributes.find(attribute => attribute[0] === filterAttributeName);
 				const attributeValue = parseFloat(attribute[1]);
-				return (attributeValue < filterValueFrom) || (attributeValue > filterValueTo);
+				return (attributeValue >= filterValueFrom) && (attributeValue <= filterValueTo);
 			};
 
 		} else {
