Skip to content

Commit 232e1c6

Browse files
Dropping the node, font change
1 parent 200fc49 commit 232e1c6

File tree

10 files changed

+79
-23
lines changed

10 files changed

+79
-23
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.4.2",
3+
"version": "0.5.0",
44
"description": "Visualizer for iKnow entities",
55
"main": "gulpfile.babel.js",
66
"scripts": {
-340 Bytes
Binary file not shown.

src/static/fonts/iknowentitybrowsericons.svg

Lines changed: 7 additions & 8 deletions
Loading
-340 Bytes
Binary file not shown.
-284 Bytes
Binary file not shown.

src/static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</div>
1818
<svg id="graph"></svg>
1919
<div id="table">
20-
<i id="tableToggle" class="ui icon-window-list"></i>
20+
<i id="tableToggle" class="ui icon-list"></i>
2121
<div id="rightTopIcons">
2222
<i id="settingsToggle" class="ui icon-settings"></i>
2323
</div>

src/static/js/controls.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This file describes on-screen controls like UI link/remove buttons, etc.
33
*/
44
import { onSelectionUpdate, updateSelection } from "./selection";
5-
import { dropDescendants } from "./model";
5+
import { dropDescendants, dropNodes } from "./model";
66

77
let dropChildrenButton = null,
88
removeButton = null,
@@ -18,12 +18,15 @@ function updateButtons () {
1818
for (let node of selection) {
1919
toDrop += (node.children ? node.children.length : 0);
2020
}
21-
removeButton.classList.add("disabled"); // temporary
21+
removeButton.classList[selection.length > 0 ? "remove" : "add"]("disabled");
2222
dropChildrenButton.classList[toDrop > 0 ? "remove" : "add"]("disabled");
2323
}
2424

2525
function deleteSelection () {
26-
26+
if (!selection.length)
27+
return;
28+
dropNodes(selection);
29+
updateSelection();
2730
}
2831

2932
function dropChildren () {

src/static/js/model/index.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function toTree (graph, parent) {
6161
try {
6262
parent.children.sort(
6363
(a, b) => a.entities[0][FOLDING_CRITERIA] > b.entities[0][FOLDING_CRITERIA] ? -1 : 1
64+
).forEach(
65+
(e) => e.parent = parent
6466
);
6567
} catch (e) {
6668
console.error(`Error! Most likely, one of the graph nodes does not has any entities.`
@@ -309,4 +311,58 @@ export function dropDescendants (nodes) {
309311

310312
return toDrop;
311313

314+
}
315+
316+
/**
317+
* Delete all nodes and their descendants.
318+
* @param {Array|*} nodes - Node to delete
319+
* @returns {number} - Number of nodes deleted
320+
*/
321+
export function dropNodes (nodes) {
322+
323+
if (!(nodes instanceof Array))
324+
nodes = [nodes];
325+
326+
let restore = nodes.filter(n => !!n.parent).map(node => {
327+
return {
328+
node: node.parent,
329+
children: node.parent.children.slice()
330+
};
331+
});
332+
333+
if (restore.length === 0)
334+
return 0;
335+
336+
function f () {
337+
for (let node of nodes) {
338+
if (!node.parent) // unable to drop root node
339+
continue;
340+
let i = node.parent.children.indexOf(node);
341+
if (i === -1) {
342+
console.error(
343+
`There is a mess occurred with the tree model structure while dropping nodes: `
344+
`node's parent is pointing to a node which doesn't have this node as a child.`
345+
);
346+
continue;
347+
}
348+
let temp = node.parent.children.slice();
349+
temp.splice(i, 1);
350+
node.parent.children = temp;
351+
}
352+
dataUpdated();
353+
}
354+
f();
355+
356+
history.createState({
357+
redo: f,
358+
undo: () => {
359+
for (let res of restore) {
360+
res.node.children = res.children;
361+
}
362+
dataUpdated();
363+
}
364+
});
365+
366+
return nodes.length;
367+
312368
}

src/static/scss/icons.scss

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,22 @@
4040
-moz-osx-font-smoothing: grayscale;
4141
}
4242

43-
.icon-window-list:before {
43+
.icon-list:before {
4444
content: "\61";
4545
}
46-
.icon-page-export-csv:before {
47-
content: "\62";
48-
}
49-
.icon-search-plus:before {
46+
.icon-zoom-in:before {
5047
content: "\63";
5148
}
52-
.icon-search-minus:before {
49+
.icon-zoom-out:before {
5350
content: "\64";
5451
}
5552
.icon-search:before {
5653
content: "\65";
5754
}
58-
.icon-ios-circle-outline:before {
55+
.icon-outline:before {
5956
content: "\66";
6057
}
61-
.icon-ios-circle-filled:before {
58+
.icon-filled:before {
6259
content: "\67";
6360
}
6461
.icon-th-list:before {
@@ -70,7 +67,7 @@
7067
.icon-circle:before {
7168
content: "\6a";
7269
}
73-
.icon-cog:before {
70+
.icon-config:before {
7471
content: "\6b";
7572
}
7673
.icon-settings:before {
@@ -82,7 +79,7 @@
8279
.icon-wrench:before {
8380
content: "\6f";
8481
}
85-
.icon-android-options:before {
82+
.icon-options:before {
8683
content: "\6e";
8784
}
8885
.icon-close:before {

src/static/scss/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ html, body {
88
width: 100%;
99
margin: 0;
1010
padding: 0;
11+
font-family: monospace;
1112
}
1213

1314
#windows {

0 commit comments

Comments
 (0)