Skip to content

Commit 9e034a5

Browse files
Reset selection control
1 parent db00e51 commit 9e034a5

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iknow-entity-browser",
3-
"version": "0.5.3",
3+
"version": "0.5.4",
44
"description": "Visualizer for iKnow entities",
55
"main": "gulpfile.babel.js",
66
"scripts": {

src/static/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<i id="settingsToggle" class="ui icon-settings"></i>
3535
</div>
3636
<div id="toolbarIcons">
37+
<i id="resetSelectionButton" class="ui icon-outline"></i>
3738
<i id="dropChildrenButton" class="ui icon-unlink"></i>
3839
<i id="removeButton" class="ui icon-remove"></i>
3940
</div>

src/static/js/controls.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
*/
44
import { onSelectionUpdate, updateSelection } from "./selection";
55
import { dropDescendants, dropNodes } from "./model";
6+
import { updateSelected } from "./graph"
67

78
let dropChildrenButton = null,
89
removeButton = null,
10+
resetSelectionButton = null,
911
selection = [];
1012

1113
onSelectionUpdate((sel) => {
@@ -20,6 +22,15 @@ function updateButtons () {
2022
}
2123
removeButton.classList[selection.length > 0 ? "remove" : "add"]("disabled");
2224
dropChildrenButton.classList[toDrop > 0 ? "remove" : "add"]("disabled");
25+
resetSelectionButton.classList[selection.length > 0 ? "remove" : "add"]("icon-outline");
26+
resetSelectionButton.classList[selection.length == 0 ? "remove" : "add"]("icon-filled");
27+
resetSelectionButton.classList[selection.length > 0 ? "remove" : "add"]("disabled");
28+
}
29+
30+
function resetSelection () {
31+
selection.forEach(n => n.selected = n.wasSelected = false);
32+
updateSelection();
33+
updateSelected();
2334
}
2435

2536
function deleteSelection () {
@@ -38,8 +49,10 @@ function dropChildren () {
3849

3950
export function init () {
4051
dropChildrenButton = document.getElementById(`dropChildrenButton`);
41-
dropChildrenButton.addEventListener("click", () => dropChildren());
52+
dropChildrenButton.addEventListener("click", dropChildren);
4253
removeButton = document.getElementById(`removeButton`);
43-
removeButton.addEventListener("click", () => deleteSelection());
54+
removeButton.addEventListener("click", deleteSelection);
55+
resetSelectionButton = document.getElementById(`resetSelectionButton`);
56+
resetSelectionButton.addEventListener(`click`, resetSelection);
4457
updateButtons();
4558
}

src/static/js/graph/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ let svg = null,
5151
}),
5252
view = null;
5353

54+
export function updateSelected () {
55+
node.classed("selected", p => p.selected);
56+
}
57+
5458
function newSimulation () {
5559
return d3.forceSimulation()
5660
.force("link",
@@ -236,7 +240,7 @@ export function update (g = lastGraph, reset = false) {
236240
deselectAll(d);
237241
else
238242
selectAll(d);
239-
node.classed("selected", (p) => p.selected);
243+
updateSelected();
240244
} else {
241245
d3.select(this).classed("selected", d.selected = !d.selected); // (!prevSel)
242246
}

0 commit comments

Comments
 (0)