@yuneta/gobj-ui 7.29.6 → 7.29.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -17
- package/dist/gobj-ui.cjs.js +10 -10
- package/dist/gobj-ui.es.js +10 -10
- package/package.json +2 -2
- package/scripts/validate-locales.mjs +1 -1
- package/src/c_g6_nodes_tree.js +3 -3
- package/src/treedb_fold_model.js +2 -2
- package/src/treedb_fold_model.test.js +99 -77
- package/src/treedb_layout.js +7 -7
- package/src/treedb_layout.test.js +17 -17
- package/src/yui_icons.css +2 -3
package/README.md
CHANGED
|
@@ -2086,7 +2086,7 @@ a level or two, with a count on every cut.
|
|
|
2086
2086
|
are the records with no drawable parent, a node's children are the records
|
|
2087
2087
|
whose fkey names it through a hook, and a node is visible when a visible
|
|
2088
2088
|
parent shows it or it is a shown root — the **union**, so a device that hangs
|
|
2089
|
-
from its site AND its
|
|
2089
|
+
from its site AND its owner is drawn once, under whichever opened
|
|
2090
2090
|
first, and folding one of the two leaves it where the other shows it.
|
|
2091
2091
|
- **`expand_depth`** (default `1` since `7.23.142`, `2` before) is how much
|
|
2092
2092
|
opens on load until the reader steps: the roots alone. **`fold_page_size`** (default `24`) is how many children of
|
|
@@ -2109,14 +2109,14 @@ a level or two, with a count on every cut.
|
|
|
2109
2109
|
JSON graph's fold handles are — G6 never reads the DOM `click`, it builds its
|
|
2110
2110
|
own from the pointer pair.
|
|
2111
2111
|
- **The toolbar's fold STEPPER** (since `7.23.141`; it replaced the *expand
|
|
2112
|
-
all* / *collapse all* pair): `▸` · **`sites level 2/
|
|
2112
|
+
all* / *collapse all* pair): `▸` · **`sites level 2/5`** · `▾`. It walks the
|
|
2113
2113
|
**main tree** one level at a time, the way the frontend view opens one level
|
|
2114
2114
|
per press: level 1 is the main topic's roots (and the loose records the
|
|
2115
2115
|
reader asked to see), each `▾` opens the next level through every topic that
|
|
2116
2116
|
is not hidden, each `▸` folds the deepest one. The readout says what the two
|
|
2117
2117
|
buttons act on — the main topic's swatch and name (data, never translated;
|
|
2118
2118
|
gone on a phone, the numbers stay) and `level N/M` — the WORD as well as the
|
|
2119
|
-
numbers, because the legend chip under it says `sites 2/
|
|
2119
|
+
numbers, because the legend chip under it says `sites 2/5` too and there it
|
|
2120
2120
|
means records on screen — and a button is disabled at either end. **A level is a floor, not a picture**: stepping down
|
|
2121
2121
|
opens only what is folded above the new level and keeps the pages and pills
|
|
2122
2122
|
already open; stepping up folds from the new level down and touches nothing
|
|
@@ -2159,9 +2159,9 @@ One consumer key came with it: `show more`, the chip's tooltip.
|
|
|
2159
2159
|
|
|
2160
2160
|
What a treedb graph IS, once folded: a **forest read top to bottom**. A main
|
|
2161
2161
|
topic is a tree (sites: country, region, campus), the other topics hang
|
|
2162
|
-
from its nodes through hooks, a record may hang from two parents
|
|
2163
|
-
from its site AND its
|
|
2164
|
-
root. Tens to a few hundred cards on screen, never the store.
|
|
2162
|
+
from its nodes through hooks, a record may hang from two parents of two
|
|
2163
|
+
topics (a device from its site AND its owner), and every visible node was
|
|
2164
|
+
reached from a root. Tens to a few hundred cards on screen, never the store.
|
|
2165
2165
|
|
|
2166
2166
|
G6 5.1 registers these layouts, and this is how each meets that shape:
|
|
2167
2167
|
|
|
@@ -2169,7 +2169,7 @@ G6 5.1 registers these layouts, and this is how each meets that shape:
|
|
|
2169
2169
|
|---|---|---|
|
|
2170
2170
|
| `dagre` / `antv-dagre` | layered DAG: longest-path ranks, crossing minimisation, one direction | the right reading (LR); but the crossing heuristic **reorders the siblings on every run** — open one hook and the column next to it shuffles — and it is the one thing that takes time on a big expansion |
|
|
2171
2171
|
| `compact-box`, `indented`, `dendrogram`, `mindmap` | @antv/hierarchy tree layouts | the shape wanted, but G6 runs them on a tree it **builds from the edges** (`createTreeStructure`): a node with two parents lands under whichever parent the builder met first, unstably |
|
|
2172
|
-
| `radial` | MDS on graph distances from a focus node, a ring per depth, overlaps pushed apart afterwards | the right idea — a
|
|
2172
|
+
| `radial` | MDS on graph distances from a focus node, a ring per depth, overlaps pushed apart afterwards | the right idea — a site with a hundred devices is a **fan**, not a column — but the ring radius is one it is TOLD: twenty cards of 172px on a ring of radius 200 have 52px each and pile up. Tried, and replaced by our own (below) |
|
|
2173
2173
|
| `force`, `d3-force`, `force-atlas2`, `fruchterman` | physics | scatter a tree: the pile with springs. `d3-force` and `force-atlas2` stay in the picker for the rare flat treedb |
|
|
2174
2174
|
| `circular`, `concentric`, `grid`, `mds`, `random` | rings, rings by degree, a grid, projection, noise | none knows a parent from a child |
|
|
2175
2175
|
| `combo-combined`, `fishbone` | combos / cause-effect | not this data |
|
|
@@ -2181,7 +2181,7 @@ layouts by two thin adapters in `c_g6_nodes_tree.js`:
|
|
|
2181
2181
|
depth as tall as its tallest card, a node centred over the block of its
|
|
2182
2182
|
children, siblings side by side with `nodesep`. **The default** for a
|
|
2183
2183
|
treedb nobody has arranged (was `dagre`). It reads down because down is
|
|
2184
|
-
where a tree has room: a
|
|
2184
|
+
where a tree has room: a site with a hundred devices is a wide row, not a
|
|
2185
2185
|
column beside a card — and read right (as it did until `7.23.74`) it was
|
|
2186
2186
|
`dagre` with the siblings held still, which nobody could tell apart. The
|
|
2187
2187
|
algorithm is written once, left to right; the top-down tree is the same
|
|
@@ -2242,8 +2242,8 @@ module defaults with every config it is given.
|
|
|
2242
2242
|
|
|
2243
2243
|
Both take the **same spanning tree**, chosen deterministically: roots are the
|
|
2244
2244
|
nodes with no incoming edge, in node order; a node belongs to the **first
|
|
2245
|
-
parent that reaches it** in a breadth-first walk (
|
|
2246
|
-
|
|
2245
|
+
parent that reaches it** in a breadth-first walk (a device under its site
|
|
2246
|
+
or under its owner, whichever the walk meets first) and its other links are
|
|
2247
2247
|
drawn as edges across the tree; the children of a node are ordered by the
|
|
2248
2248
|
**hook they hang from** (the parent's port order — the schema's column order)
|
|
2249
2249
|
and then by node order (record order, the pages' order); a cycle nothing
|
|
@@ -2524,9 +2524,10 @@ others*) drew the agent's treedb from `yunos` instead of `realms`. In order:
|
|
|
2524
2524
|
3. the hierarchical topic that reaches the most other topics, schema order
|
|
2525
2525
|
breaking a tie.
|
|
2526
2526
|
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2527
|
+
A treedb of the SDK has one hierarchical topic at most (`roles` in the
|
|
2528
|
+
authorization treedb, `realms` in the agent's, `client_groups` in the MQTT
|
|
2529
|
+
broker's; the controlcenter's has none), so the mark only has something to
|
|
2530
|
+
decide once a schema grows a second one. A treedb with
|
|
2530
2531
|
no topic hooked to itself has no trunk, and every topic is a tree of its own.
|
|
2531
2532
|
|
|
2532
2533
|
(Not the engine's card tier: a topic with hooks AND fkeys is an `entity` card
|
|
@@ -2541,9 +2542,9 @@ What the main topic governs, in `treedb_fold_model.js`:
|
|
|
2541
2542
|
- a topic the schema does not tie to the main one is its own tree, with its
|
|
2542
2543
|
own roots, as before.
|
|
2543
2544
|
|
|
2544
|
-
So *sites with their
|
|
2545
|
-
`
|
|
2546
|
-
|
|
2545
|
+
So *sites with their devices and nothing else* is hiding `notes` and
|
|
2546
|
+
`owners`; *devices by owner* is hiding `sites` and `notes`, and the owners
|
|
2547
|
+
tree is drawn on its own. Each combination is a user preference **per
|
|
2547
2548
|
treedb**: `hidden_topics`, `main_topic` and `loose_topics` are `SDF_PERSIST`
|
|
2548
2549
|
attrs of `C_YUI_TREEDB_GRAPH`, saved under the view's name, and both hosts
|
|
2549
2550
|
name the view after the treedb.
|
|
@@ -4865,7 +4866,7 @@ names a shell declaration other than `src/app_config.json`.
|
|
|
4865
4866
|
|
|
4866
4867
|
What is particular to an app goes in ITS `package.json`, not in the script:
|
|
4867
4868
|
properties whose value is a key, and properties whose value is a list of keys
|
|
4868
|
-
(an application hands its orchestrator `app_title: "
|
|
4869
|
+
(an application hands its orchestrator `app_title: "dashboard"` and
|
|
4869
4870
|
`welcome_features: [...]`):
|
|
4870
4871
|
|
|
4871
4872
|
```json
|
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -65557,7 +65557,7 @@ function node_label(desc, record) {
|
|
|
65557
65557
|
*
|
|
65558
65558
|
* - A node is visible when SOME visible parent shows it, or it is
|
|
65559
65559
|
* a shown root. A record with two parents (a device hangs from
|
|
65560
|
-
* its site AND its
|
|
65560
|
+
* its site AND its owner) is drawn ONCE, under whichever
|
|
65561
65561
|
* opened first, and folding one of the two leaves it where the
|
|
65562
65562
|
* other one shows it. The union, never the intersection.
|
|
65563
65563
|
*
|
|
@@ -66119,9 +66119,9 @@ function fold_reveal(model, state, node_key) {
|
|
|
66119
66119
|
* What a treedb graph IS, once it is folded (treedb_fold_model.js):
|
|
66120
66120
|
* a forest read top to bottom. A main topic is a tree (sites:
|
|
66121
66121
|
* country, region, campus), the other topics hang from its nodes
|
|
66122
|
-
* through hooks (
|
|
66123
|
-
*
|
|
66124
|
-
* every visible node was reached from a root.
|
|
66122
|
+
* through hooks (devices, notes), a record may hang from two
|
|
66123
|
+
* parents of two topics (a device from its site AND its owner),
|
|
66124
|
+
* and every visible node was reached from a root.
|
|
66125
66125
|
* Tens to a few hundred cards on screen, never the whole store.
|
|
66126
66126
|
*
|
|
66127
66127
|
* G6's own layouts either do not know that or pay for not knowing:
|
|
@@ -66143,8 +66143,8 @@ function fold_reveal(model, state, node_key) {
|
|
|
66143
66143
|
*
|
|
66144
66144
|
* - roots are the nodes with no incoming edge, in node order;
|
|
66145
66145
|
* - a node belongs to the FIRST parent that reaches it in a
|
|
66146
|
-
* breadth-first walk from the roots --
|
|
66147
|
-
*
|
|
66146
|
+
* breadth-first walk from the roots -- a device under its site
|
|
66147
|
+
* or under its owner, whichever the walk meets first -- and the
|
|
66148
66148
|
* other links are drawn as edges across the tree;
|
|
66149
66149
|
* - the children of a node are ordered by the HOOK they hang from
|
|
66150
66150
|
* (the parent's port order, which is the schema's column order)
|
|
@@ -66157,7 +66157,7 @@ function fold_reveal(model, state, node_key) {
|
|
|
66157
66157
|
* between them. O(n), and opening a hook moves NOTHING that is
|
|
66158
66158
|
* not below or beside it -- the cards keep their order, the eye
|
|
66159
66159
|
* keeps its place. It reads DOWN because that is the direction a
|
|
66160
|
-
* tree with many children has room in: a
|
|
66160
|
+
* tree with many children has room in: a site with a hundred
|
|
66161
66161
|
* devices is a wide row, not a tall column beside a card. (The
|
|
66162
66162
|
* left-to-right reading is `direction: "LR"`, kept for a host
|
|
66163
66163
|
* that wants it; `dagre` reads that way in the graph.)
|
|
@@ -66361,7 +66361,7 @@ function extent_at(n, a) {
|
|
|
66361
66361
|
* subtree gets an angular SECTOR proportional to its leaves, a node
|
|
66362
66362
|
* sits in the middle of its sector, and the radius of each ring is
|
|
66363
66363
|
* the larger of "one step further out than the ring before" and
|
|
66364
|
-
* "long enough for its nodes to sit side by side" -- so a
|
|
66364
|
+
* "long enough for its nodes to sit side by side" -- so a site
|
|
66365
66365
|
* with a hundred devices is a wide, sparse fan, and nothing
|
|
66366
66366
|
* overlaps by construction. Several roots share the circle around
|
|
66367
66367
|
* a virtual centre.
|
|
@@ -72023,8 +72023,8 @@ function geometry_has_position(g) {
|
|
|
72023
72023
|
* `manual` means "leave every node where it was put", and where none
|
|
72024
72024
|
* was put it means a cascade: get_default_ne_xy() walks x and y
|
|
72025
72025
|
* together, so a treedb opened for the first time was a diagonal pile
|
|
72026
|
-
* of cards
|
|
72027
|
-
*
|
|
72026
|
+
* of cards, and the only way out was to know to pick a layout by
|
|
72027
|
+
* hand. It is the right default only once
|
|
72028
72028
|
* there ARE saved positions to leave alone.
|
|
72029
72029
|
*
|
|
72030
72030
|
* So: nothing saved and no preference of the user's ⇒ dagre. The pick
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -65552,7 +65552,7 @@ function node_label(desc, record) {
|
|
|
65552
65552
|
*
|
|
65553
65553
|
* - A node is visible when SOME visible parent shows it, or it is
|
|
65554
65554
|
* a shown root. A record with two parents (a device hangs from
|
|
65555
|
-
* its site AND its
|
|
65555
|
+
* its site AND its owner) is drawn ONCE, under whichever
|
|
65556
65556
|
* opened first, and folding one of the two leaves it where the
|
|
65557
65557
|
* other one shows it. The union, never the intersection.
|
|
65558
65558
|
*
|
|
@@ -66114,9 +66114,9 @@ function fold_reveal(model, state, node_key) {
|
|
|
66114
66114
|
* What a treedb graph IS, once it is folded (treedb_fold_model.js):
|
|
66115
66115
|
* a forest read top to bottom. A main topic is a tree (sites:
|
|
66116
66116
|
* country, region, campus), the other topics hang from its nodes
|
|
66117
|
-
* through hooks (
|
|
66118
|
-
*
|
|
66119
|
-
* every visible node was reached from a root.
|
|
66117
|
+
* through hooks (devices, notes), a record may hang from two
|
|
66118
|
+
* parents of two topics (a device from its site AND its owner),
|
|
66119
|
+
* and every visible node was reached from a root.
|
|
66120
66120
|
* Tens to a few hundred cards on screen, never the whole store.
|
|
66121
66121
|
*
|
|
66122
66122
|
* G6's own layouts either do not know that or pay for not knowing:
|
|
@@ -66138,8 +66138,8 @@ function fold_reveal(model, state, node_key) {
|
|
|
66138
66138
|
*
|
|
66139
66139
|
* - roots are the nodes with no incoming edge, in node order;
|
|
66140
66140
|
* - a node belongs to the FIRST parent that reaches it in a
|
|
66141
|
-
* breadth-first walk from the roots --
|
|
66142
|
-
*
|
|
66141
|
+
* breadth-first walk from the roots -- a device under its site
|
|
66142
|
+
* or under its owner, whichever the walk meets first -- and the
|
|
66143
66143
|
* other links are drawn as edges across the tree;
|
|
66144
66144
|
* - the children of a node are ordered by the HOOK they hang from
|
|
66145
66145
|
* (the parent's port order, which is the schema's column order)
|
|
@@ -66152,7 +66152,7 @@ function fold_reveal(model, state, node_key) {
|
|
|
66152
66152
|
* between them. O(n), and opening a hook moves NOTHING that is
|
|
66153
66153
|
* not below or beside it -- the cards keep their order, the eye
|
|
66154
66154
|
* keeps its place. It reads DOWN because that is the direction a
|
|
66155
|
-
* tree with many children has room in: a
|
|
66155
|
+
* tree with many children has room in: a site with a hundred
|
|
66156
66156
|
* devices is a wide row, not a tall column beside a card. (The
|
|
66157
66157
|
* left-to-right reading is `direction: "LR"`, kept for a host
|
|
66158
66158
|
* that wants it; `dagre` reads that way in the graph.)
|
|
@@ -66356,7 +66356,7 @@ function extent_at(n, a) {
|
|
|
66356
66356
|
* subtree gets an angular SECTOR proportional to its leaves, a node
|
|
66357
66357
|
* sits in the middle of its sector, and the radius of each ring is
|
|
66358
66358
|
* the larger of "one step further out than the ring before" and
|
|
66359
|
-
* "long enough for its nodes to sit side by side" -- so a
|
|
66359
|
+
* "long enough for its nodes to sit side by side" -- so a site
|
|
66360
66360
|
* with a hundred devices is a wide, sparse fan, and nothing
|
|
66361
66361
|
* overlaps by construction. Several roots share the circle around
|
|
66362
66362
|
* a virtual centre.
|
|
@@ -72018,8 +72018,8 @@ function geometry_has_position(g) {
|
|
|
72018
72018
|
* `manual` means "leave every node where it was put", and where none
|
|
72019
72019
|
* was put it means a cascade: get_default_ne_xy() walks x and y
|
|
72020
72020
|
* together, so a treedb opened for the first time was a diagonal pile
|
|
72021
|
-
* of cards
|
|
72022
|
-
*
|
|
72021
|
+
* of cards, and the only way out was to know to pick a layout by
|
|
72022
|
+
* hand. It is the right default only once
|
|
72023
72023
|
* there ARE saved positions to leave alone.
|
|
72024
72024
|
*
|
|
72025
72025
|
* So: nothing saved and no preference of the user's ⇒ dagre. The pick
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuneta/gobj-ui",
|
|
3
|
-
"version": "7.29.
|
|
3
|
+
"version": "7.29.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/gobj-ui.cjs.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@rollup/plugin-terser": "^1.0.2",
|
|
49
49
|
"@vitest/coverage-v8": "^5.0.5",
|
|
50
|
-
"@yuneta/gobj-js": "^7.
|
|
50
|
+
"@yuneta/gobj-js": "^7.29.4",
|
|
51
51
|
"jsdom": "^30.1.3",
|
|
52
52
|
"vite": "^8.3.5",
|
|
53
53
|
"vitest": "^5.0.5"
|
|
@@ -301,7 +301,7 @@
|
|
|
301
301
|
* }
|
|
302
302
|
*
|
|
303
303
|
* `attr_keys` names properties whose string value is an i18n key
|
|
304
|
-
* (`app_title: "
|
|
304
|
+
* (`app_title: "dashboard"`), `array_keys` properties whose value is
|
|
305
305
|
* an array of keys. A key the app hands over that way reaches no
|
|
306
306
|
* t() the scan can read. A name declared that no source uses is a
|
|
307
307
|
* violation (a typo would turn its check off).
|
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -571,7 +571,7 @@ const _layouts = {
|
|
|
571
571
|
* -- the roots, the first parent that reaches a node, the hooks
|
|
572
572
|
* in schema order, the records in their order -- so opening a
|
|
573
573
|
* hook moves nothing that is not under or beside it. Down and not
|
|
574
|
-
* right, because down is where a tree has room: a
|
|
574
|
+
* right, because down is where a tree has room: a site with a
|
|
575
575
|
* hundred devices is a wide row, not a column beside a card --
|
|
576
576
|
* and read right it was `dagre` with the siblings held still,
|
|
577
577
|
* which nobody could tell apart. The default for a treedb nobody
|
|
@@ -7997,8 +7997,8 @@ function geometry_has_position(g)
|
|
|
7997
7997
|
* `manual` means "leave every node where it was put", and where none
|
|
7998
7998
|
* was put it means a cascade: get_default_ne_xy() walks x and y
|
|
7999
7999
|
* together, so a treedb opened for the first time was a diagonal pile
|
|
8000
|
-
* of cards
|
|
8001
|
-
*
|
|
8000
|
+
* of cards, and the only way out was to know to pick a layout by
|
|
8001
|
+
* hand. It is the right default only once
|
|
8002
8002
|
* there ARE saved positions to leave alone.
|
|
8003
8003
|
*
|
|
8004
8004
|
* So: nothing saved and no preference of the user's ⇒ dagre. The pick
|
package/src/treedb_fold_model.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
*
|
|
29
29
|
* - A node is visible when SOME visible parent shows it, or it is
|
|
30
30
|
* a shown root. A record with two parents (a device hangs from
|
|
31
|
-
* its site AND its
|
|
31
|
+
* its site AND its owner) is drawn ONCE, under whichever
|
|
32
32
|
* opened first, and folding one of the two leaves it where the
|
|
33
33
|
* other one shows it. The union, never the intersection.
|
|
34
34
|
*
|
|
@@ -229,7 +229,7 @@ export function fold_build_model(descs, records, opts)
|
|
|
229
229
|
/* Roots: no drawable parent -- with one distinction when there is
|
|
230
230
|
* a MAIN topic. A record of a topic the schema hangs from the main
|
|
231
231
|
* one (`linked`) that has no parent is LOOSE: a device with no
|
|
232
|
-
*
|
|
232
|
+
* site. It should hang and does not, so it is not a root of the
|
|
233
233
|
* tree; it is counted per topic and shown only on request
|
|
234
234
|
* (`loose_topics`). A topic the schema does not tie to the main
|
|
235
235
|
* one at all is a tree of its own, and its parentless records are
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The fold arithmetic of the treedb graph, pinned.
|
|
5
5
|
*
|
|
6
|
-
* A small
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* A small inventory on two axes: sites (a self-referent tree,
|
|
7
|
+
* where a thing is), owners (a self-referent tree of its own, who
|
|
8
|
+
* owns it), devices hanging from a site AND an owner, notes
|
|
9
|
+
* hanging from a site or a device, and a topic with hooks and no
|
|
9
10
|
* fkeys (extended) whose children must be roots.
|
|
10
11
|
***********************************************************************/
|
|
11
12
|
import { describe, test, expect } from "vitest";
|
|
@@ -42,35 +43,41 @@ const sites_desc = {
|
|
|
42
43
|
{id: "site", flag: ["fkey"], fkey: {sites: "sites"}},
|
|
43
44
|
{id: "sites", flag: ["hook"], hook: {sites: "site"}},
|
|
44
45
|
{id: "devices", flag: ["hook"], hook: {devices: "site"}},
|
|
45
|
-
{id: "
|
|
46
|
+
{id: "notes", flag: ["hook"], hook: {notes: "site"}},
|
|
46
47
|
],
|
|
47
48
|
};
|
|
48
49
|
const devices_desc = {
|
|
49
50
|
topic_name: "devices",
|
|
50
|
-
node_treedb_type: "
|
|
51
|
+
node_treedb_type: "entity",
|
|
51
52
|
cols: [
|
|
52
53
|
{id: "id", flag: []},
|
|
53
54
|
{id: "site", flag: ["fkey"], fkey: {sites: "devices"}},
|
|
54
|
-
{id: "
|
|
55
|
+
{id: "owner", flag: ["fkey"], fkey: {owners: "devices"}},
|
|
55
56
|
{id: "photo", flag: ["fkey", "file"], fkey: {__assets__: "photos"}},
|
|
57
|
+
{id: "notes", flag: ["hook"], hook: {notes: "device"}},
|
|
56
58
|
],
|
|
57
59
|
};
|
|
58
|
-
const
|
|
59
|
-
topic_name: "
|
|
60
|
+
const notes_desc = {
|
|
61
|
+
topic_name: "notes",
|
|
62
|
+
node_treedb_type: "child",
|
|
63
|
+
cols: [
|
|
64
|
+
{id: "id", flag: []},
|
|
65
|
+
{id: "site", flag: ["fkey"], fkey: {sites: "notes"}},
|
|
66
|
+
{id: "device", flag: ["fkey"], fkey: {devices: "notes"}},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
/* owners inside owners: a second HIERARCHICAL topic, on an axis the
|
|
70
|
+
* sites know nothing of */
|
|
71
|
+
const owners_desc = {
|
|
72
|
+
topic_name: "owners",
|
|
60
73
|
node_treedb_type: "entity",
|
|
61
74
|
cols: [
|
|
62
75
|
{id: "id", flag: []},
|
|
63
|
-
{id: "
|
|
64
|
-
{id: "
|
|
76
|
+
{id: "parent", flag: ["fkey"], fkey: {owners: "owners"}},
|
|
77
|
+
{id: "owners", flag: ["hook"], hook: {owners: "parent"}},
|
|
78
|
+
{id: "devices", flag: ["hook"], hook: {devices: "owner"}},
|
|
65
79
|
],
|
|
66
80
|
};
|
|
67
|
-
/* buildings inside buildings: a second HIERARCHICAL topic */
|
|
68
|
-
const buildings_self = Object.assign({}, buildings_desc, {
|
|
69
|
-
cols: buildings_desc.cols.concat([
|
|
70
|
-
{id: "buildings", flag: ["hook"], hook: {buildings: "parent"}},
|
|
71
|
-
{id: "parent", flag: ["fkey"], fkey: {buildings: "buildings"}},
|
|
72
|
-
]),
|
|
73
|
-
});
|
|
74
81
|
const groups_desc = {
|
|
75
82
|
topic_name: "groups",
|
|
76
83
|
node_treedb_type: "extended",
|
|
@@ -84,19 +91,20 @@ const descs = {
|
|
|
84
91
|
__graphs__: {topic_name: "__graphs__", cols: []},
|
|
85
92
|
sites: sites_desc,
|
|
86
93
|
devices: devices_desc,
|
|
87
|
-
|
|
94
|
+
notes: notes_desc,
|
|
95
|
+
owners: owners_desc,
|
|
88
96
|
groups: groups_desc,
|
|
89
97
|
};
|
|
90
98
|
|
|
91
|
-
/* region > (north, south); north > site1; site1
|
|
92
|
-
*
|
|
99
|
+
/* region > (north, south); north > site1; site1 holds the devices and
|
|
100
|
+
* one note n1; the owner o1, a root of the owners tree, owns d0..d9. */
|
|
93
101
|
function make_records(n_devices)
|
|
94
102
|
{
|
|
95
103
|
let devices = [];
|
|
96
104
|
for(let i = 0; i < n_devices; i++) {
|
|
97
105
|
let rec = {id: `d${i}`, site: "sites^site1^devices", photo: "x^y^photos"};
|
|
98
106
|
if(i < 10) {
|
|
99
|
-
rec.
|
|
107
|
+
rec.owner = ["owners^o1^devices"];
|
|
100
108
|
}
|
|
101
109
|
devices.push(rec);
|
|
102
110
|
}
|
|
@@ -108,7 +116,8 @@ function make_records(n_devices)
|
|
|
108
116
|
{id: "site1", site: "sites^north^sites"},
|
|
109
117
|
],
|
|
110
118
|
devices: devices,
|
|
111
|
-
|
|
119
|
+
notes: [{id: "n1", site: "sites^site1^notes"}],
|
|
120
|
+
owners: [{id: "o1", parent: ""}],
|
|
112
121
|
groups: [{id: "g1"}],
|
|
113
122
|
};
|
|
114
123
|
}
|
|
@@ -118,8 +127,8 @@ const K = (t, id) => `${t}^${id}`;
|
|
|
118
127
|
describe("the model", () => {
|
|
119
128
|
test("every record is a node, system topics are skipped", () => {
|
|
120
129
|
let m = fold_build_model(descs, make_records(3));
|
|
121
|
-
expect(m.nodes.size).toBe(4 + 3 + 1 + 1);
|
|
122
|
-
expect(m.topics).toEqual(["sites", "devices", "
|
|
130
|
+
expect(m.nodes.size).toBe(4 + 3 + 1 + 1 + 1);
|
|
131
|
+
expect(m.topics).toEqual(["sites", "devices", "notes", "owners", "groups"]);
|
|
123
132
|
});
|
|
124
133
|
|
|
125
134
|
test("children hang from the hook the fkey names, in record order", () => {
|
|
@@ -128,15 +137,15 @@ describe("the model", () => {
|
|
|
128
137
|
.toEqual([K("sites", "north"), K("sites", "south")]);
|
|
129
138
|
expect(m.groups.get(fold_group_key(K("sites", "site1"), "devices")))
|
|
130
139
|
.toEqual([K("devices", "d0"), K("devices", "d1"), K("devices", "d2")]);
|
|
131
|
-
expect(m.groups.get(fold_group_key(K("
|
|
140
|
+
expect(m.groups.get(fold_group_key(K("owners", "o1"), "devices")))
|
|
132
141
|
.toEqual([K("devices", "d0"), K("devices", "d1"), K("devices", "d2")]);
|
|
133
142
|
});
|
|
134
143
|
|
|
135
|
-
test("a device has two parents and is one node", () => {
|
|
144
|
+
test("a device has two parents, of two topics, and is one node", () => {
|
|
136
145
|
let m = fold_build_model(descs, make_records(3));
|
|
137
146
|
let d0 = m.nodes.get(K("devices", "d0"));
|
|
138
147
|
expect(d0.parents.map((p) => p.node_key).sort())
|
|
139
|
-
.toEqual([K("
|
|
148
|
+
.toEqual([K("owners", "o1"), K("sites", "site1")]);
|
|
140
149
|
});
|
|
141
150
|
|
|
142
151
|
test("roots: no drawable parent -- and a fkey into a topic nobody fetched is not a parent", () => {
|
|
@@ -146,6 +155,7 @@ describe("the model", () => {
|
|
|
146
155
|
/* `photo` names __assets__, which has no desc: ignored */
|
|
147
156
|
expect(m.nodes.get(K("devices", "d0")).parents.length).toBe(2);
|
|
148
157
|
expect(m.groups.get(fold_root_group_key("groups"))).toEqual([K("groups", "g1")]);
|
|
158
|
+
expect(m.groups.get(fold_root_group_key("owners"))).toEqual([K("owners", "o1")]);
|
|
149
159
|
});
|
|
150
160
|
|
|
151
161
|
test("a child of an `extended` parent only has no parent: the engine draws no edge to one", () => {
|
|
@@ -193,13 +203,17 @@ describe("main topic, hidden topics, loose records", () => {
|
|
|
193
203
|
expect(fold_main_topic(descs)).toBe("sites");
|
|
194
204
|
let m = fold_build_model(descs, make_records(3));
|
|
195
205
|
expect(m.main_topic).toBe("sites");
|
|
196
|
-
expect([...m.linked].sort()).toEqual(["
|
|
206
|
+
expect([...m.linked].sort()).toEqual(["devices", "notes", "sites"]);
|
|
207
|
+
/* owners is a tree of its own: the sites reach none of it */
|
|
208
|
+
expect(m.linked.has("owners")).toBe(false);
|
|
197
209
|
expect(m.linked.has("groups")).toBe(false);
|
|
198
210
|
});
|
|
199
211
|
|
|
200
212
|
test("only a topic hooked to ITSELF can be the main one", () => {
|
|
201
213
|
expect(fold_is_hierarchical(descs, "sites")).toBe(true);
|
|
202
|
-
expect(fold_is_hierarchical(descs, "
|
|
214
|
+
expect(fold_is_hierarchical(descs, "owners")).toBe(true);
|
|
215
|
+
expect(fold_is_hierarchical(descs, "devices")).toBe(false);
|
|
216
|
+
expect(fold_is_hierarchical(descs, "notes")).toBe(false);
|
|
203
217
|
expect(fold_is_hierarchical(descs, "groups")).toBe(false);
|
|
204
218
|
/* c reaches x and nothing reaches itself: no trunk at all */
|
|
205
219
|
let c = {topic_name: "c", cols: [{id: "id", flag: []},
|
|
@@ -211,10 +225,10 @@ describe("main topic, hidden topics, loose records", () => {
|
|
|
211
225
|
});
|
|
212
226
|
|
|
213
227
|
test("the schema's mark wins over the deduction, among hierarchical topics", () => {
|
|
214
|
-
|
|
215
|
-
expect(fold_main_topic(
|
|
216
|
-
let marked = Object.assign({},
|
|
217
|
-
expect(fold_main_topic(marked)).toBe("
|
|
228
|
+
/* two hierarchical topics; sites reaches more (devices, notes) */
|
|
229
|
+
expect(fold_main_topic(descs)).toBe("sites");
|
|
230
|
+
let marked = Object.assign({}, descs, {owners: Object.assign({}, owners_desc, {main_topic: true})});
|
|
231
|
+
expect(fold_main_topic(marked)).toBe("owners");
|
|
218
232
|
/* a mark on a topic that is not hierarchical is not a trunk */
|
|
219
233
|
let wrong = Object.assign({}, descs, {devices: Object.assign({}, devices_desc, {main_topic: true})});
|
|
220
234
|
expect(fold_main_topic(wrong)).toBe("sites");
|
|
@@ -233,14 +247,13 @@ describe("main topic, hidden topics, loose records", () => {
|
|
|
233
247
|
});
|
|
234
248
|
|
|
235
249
|
test("the reader's pick wins -- if it is a hierarchical topic", () => {
|
|
236
|
-
let
|
|
237
|
-
|
|
238
|
-
expect(m.
|
|
239
|
-
|
|
240
|
-
/* sites is not linked to buildings, so its roots are roots */
|
|
250
|
+
let m = fold_build_model(descs, make_records(3), {main_topic: "owners"});
|
|
251
|
+
expect(m.main_topic).toBe("owners");
|
|
252
|
+
expect([...m.linked].sort()).toEqual(["devices", "notes", "owners"]);
|
|
253
|
+
/* sites is not linked to owners, so its roots are roots */
|
|
241
254
|
expect(m.groups.get(fold_root_group_key("sites"))).toEqual([K("sites", "region")]);
|
|
242
255
|
/* a pick the rule refuses is ignored, and the trunk is deduced */
|
|
243
|
-
let m2 = fold_build_model(descs, make_records(3), {main_topic: "
|
|
256
|
+
let m2 = fold_build_model(descs, make_records(3), {main_topic: "devices"});
|
|
244
257
|
expect(m2.main_topic).toBe("sites");
|
|
245
258
|
});
|
|
246
259
|
|
|
@@ -256,42 +269,43 @@ describe("main topic, hidden topics, loose records", () => {
|
|
|
256
269
|
expect(m2.loose.devices).toEqual([K("devices", "d_loose")]);
|
|
257
270
|
});
|
|
258
271
|
|
|
259
|
-
test("a
|
|
272
|
+
test("a note on a loose device only is loose too, and follows it", () => {
|
|
260
273
|
let recs = make_records(0);
|
|
261
|
-
recs.
|
|
262
|
-
recs.
|
|
274
|
+
recs.devices.push({id: "d_loose"});
|
|
275
|
+
recs.notes.push({id: "n_under", device: ["devices^d_loose^notes"]});
|
|
263
276
|
let m = fold_build_model(descs, recs);
|
|
264
|
-
expect(m.loose.
|
|
265
|
-
expect(m.loose.
|
|
277
|
+
expect(m.loose.devices).toEqual([K("devices", "d_loose")]);
|
|
278
|
+
expect(m.loose.notes).toEqual([K("notes", "n_under")]);
|
|
266
279
|
let st = fold_new_state(24);
|
|
267
280
|
fold_expand_all(m, st);
|
|
268
|
-
expect(fold_visible_set(m, st).has(K("
|
|
269
|
-
let m2 = fold_build_model(descs, recs, {loose_topics: ["
|
|
281
|
+
expect(fold_visible_set(m, st).has(K("notes", "n_under"))).toBe(false);
|
|
282
|
+
let m2 = fold_build_model(descs, recs, {loose_topics: ["devices"]});
|
|
270
283
|
fold_expand_all(m2, st);
|
|
271
|
-
expect(fold_visible_set(m2, st).has(K("
|
|
284
|
+
expect(fold_visible_set(m2, st).has(K("notes", "n_under"))).toBe(true);
|
|
272
285
|
});
|
|
273
286
|
|
|
274
287
|
test("a hidden topic leaves the model whole: no node, no pill, no edge", () => {
|
|
275
288
|
let m = fold_build_model(descs, make_records(30), {hidden_topics: ["devices"]});
|
|
276
|
-
expect(m.topics).toEqual(["sites", "
|
|
289
|
+
expect(m.topics).toEqual(["sites", "notes", "owners", "groups"]);
|
|
277
290
|
expect(m.totals.devices).toBe(30);
|
|
278
291
|
expect(m.nodes.get(K("sites", "site1")).hooks.devices).toBeUndefined();
|
|
279
292
|
expect(fold_pills_of(m, fold_new_state(24), K("sites", "site1")).map((p) => p.hook))
|
|
280
|
-
.toEqual(["
|
|
293
|
+
.toEqual(["notes"]);
|
|
281
294
|
expect(m.hidden.has("devices")).toBe(true);
|
|
282
295
|
});
|
|
283
296
|
|
|
284
297
|
test("hiding a topic in the middle: what hung from it alone becomes loose", () => {
|
|
285
|
-
let m = fold_build_model(descs, make_records(12), {hidden_topics: ["
|
|
286
|
-
/* d0..d9 hang from site1 AND
|
|
298
|
+
let m = fold_build_model(descs, make_records(12), {hidden_topics: ["owners"]});
|
|
299
|
+
/* d0..d9 hang from site1 AND o1: still under site1 */
|
|
287
300
|
expect(m.nodes.get(K("devices", "d0")).parents.length).toBe(1);
|
|
288
301
|
expect(m.loose.devices).toEqual([]);
|
|
289
302
|
/* sites hidden = the main topic gone: nothing governs, and
|
|
290
|
-
* whatever has no parent left is a root --
|
|
291
|
-
* still hanging from it */
|
|
303
|
+
* whatever has no parent left is a root -- o1, with d0 and d1
|
|
304
|
+
* still hanging from it, and n1 */
|
|
292
305
|
let m2 = fold_build_model(descs, make_records(2), {hidden_topics: ["sites"]});
|
|
293
306
|
expect(m2.main_topic).toBe("");
|
|
294
|
-
expect(m2.groups.get(fold_root_group_key("
|
|
307
|
+
expect(m2.groups.get(fold_root_group_key("owners"))).toEqual([K("owners", "o1")]);
|
|
308
|
+
expect(m2.groups.get(fold_root_group_key("notes"))).toEqual([K("notes", "n1")]);
|
|
295
309
|
expect(m2.groups.get(fold_root_group_key("devices"))).toBeUndefined();
|
|
296
310
|
let m3 = fold_build_model(descs, {devices: [{id: "d9"}]}, {hidden_topics: ["sites"]});
|
|
297
311
|
expect(m3.groups.get(fold_root_group_key("devices"))).toEqual([K("devices", "d9")]);
|
|
@@ -328,7 +342,7 @@ describe("depth", () => {
|
|
|
328
342
|
let st = fold_new_state(24);
|
|
329
343
|
fold_expand_to_depth(m, st, 1);
|
|
330
344
|
expect([...fold_visible_set(m, st)].sort())
|
|
331
|
-
.toEqual([K("groups", "g1"), K("sites", "region")]);
|
|
345
|
+
.toEqual([K("groups", "g1"), K("owners", "o1"), K("sites", "region")]);
|
|
332
346
|
});
|
|
333
347
|
|
|
334
348
|
test("depth 2 opens the roots' hooks on their first page", () => {
|
|
@@ -339,7 +353,9 @@ describe("depth", () => {
|
|
|
339
353
|
expect(v.has(K("sites", "north"))).toBe(true);
|
|
340
354
|
expect(v.has(K("sites", "south"))).toBe(true);
|
|
341
355
|
expect(v.has(K("sites", "site1"))).toBe(false);
|
|
342
|
-
expect(v.has(K("devices", "
|
|
356
|
+
expect(v.has(K("devices", "d15"))).toBe(false);
|
|
357
|
+
/* o1 is a root: its devices are one level down */
|
|
358
|
+
expect(v.has(K("devices", "d0"))).toBe(true);
|
|
343
359
|
});
|
|
344
360
|
|
|
345
361
|
test("depth 4 reaches the devices, one page of them", () => {
|
|
@@ -350,7 +366,7 @@ describe("depth", () => {
|
|
|
350
366
|
expect(v.has(K("devices", "d0"))).toBe(true);
|
|
351
367
|
expect(v.has(K("devices", "d23"))).toBe(true);
|
|
352
368
|
expect(v.has(K("devices", "d24"))).toBe(false);
|
|
353
|
-
expect(v.has(K("
|
|
369
|
+
expect(v.has(K("notes", "n1"))).toBe(true);
|
|
354
370
|
});
|
|
355
371
|
|
|
356
372
|
test("expand all shows everything, collapse all the roots' first page", () => {
|
|
@@ -359,25 +375,29 @@ describe("depth", () => {
|
|
|
359
375
|
fold_expand_all(m, st);
|
|
360
376
|
expect(fold_visible_set(m, st).size).toBe(m.nodes.size);
|
|
361
377
|
fold_collapse_all(m, st);
|
|
362
|
-
expect(fold_visible_set(m, st).size).toBe(
|
|
378
|
+
expect(fold_visible_set(m, st).size).toBe(3);
|
|
363
379
|
});
|
|
364
380
|
});
|
|
365
381
|
|
|
366
382
|
describe("levels of the main tree (the toolbar's stepper)", () => {
|
|
367
383
|
test("levels count from the main topic's roots, down every hook", () => {
|
|
368
|
-
let
|
|
369
|
-
|
|
384
|
+
let recs = make_records(30);
|
|
385
|
+
recs.notes.push({id: "n2", site: "sites^north^notes", device: ["devices^d0^notes"]});
|
|
386
|
+
let m = fold_build_model(descs, recs);
|
|
387
|
+
/* region 1, north/south 2, site1 3, its devices and n1 4 */
|
|
370
388
|
expect(m.levels).toBe(4);
|
|
371
389
|
expect(m.level_of.get(K("sites", "region"))).toBe(1);
|
|
372
390
|
expect(m.level_of.get(K("sites", "site1"))).toBe(3);
|
|
373
|
-
/* d0 hangs from site1 (3) and b1 (4): the shallowest wins */
|
|
374
391
|
expect(m.level_of.get(K("devices", "d0"))).toBe(4);
|
|
375
|
-
/*
|
|
392
|
+
/* n2 hangs from north (2) and d0 (4): the shallowest wins */
|
|
393
|
+
expect(m.level_of.get(K("notes", "n2"))).toBe(3);
|
|
394
|
+
/* owners and groups are not tied to sites: trees of their own, no level */
|
|
395
|
+
expect(m.level_of.has(K("owners", "o1"))).toBe(false);
|
|
376
396
|
expect(m.level_of.has(K("groups", "g1"))).toBe(false);
|
|
377
397
|
});
|
|
378
398
|
|
|
379
399
|
test("a hidden topic takes its levels with it", () => {
|
|
380
|
-
let m = fold_build_model(descs, make_records(30), {hidden_topics: ["devices", "
|
|
400
|
+
let m = fold_build_model(descs, make_records(30), {hidden_topics: ["devices", "notes"]});
|
|
381
401
|
expect(m.levels).toBe(3);
|
|
382
402
|
let m0 = fold_build_model({}, {});
|
|
383
403
|
expect(m0.levels).toBe(0);
|
|
@@ -397,7 +417,7 @@ describe("levels of the main tree (the toolbar's stepper)", () => {
|
|
|
397
417
|
let st = fold_new_state(24);
|
|
398
418
|
fold_expand_to_level(m, st, 1);
|
|
399
419
|
expect([...fold_visible_set(m, st)].sort())
|
|
400
|
-
.toEqual([K("groups", "g1"), K("sites", "region")]);
|
|
420
|
+
.toEqual([K("groups", "g1"), K("owners", "o1"), K("sites", "region")]);
|
|
401
421
|
fold_open_levels(m, st, 2);
|
|
402
422
|
let v = fold_visible_set(m, st);
|
|
403
423
|
expect(v.has(K("sites", "north"))).toBe(true);
|
|
@@ -409,7 +429,9 @@ describe("levels of the main tree (the toolbar's stepper)", () => {
|
|
|
409
429
|
v = fold_visible_set(m, st);
|
|
410
430
|
expect(v.has(K("devices", "d23"))).toBe(true);
|
|
411
431
|
expect(v.has(K("devices", "d24"))).toBe(false); /* one page */
|
|
412
|
-
expect(v.has(K("
|
|
432
|
+
expect(v.has(K("notes", "n1"))).toBe(true);
|
|
433
|
+
/* the owners tree has no level: the stepper leaves it to its pills */
|
|
434
|
+
expect(fold_is_open(st, fold_group_key(K("owners", "o1"), "devices"))).toBe(false);
|
|
413
435
|
});
|
|
414
436
|
|
|
415
437
|
test("opening keeps the pages already shown; closing folds only from its level down", () => {
|
|
@@ -424,7 +446,7 @@ describe("levels of the main tree (the toolbar's stepper)", () => {
|
|
|
424
446
|
let v = fold_visible_set(m, st);
|
|
425
447
|
expect(v.has(K("sites", "site1"))).toBe(true); /* level 3 stays */
|
|
426
448
|
expect(v.has(K("devices", "d0"))).toBe(false); /* its hooks folded */
|
|
427
|
-
expect(v.has(K("
|
|
449
|
+
expect(v.has(K("notes", "n1"))).toBe(false);
|
|
428
450
|
expect(fold_is_open(st, fold_group_key(K("sites", "north"), "sites"))).toBe(true);
|
|
429
451
|
});
|
|
430
452
|
|
|
@@ -445,9 +467,9 @@ describe("toggle and pages", () => {
|
|
|
445
467
|
fold_expand_to_depth(m, st, 3);
|
|
446
468
|
let g = fold_group_key(K("sites", "site1"), "devices");
|
|
447
469
|
expect(fold_toggle(m, st, g)).toBe(true);
|
|
448
|
-
expect(fold_visible_set(m, st).has(K("devices", "
|
|
470
|
+
expect(fold_visible_set(m, st).has(K("devices", "d15"))).toBe(true);
|
|
449
471
|
expect(fold_toggle(m, st, g)).toBe(false);
|
|
450
|
-
expect(fold_visible_set(m, st).has(K("devices", "
|
|
472
|
+
expect(fold_visible_set(m, st).has(K("devices", "d15"))).toBe(false);
|
|
451
473
|
});
|
|
452
474
|
|
|
453
475
|
test("show more adds a page and stops at the total", () => {
|
|
@@ -465,22 +487,22 @@ describe("toggle and pages", () => {
|
|
|
465
487
|
fold_expand_to_depth(m, st, 4);
|
|
466
488
|
fold_toggle(m, st, fold_group_key(K("sites", "region"), "sites")); /* close */
|
|
467
489
|
let v = fold_visible_set(m, st);
|
|
468
|
-
expect(v.has(K("devices", "
|
|
469
|
-
|
|
490
|
+
expect(v.has(K("devices", "d15"))).toBe(false);
|
|
491
|
+
/* the three roots, and o1's ten devices, which o1 still shows */
|
|
492
|
+
expect(v.size).toBe(3 + 10);
|
|
470
493
|
fold_toggle(m, st, fold_group_key(K("sites", "region"), "sites")); /* reopen */
|
|
471
|
-
expect(fold_visible_set(m, st).has(K("devices", "
|
|
494
|
+
expect(fold_visible_set(m, st).has(K("devices", "d15"))).toBe(true);
|
|
472
495
|
});
|
|
473
496
|
|
|
474
497
|
test("the union: folding one parent leaves the child where the other shows it", () => {
|
|
475
498
|
let m = fold_build_model(descs, make_records(30));
|
|
476
499
|
let st = fold_new_state(24);
|
|
477
|
-
fold_expand_to_depth(m, st, 4);
|
|
500
|
+
fold_expand_to_depth(m, st, 4); /* site1's and o1's devices open */
|
|
478
501
|
let g_site = fold_group_key(K("sites", "site1"), "devices");
|
|
479
|
-
|
|
480
|
-
fold_toggle(m, st, g_bldg); /* b1's devices open too */
|
|
502
|
+
expect(fold_is_open(st, fold_group_key(K("owners", "o1"), "devices"))).toBe(true);
|
|
481
503
|
fold_toggle(m, st, g_site); /* site1's devices folded */
|
|
482
504
|
let v = fold_visible_set(m, st);
|
|
483
|
-
expect(v.has(K("devices", "d3"))).toBe(true); /* via
|
|
505
|
+
expect(v.has(K("devices", "d3"))).toBe(true); /* via o1 */
|
|
484
506
|
expect(v.has(K("devices", "d15"))).toBe(false); /* only via site1 */
|
|
485
507
|
});
|
|
486
508
|
|
|
@@ -503,9 +525,9 @@ describe("toggle and pages", () => {
|
|
|
503
525
|
let st = fold_new_state(24);
|
|
504
526
|
fold_expand_to_depth(m, st, 4);
|
|
505
527
|
let pills = fold_pills_of(m, st, K("sites", "site1"));
|
|
506
|
-
expect(pills.map((p) => p.hook)).toEqual(["devices", "
|
|
528
|
+
expect(pills.map((p) => p.hook)).toEqual(["devices", "notes"]);
|
|
507
529
|
expect(pills[0]).toMatchObject({total: 30, shown: 24, open: true, child_topic: "devices"});
|
|
508
|
-
expect(pills[1]).toMatchObject({total: 1, shown: 1, open: true, child_topic: "
|
|
530
|
+
expect(pills[1]).toMatchObject({total: 1, shown: 1, open: true, child_topic: "notes"});
|
|
509
531
|
expect(fold_pills_of(m, st, K("sites", "south"))).toEqual([]);
|
|
510
532
|
});
|
|
511
533
|
});
|
package/src/treedb_layout.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* What a treedb graph IS, once it is folded (treedb_fold_model.js):
|
|
7
7
|
* a forest read top to bottom. A main topic is a tree (sites:
|
|
8
8
|
* country, region, campus), the other topics hang from its nodes
|
|
9
|
-
* through hooks (
|
|
10
|
-
*
|
|
11
|
-
* every visible node was reached from a root.
|
|
9
|
+
* through hooks (devices, notes), a record may hang from two
|
|
10
|
+
* parents of two topics (a device from its site AND its owner),
|
|
11
|
+
* and every visible node was reached from a root.
|
|
12
12
|
* Tens to a few hundred cards on screen, never the whole store.
|
|
13
13
|
*
|
|
14
14
|
* G6's own layouts either do not know that or pay for not knowing:
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
*
|
|
31
31
|
* - roots are the nodes with no incoming edge, in node order;
|
|
32
32
|
* - a node belongs to the FIRST parent that reaches it in a
|
|
33
|
-
* breadth-first walk from the roots --
|
|
34
|
-
*
|
|
33
|
+
* breadth-first walk from the roots -- a device under its site
|
|
34
|
+
* or under its owner, whichever the walk meets first -- and the
|
|
35
35
|
* other links are drawn as edges across the tree;
|
|
36
36
|
* - the children of a node are ordered by the HOOK they hang from
|
|
37
37
|
* (the parent's port order, which is the schema's column order)
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
* between them. O(n), and opening a hook moves NOTHING that is
|
|
45
45
|
* not below or beside it -- the cards keep their order, the eye
|
|
46
46
|
* keeps its place. It reads DOWN because that is the direction a
|
|
47
|
-
* tree with many children has room in: a
|
|
47
|
+
* tree with many children has room in: a site with a hundred
|
|
48
48
|
* devices is a wide row, not a tall column beside a card. (The
|
|
49
49
|
* left-to-right reading is `direction: "LR"`, kept for a host
|
|
50
50
|
* that wants it; `dagre` reads that way in the graph.)
|
|
@@ -296,7 +296,7 @@ function extent_at(n, a)
|
|
|
296
296
|
* subtree gets an angular SECTOR proportional to its leaves, a node
|
|
297
297
|
* sits in the middle of its sector, and the radius of each ring is
|
|
298
298
|
* the larger of "one step further out than the ring before" and
|
|
299
|
-
* "long enough for its nodes to sit side by side" -- so a
|
|
299
|
+
* "long enough for its nodes to sit side by side" -- so a site
|
|
300
300
|
* with a hundred devices is a wide, sparse fan, and nothing
|
|
301
301
|
* overlaps by construction. Several roots share the circle around
|
|
302
302
|
* a virtual centre.
|
|
@@ -9,20 +9,20 @@ import { describe, test, expect } from "vitest";
|
|
|
9
9
|
import { spanning_tree, layout_tree, layout_radial } from "./treedb_layout.js";
|
|
10
10
|
|
|
11
11
|
/* region -> (north, south); north -> site; site -> d0, d1 (hook rank 1) and
|
|
12
|
-
*
|
|
12
|
+
* x1 (hook rank 2); x1 -> d0 as well (second parent). */
|
|
13
13
|
const N = (id, w, h) => ({id, w, h});
|
|
14
14
|
const nodes = [
|
|
15
15
|
N("region", 172, 96), N("north", 172, 96), N("south", 172, 96), N("site", 172, 120),
|
|
16
|
-
N("d0", 116, 40), N("d1", 116, 40), N("
|
|
16
|
+
N("d0", 116, 40), N("d1", 116, 40), N("x1", 172, 96),
|
|
17
17
|
];
|
|
18
18
|
const edges = [
|
|
19
19
|
{source: "region", target: "north", rank: 0},
|
|
20
20
|
{source: "region", target: "south", rank: 0},
|
|
21
21
|
{source: "north", target: "site", rank: 0},
|
|
22
|
-
{source: "site", target: "
|
|
22
|
+
{source: "site", target: "x1", rank: 2},
|
|
23
23
|
{source: "site", target: "d0", rank: 1},
|
|
24
24
|
{source: "site", target: "d1", rank: 1},
|
|
25
|
-
{source: "
|
|
25
|
+
{source: "x1", target: "d0", rank: 0},
|
|
26
26
|
];
|
|
27
27
|
|
|
28
28
|
describe("the spanning tree", () => {
|
|
@@ -35,13 +35,13 @@ describe("the spanning tree", () => {
|
|
|
35
35
|
|
|
36
36
|
test("children are ordered by hook rank, then by node order", () => {
|
|
37
37
|
let t = spanning_tree(nodes, edges);
|
|
38
|
-
expect(t.children.get("site")).toEqual(["d0", "d1", "
|
|
38
|
+
expect(t.children.get("site")).toEqual(["d0", "d1", "x1"]);
|
|
39
39
|
expect(t.children.get("region")).toEqual(["north", "south"]);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
test("a node with two parents belongs to the first that reaches it", () => {
|
|
43
43
|
let t = spanning_tree(nodes, edges);
|
|
44
|
-
expect(t.children.get("
|
|
44
|
+
expect(t.children.get("x1")).toEqual([]); /* d0 is site's */
|
|
45
45
|
expect(t.depth.get("d0")).toBe(3);
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -71,20 +71,20 @@ describe("the tidy tree, read down (the default)", () => {
|
|
|
71
71
|
expect(pos.get("south").y).toBe(pos.get("north").y);
|
|
72
72
|
/* depth 2 holds site (120 tall): the row is 120 tall */
|
|
73
73
|
expect(pos.get("site").y).toBe(2 * (96 + 100) + 60);
|
|
74
|
-
/* depth 3 holds chips (40) and
|
|
74
|
+
/* depth 3 holds chips (40) and x1 (96): row is 96 tall, the
|
|
75
75
|
* chips are centred in it */
|
|
76
76
|
let row3 = 2 * (96 + 100) + 120 + 100;
|
|
77
|
-
expect(pos.get("
|
|
77
|
+
expect(pos.get("x1").y).toBe(row3 + 48);
|
|
78
78
|
expect(pos.get("d0").y).toBe(row3 + 48);
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
test("siblings sit side by side; a parent is centred over its children", () => {
|
|
82
82
|
let pos = layout_tree(nodes, edges, {nodesep: 10, ranksep: 100});
|
|
83
|
-
/* site's children: d0 (116), d1 (116),
|
|
83
|
+
/* site's children: d0 (116), d1 (116), x1 (172) = 424 wide */
|
|
84
84
|
expect(pos.get("d1").x - pos.get("d0").x).toBe(126);
|
|
85
|
-
expect(pos.get("
|
|
85
|
+
expect(pos.get("x1").x - pos.get("d1").x).toBe(58 + 10 + 86);
|
|
86
86
|
let first = pos.get("d0").x - 58;
|
|
87
|
-
let last = pos.get("
|
|
87
|
+
let last = pos.get("x1").x + 86;
|
|
88
88
|
expect(pos.get("site").x).toBe((first + last) / 2);
|
|
89
89
|
});
|
|
90
90
|
|
|
@@ -103,20 +103,20 @@ describe("the tidy tree, read right", () => {
|
|
|
103
103
|
expect(pos.get("region").x).toBe(86); /* 172/2 */
|
|
104
104
|
expect(pos.get("north").x).toBe(172 + 100 + 86);
|
|
105
105
|
expect(pos.get("south").x).toBe(pos.get("north").x);
|
|
106
|
-
/* depth 3 holds chips (116) and
|
|
106
|
+
/* depth 3 holds chips (116) and x1 (172): column is 172 wide,
|
|
107
107
|
* the chips are centred in it */
|
|
108
108
|
let col3 = 3 * (172 + 100);
|
|
109
|
-
expect(pos.get("
|
|
109
|
+
expect(pos.get("x1").x).toBe(col3 + 86);
|
|
110
110
|
expect(pos.get("d0").x).toBe(col3 + 86);
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
test("siblings stack with the gap; a parent is centred on its children", () => {
|
|
114
114
|
let pos = layout_tree(nodes, edges, {nodesep: 10, ranksep: 100, direction: "LR"});
|
|
115
|
-
/* site's children: d0 (40), d1 (40),
|
|
115
|
+
/* site's children: d0 (40), d1 (40), x1 (96) = 196 tall */
|
|
116
116
|
expect(pos.get("d1").y - pos.get("d0").y).toBe(50);
|
|
117
|
-
expect(pos.get("
|
|
117
|
+
expect(pos.get("x1").y - pos.get("d1").y).toBe(20 + 10 + 48);
|
|
118
118
|
let first = pos.get("d0").y - 20;
|
|
119
|
-
let last = pos.get("
|
|
119
|
+
let last = pos.get("x1").y + 48;
|
|
120
120
|
expect(pos.get("site").y).toBe((first + last) / 2);
|
|
121
121
|
});
|
|
122
122
|
|
|
@@ -146,7 +146,7 @@ describe("the tidy tree, read right", () => {
|
|
|
146
146
|
expect(pos.get("d0").y).toBe(base.get("d0").y); /* above the new one */
|
|
147
147
|
expect(pos.get("d1").y).toBe(base.get("d1").y);
|
|
148
148
|
expect(pos.get("d2").y).toBe(base.get("d1").y + 50);
|
|
149
|
-
expect(pos.get("
|
|
149
|
+
expect(pos.get("x1").y).toBe(base.get("x1").y + 50); /* pushed down, in order */
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
152
|
|
package/src/yui_icons.css
CHANGED
|
@@ -351,9 +351,8 @@
|
|
|
351
351
|
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath d='M267.5 440.6c9.5 7.9 22.8 9.7 34.1 4.4s18.4-16.6 18.4-29l0-320c0-12.4-7.2-23.7-18.4-29s-24.5-3.6-34.1 4.4l-192 160L64 241l0-145c0-17.7-14.3-32-32-32S0 78.3 0 96L0 416c0 17.7 14.3 32 32 32s32-14.3 32-32l0-145 11.5 9.6 192 160z'/%3E%3C/svg%3E");
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
/* yi-bolt / yi-droplet: hand-drawn masks
|
|
355
|
-
*
|
|
356
|
-
* water are two of the meter families the AMR apps read. */
|
|
354
|
+
/* yi-bolt / yi-droplet: hand-drawn masks, for electricity and water:
|
|
355
|
+
* a supply, a measure or a section of either. */
|
|
357
356
|
.yi-bolt::before {
|
|
358
357
|
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath d='M300 0 60 288l140 0-50 224 240-288-140 0z'/%3E%3C/svg%3E");
|
|
359
358
|
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath d='M300 0 60 288l140 0-50 224 240-288-140 0z'/%3E%3C/svg%3E");
|