Skip to content

Commit ad75366

Browse files
Showing hidden nodes in table option, selection updates fix
1 parent 7d54abd commit ad75366

File tree

10 files changed

+74
-10
lines changed

10 files changed

+74
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ represented in the table below.
4747
| `queryType` | `related` | iKnow query type. Can be `related` or `similar`. |
4848
| `seed` | `crew` | Seed string. |
4949
| `keepSeedInView` | `false` | A `boolean` value determining whether the `queryType` and `seed` settings will be displayed on the screen all the time. |
50+
| `tabularShowHiddenNodes` | `false` | A `boolean` value determining whether to show entities hidden behind `X more` node in the table. |
5051

5152
URL example: `http://.../index.html?domain=1&queryType=similar&seed=plane`
5253

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.7.12",
3+
"version": "0.8.0",
44
"description": "Visualizer for iKnow entities",
55
"main": "gulpfile.babel.js",
66
"scripts": {

src/static/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
</tbody>
118118
<tbody id="tabular-others">
119119

120+
</tbody>
121+
<tbody id="tabular-hidden">
122+
120123
</tbody>
121124
</table>
122125
</div>
@@ -146,6 +149,12 @@ <h1>General Settings</h1>
146149
</div>
147150
<h1>Tabular View Settings</h1>
148151
<div>
152+
<div>
153+
<label>
154+
<input id="settings.tabularShowHiddenNodes" type="checkbox"/>
155+
Show hidden nodes in table
156+
</label>
157+
</div>
149158
<div>
150159
<b>Columns:</b>
151160
<span id="settings.tabularColumns"></span>

src/static/js/controls.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ function deleteSelection () {
4040
if (!selection.length)
4141
return;
4242
dropNodes(selection);
43-
updateSelection();
43+
// updateSelection();
4444
}
4545

4646
function dropChildren () {
4747
if (!selection.length)
4848
return;
4949
dropDescendants(selection);
50-
updateSelection();
50+
// updateSelection();
5151
}
5252

5353
export function init () {

src/static/js/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as tabular from "./tabular";
33
import * as settings from "./settings";
44
import * as model from "./model";
55
import * as controls from "./controls";
6+
import * as selection from "./selection";
67

78
window.init = () => {
89

@@ -11,6 +12,7 @@ window.init = () => {
1112
graph.init();
1213
controls.init();
1314
model.init();
15+
selection.init();
1416
model.update(() => graph.update(true));
1517

1618
};

src/static/js/selection.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@ import * as model from "./model";
22

33
let selection = [],
44
others = [],
5+
hidden = [],
56
callbacks = [];
67

78
export function updateSelection () {
89

910
let tree = model.getGraphData();
1011
selection = [];
1112
others = [];
13+
hidden = [];
14+
15+
function findHidden (node) {
16+
if (node.selected)
17+
hidden.push(node);
18+
else
19+
hidden.push(node);
20+
if (node.children)
21+
for (let n of node.children) findHidden(n);
22+
if (node._children)
23+
for (let n of node._children) findHidden(n);
24+
}
1225

1326
function findSelected (node) {
1427
if (node.selected)
@@ -17,7 +30,10 @@ export function updateSelection () {
1730
others.push(node);
1831
if (node.children)
1932
for (let n of node.children) findSelected(n);
33+
if (node._children)
34+
for (let n of node._children) findHidden(n);
2035
}
36+
2137
findSelected(tree);
2238

2339
callbacks.forEach(c => c(selection));
@@ -32,6 +48,10 @@ export function getOthers () {
3248
return others;
3349
}
3450

51+
export function getHidden () {
52+
return hidden;
53+
}
54+
3555
export function selectAll (node, nodeItself = true) {
3656
if (!node)
3757
return;
@@ -60,6 +80,10 @@ export function onSelectionUpdate (callback) {
6080

6181
}
6282

83+
export function init () {
84+
model.onModelUpdate(() => updateSelection());
85+
}
86+
6387
/**
6488
* This callback is invoked when selection changes.
6589
* @callback selectionCallback

src/static/js/settings/sourceSettings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export function init () {
2222
"settings.queryType",
2323
"settings.seed",
2424
"settings.webAppName",
25-
"settings.keepSeedInView"
25+
"settings.keepSeedInView",
26+
"settings.tabularShowHiddenNodes"
2627
]);
2728

2829
function apply () {

src/static/js/settings/values.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const settingsTypes = {
1111
domain: String,
1212
queryType: new Set(["similar", "related"]),
1313
seed: String,
14-
keepSeedInView: Boolean
14+
keepSeedInView: Boolean,
15+
tabularShowHiddenNodes: Boolean
1516
};
1617

1718
const settings = { // assign defaults here
@@ -22,6 +23,7 @@ const settings = { // assign defaults here
2223
queryType: "related",
2324
seed: "crew",
2425
keepSeedInView: false,
26+
tabularShowHiddenNodes: false,
2527
tabularColumns: [
2628
{
2729
label: "ID",

src/static/js/tabular/index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { csv } from "./export";
22
import * as model from "../model";
33
import {
4-
onSelectionUpdate, updateSelection, getSelection, getOthers, selectAll, deselectAll
4+
onSelectionUpdate, updateSelection, getSelection, getOthers, getHidden, selectAll, deselectAll
55
} from "../selection";
66
import { getOption } from "../settings/values";
77
import { getObjProp } from "../utils";
@@ -74,9 +74,11 @@ function insertRows (data, table, selected) {
7474
ee.addEventListener("click", switchSelected.bind(node));
7575
cell.appendChild(ee);
7676
if (node.children.length) cell.appendChild(ei);
77-
row.addEventListener("mouseover", () => { node.element.classList.add("highlighted"); });
78-
row.addEventListener("mouseout", () => { node.element.classList.remove("highlighted"); });
79-
row.addEventListener("click", () => focusOn(node.x, node.y));
77+
row.addEventListener("mouseover", () =>
78+
node.element && node.element.classList.add("highlighted"));
79+
row.addEventListener("mouseout", () =>
80+
node.element && node.element.classList.remove("highlighted"));
81+
row.addEventListener("click", () => node.element && focusOn(node.x, node.y));
8082
}
8183
}
8284

@@ -94,10 +96,19 @@ function updateOthers () {
9496
insertRows(data, table, false);
9597
}
9698

99+
function updateHidden () {
100+
let data = getHidden().filter(node => node.type === "entity").sort(sorter),
101+
table = document.querySelector("#tabular-hidden");
102+
table.textContent = "";
103+
if (getOption("tabularShowHiddenNodes"))
104+
insertRows(data, table, false);
105+
}
106+
97107
function updateAll () {
98108
updateHeaders();
99109
updateSelected();
100110
updateOthers();
111+
updateHidden();
101112
}
102113

103114
onSelectionUpdate(() => {

src/static/scss/tabular.scss

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,21 @@ $headerHeight: 36px;
139139

140140
#tabular-others {
141141

142-
opacity: 0.6;
142+
opacity: 0.7;
143+
144+
tr:first-child td {
145+
border-top: 1px solid black;
146+
}
147+
148+
tr td:last-child .icon-add {
149+
color: green;
150+
}
151+
152+
}
153+
154+
#tabular-hidden {
155+
156+
opacity: 0.4;
143157

144158
tr:first-child td {
145159
border-top: 1px solid black;

0 commit comments

Comments
 (0)