diff --git a/sources/imiger-core/src/main/webapp/css/components/navbar.css b/sources/imiger-core/src/main/webapp/css/components/navbar.css index 37383ecc..45fb24ea 100644 --- a/sources/imiger-core/src/main/webapp/css/components/navbar.css +++ b/sources/imiger-core/src/main/webapp/css/components/navbar.css @@ -69,3 +69,7 @@ line-height: 40px; vertical-align: middle; } + +.navbar .search-count { + margin-right: 5px; +} \ No newline at end of file diff --git a/sources/imiger-core/src/main/webapp/js/components/navbar.js b/sources/imiger-core/src/main/webapp/js/components/navbar.js index 043e6cd3..bc4d342e 100644 --- a/sources/imiger-core/src/main/webapp/js/components/navbar.js +++ b/sources/imiger-core/src/main/webapp/js/components/navbar.js @@ -133,11 +133,38 @@ class Navbar { onClick: () => resetSearch(), }); + const groupFoundButton = DOM.h('button', { + id: 'groupFoundButton', + innerText: 'Group found vertices', + onClick: () => { + const foundVertexList = app.vertexList.filter(node => node.isFound === true && node.group === null); + + if (foundVertexList.length > 0) { + // create a new group + let group = Group.create(); + group.isExcluded = true; + + app.nodeList.push(group); + app.groupList.push(group); + + app.sidebarComponent.excludedNodeListComponent.addNode(group); + + foundVertexList.forEach(node => { + group.addVertex(node); + app.sidebarComponent.excludedNodeListComponent.removeNode(node); + node.remove(true); + }); + } + + resetSearch(); + }, + }) + function search(term) { if (term.length < 2) return; let found = 0; - + let nodeList = app.nodeList; nodeList.forEach(node => { if (node.name.toLowerCase().includes(term.toLowerCase())) { @@ -165,6 +192,7 @@ class Navbar { searchInput, searchButton, searchCounter, + groupFoundButton, ]); } diff --git a/sources/imiger-core/src/main/webapp/js/components/node.js b/sources/imiger-core/src/main/webapp/js/components/node.js index 774911b6..e81b9a90 100644 --- a/sources/imiger-core/src/main/webapp/js/components/node.js +++ b/sources/imiger-core/src/main/webapp/js/components/node.js @@ -143,6 +143,13 @@ class Node { return this._relatedArchetypeListComponent.data; } + /** + * @returns {boolean} True if the node is found, otherwise false. + */ + get isFound() { + return this._isFound; + } + /** * Sets the node as found. Highlighting is skipped when the node is excluded. * @param {boolean} newValue True to mark the node as found, otherwise false.