Skip to content

Commit

Permalink
re #2: "move found nodes to group" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
fidransky committed Feb 11, 2019
1 parent 8addc86 commit d79296f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions sources/imiger-core/src/main/webapp/css/components/navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@
line-height: 40px;
vertical-align: middle;
}

.navbar .search-count {
margin-right: 5px;
}
30 changes: 29 additions & 1 deletion sources/imiger-core/src/main/webapp/js/components/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down Expand Up @@ -165,6 +192,7 @@ class Navbar {
searchInput,
searchButton,
searchCounter,
groupFoundButton,
]);
}

Expand Down
7 changes: 7 additions & 0 deletions sources/imiger-core/src/main/webapp/js/components/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d79296f

Please sign in to comment.