@yuneta/gobj-ui 7.29.6 → 7.29.8

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 CHANGED
@@ -1278,7 +1278,7 @@ it used to call `tabulator.setFilter` straight from the DOM handler, where the
1278
1278
  A hook cell shows how many children the row has (`[5675]`). A click on it
1279
1279
  opens the **child topic's table, filtered** to the rows whose fkey names this
1280
1280
  row (since `7.23.162`). Above the table, a chip says which filter is on,
1281
- "filtered by models model_a", and its ✕ brings the whole topic back.
1281
+ "filtered by sites north", and its ✕ brings the whole topic back.
1282
1282
 
1283
1283
  The child table already pages, searches, opens a record and exports. Until
1284
1284
  `7.23.162` the click opened a popup that listed every child id instead:
@@ -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 building is drawn once, under whichever opened
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/4`** · `▾`. It walks the
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/4` too and there it
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 (a device
2163
- from its site AND its building), and every visible node was reached from a
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 building 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) |
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 building with a hundred devices is a wide row, not 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 (the site, not the
2246
- building, because the site's column came first) and its other links are
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
- In the treedbs of the SDK there is exactly one hierarchical topic each
2528
- (`roles` in the authorization treedb, `realms` in the agent's), so the mark
2529
- only has something to decide once a schema grows a second one. A treedb with
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 users and nothing else* is hiding `devices`,
2545
- `buildings` and `models`; *sites with their devices* is hiding
2546
- `users` and `buildings`. Each combination is a user preference **per
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: "central"` and
4869
+ (an application hands its orchestrator `app_title: "dashboard"` and
4869
4870
  `welcome_features: [...]`):
4870
4871
 
4871
4872
  ```json
@@ -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 building) is drawn ONCE, under whichever
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
  *
@@ -65592,7 +65592,12 @@ function fold_split_group_key(group_key) {
65592
65592
  };
65593
65593
  }
65594
65594
  /************************************************************
65595
- * Every parent a record names, decoded, in column order.
65595
+ * Every parent a record names, decoded, in column order, and
65596
+ * in every element of a multivalued fkey. A fkey column
65597
+ * answers to one hook of one topic (the treedb refuses a
65598
+ * second), so a record that can hang from two topics has a
65599
+ * column for each; it is a hook that can hold the children
65600
+ * of several topics.
65596
65601
  *
65597
65602
  * Only the parents that will be DRAWN: a topic missing from
65598
65603
  * `descs` (a system topic such as `__assets__`, never fetched)
@@ -66119,9 +66124,9 @@ function fold_reveal(model, state, node_key) {
66119
66124
  * What a treedb graph IS, once it is folded (treedb_fold_model.js):
66120
66125
  * a forest read top to bottom. A main topic is a tree (sites:
66121
66126
  * country, region, campus), the other topics hang from its nodes
66122
- * through hooks (buildings, devices, users), a record may hang
66123
- * from two parents (a device from its site AND its building), and
66124
- * every visible node was reached from a root.
66127
+ * through hooks (devices, notes), a record may hang from two
66128
+ * parents of two topics (a device from its site AND its owner),
66129
+ * and every visible node was reached from a root.
66125
66130
  * Tens to a few hundred cards on screen, never the whole store.
66126
66131
  *
66127
66132
  * G6's own layouts either do not know that or pay for not knowing:
@@ -66143,8 +66148,8 @@ function fold_reveal(model, state, node_key) {
66143
66148
  *
66144
66149
  * - roots are the nodes with no incoming edge, in node order;
66145
66150
  * - a node belongs to the FIRST parent that reaches it in a
66146
- * breadth-first walk from the roots -- the site, not the
66147
- * building, because the site's column came first -- and the
66151
+ * breadth-first walk from the roots -- a device under its site
66152
+ * or under its owner, whichever the walk meets first -- and the
66148
66153
  * other links are drawn as edges across the tree;
66149
66154
  * - the children of a node are ordered by the HOOK they hang from
66150
66155
  * (the parent's port order, which is the schema's column order)
@@ -66157,7 +66162,7 @@ function fold_reveal(model, state, node_key) {
66157
66162
  * between them. O(n), and opening a hook moves NOTHING that is
66158
66163
  * not below or beside it -- the cards keep their order, the eye
66159
66164
  * keeps its place. It reads DOWN because that is the direction a
66160
- * tree with many children has room in: a building with a hundred
66165
+ * tree with many children has room in: a site with a hundred
66161
66166
  * devices is a wide row, not a tall column beside a card. (The
66162
66167
  * left-to-right reading is `direction: "LR"`, kept for a host
66163
66168
  * that wants it; `dagre` reads that way in the graph.)
@@ -66361,7 +66366,7 @@ function extent_at(n, a) {
66361
66366
  * subtree gets an angular SECTOR proportional to its leaves, a node
66362
66367
  * sits in the middle of its sector, and the radius of each ring is
66363
66368
  * 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 building
66369
+ * "long enough for its nodes to sit side by side" -- so a site
66365
66370
  * with a hundred devices is a wide, sparse fan, and nothing
66366
66371
  * overlaps by construction. Several roots share the circle around
66367
66372
  * a virtual centre.
@@ -72023,8 +72028,8 @@ function geometry_has_position(g) {
72023
72028
  * `manual` means "leave every node where it was put", and where none
72024
72029
  * was put it means a cascade: get_default_ne_xy() walks x and y
72025
72030
  * together, so a treedb opened for the first time was a diagonal pile
72026
- * of cards — a hundred of them on a large one — and the only way out was to
72027
- * know to pick a layout by hand. It is the right default only once
72031
+ * of cards, and the only way out was to know to pick a layout by
72032
+ * hand. It is the right default only once
72028
72033
  * there ARE saved positions to leave alone.
72029
72034
  *
72030
72035
  * So: nothing saved and no preference of the user's ⇒ dagre. The pick
@@ -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 building) is drawn ONCE, under whichever
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
  *
@@ -65587,7 +65587,12 @@ function fold_split_group_key(group_key) {
65587
65587
  };
65588
65588
  }
65589
65589
  /************************************************************
65590
- * Every parent a record names, decoded, in column order.
65590
+ * Every parent a record names, decoded, in column order, and
65591
+ * in every element of a multivalued fkey. A fkey column
65592
+ * answers to one hook of one topic (the treedb refuses a
65593
+ * second), so a record that can hang from two topics has a
65594
+ * column for each; it is a hook that can hold the children
65595
+ * of several topics.
65591
65596
  *
65592
65597
  * Only the parents that will be DRAWN: a topic missing from
65593
65598
  * `descs` (a system topic such as `__assets__`, never fetched)
@@ -66114,9 +66119,9 @@ function fold_reveal(model, state, node_key) {
66114
66119
  * What a treedb graph IS, once it is folded (treedb_fold_model.js):
66115
66120
  * a forest read top to bottom. A main topic is a tree (sites:
66116
66121
  * country, region, campus), the other topics hang from its nodes
66117
- * through hooks (buildings, devices, users), a record may hang
66118
- * from two parents (a device from its site AND its building), and
66119
- * 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.
66120
66125
  * Tens to a few hundred cards on screen, never the whole store.
66121
66126
  *
66122
66127
  * G6's own layouts either do not know that or pay for not knowing:
@@ -66138,8 +66143,8 @@ function fold_reveal(model, state, node_key) {
66138
66143
  *
66139
66144
  * - roots are the nodes with no incoming edge, in node order;
66140
66145
  * - a node belongs to the FIRST parent that reaches it in a
66141
- * breadth-first walk from the roots -- the site, not the
66142
- * building, because the site's column came first -- and the
66146
+ * breadth-first walk from the roots -- a device under its site
66147
+ * or under its owner, whichever the walk meets first -- and the
66143
66148
  * other links are drawn as edges across the tree;
66144
66149
  * - the children of a node are ordered by the HOOK they hang from
66145
66150
  * (the parent's port order, which is the schema's column order)
@@ -66152,7 +66157,7 @@ function fold_reveal(model, state, node_key) {
66152
66157
  * between them. O(n), and opening a hook moves NOTHING that is
66153
66158
  * not below or beside it -- the cards keep their order, the eye
66154
66159
  * keeps its place. It reads DOWN because that is the direction a
66155
- * tree with many children has room in: a building with a hundred
66160
+ * tree with many children has room in: a site with a hundred
66156
66161
  * devices is a wide row, not a tall column beside a card. (The
66157
66162
  * left-to-right reading is `direction: "LR"`, kept for a host
66158
66163
  * that wants it; `dagre` reads that way in the graph.)
@@ -66356,7 +66361,7 @@ function extent_at(n, a) {
66356
66361
  * subtree gets an angular SECTOR proportional to its leaves, a node
66357
66362
  * sits in the middle of its sector, and the radius of each ring is
66358
66363
  * 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 building
66364
+ * "long enough for its nodes to sit side by side" -- so a site
66360
66365
  * with a hundred devices is a wide, sparse fan, and nothing
66361
66366
  * overlaps by construction. Several roots share the circle around
66362
66367
  * a virtual centre.
@@ -72018,8 +72023,8 @@ function geometry_has_position(g) {
72018
72023
  * `manual` means "leave every node where it was put", and where none
72019
72024
  * was put it means a cascade: get_default_ne_xy() walks x and y
72020
72025
  * together, so a treedb opened for the first time was a diagonal pile
72021
- * of cards — a hundred of them on a large one — and the only way out was to
72022
- * know to pick a layout by hand. It is the right default only once
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
72023
72028
  * there ARE saved positions to leave alone.
72024
72029
  *
72025
72030
  * 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.6",
3
+ "version": "7.29.8",
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.28.0",
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: "central"`), `array_keys` properties whose value is
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).
@@ -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 building with 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 — a hundred of them on a large one — and the only way out was to
8001
- * know to pick a layout by hand. It is the right default only once
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
@@ -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 building) is drawn ONCE, under whichever
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
  *
@@ -78,7 +78,12 @@ export function fold_split_group_key(group_key)
78
78
  }
79
79
 
80
80
  /************************************************************
81
- * Every parent a record names, decoded, in column order.
81
+ * Every parent a record names, decoded, in column order, and
82
+ * in every element of a multivalued fkey. A fkey column
83
+ * answers to one hook of one topic (the treedb refuses a
84
+ * second), so a record that can hang from two topics has a
85
+ * column for each; it is a hook that can hold the children
86
+ * of several topics.
82
87
  *
83
88
  * Only the parents that will be DRAWN: a topic missing from
84
89
  * `descs` (a system topic such as `__assets__`, never fetched)
@@ -229,7 +234,7 @@ export function fold_build_model(descs, records, opts)
229
234
  /* Roots: no drawable parent -- with one distinction when there is
230
235
  * a MAIN topic. A record of a topic the schema hangs from the main
231
236
  * one (`linked`) that has no parent is LOOSE: a device with no
232
- * place. It should hang and does not, so it is not a root of the
237
+ * site. It should hang and does not, so it is not a root of the
233
238
  * tree; it is counted per topic and shown only on request
234
239
  * (`loose_topics`). A topic the schema does not tie to the main
235
240
  * one at all is a tree of its own, and its parentless records are
@@ -3,10 +3,17 @@
3
3
  *
4
4
  * The fold arithmetic of the treedb graph, pinned.
5
5
  *
6
- * A small sites / buildings / devices inventory: sites (a
7
- * self-referent tree), devices hanging from a site AND a building,
8
- * buildings hanging from a site, and a topic with hooks and no
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.
11
+ *
12
+ * A note has two fkey columns, one for each topic it can hang from:
13
+ * a fkey column answers to ONE hook of ONE topic (the treedb refuses
14
+ * a second, "Only can be one fkey"). What CAN name several topics is
15
+ * a hook: one hook holding children of two topics has a case of its
16
+ * own below.
10
17
  ***********************************************************************/
11
18
  import { describe, test, expect } from "vitest";
12
19
  import {
@@ -42,35 +49,42 @@ const sites_desc = {
42
49
  {id: "site", flag: ["fkey"], fkey: {sites: "sites"}},
43
50
  {id: "sites", flag: ["hook"], hook: {sites: "site"}},
44
51
  {id: "devices", flag: ["hook"], hook: {devices: "site"}},
45
- {id: "buildings", flag: ["hook"], hook: {buildings: "site"}},
52
+ {id: "notes", flag: ["hook"], hook: {notes: "site"}},
46
53
  ],
47
54
  };
48
55
  const devices_desc = {
49
56
  topic_name: "devices",
50
- node_treedb_type: "child",
57
+ node_treedb_type: "entity",
51
58
  cols: [
52
59
  {id: "id", flag: []},
53
60
  {id: "site", flag: ["fkey"], fkey: {sites: "devices"}},
54
- {id: "building", flag: ["fkey"], fkey: {buildings: "devices"}},
61
+ {id: "owner", flag: ["fkey"], fkey: {owners: "devices"}},
62
+ {id: "group", flag: ["fkey"], fkey: {groups: "members"}},
55
63
  {id: "photo", flag: ["fkey", "file"], fkey: {__assets__: "photos"}},
64
+ {id: "notes", flag: ["hook"], hook: {notes: "device"}},
56
65
  ],
57
66
  };
58
- const buildings_desc = {
59
- topic_name: "buildings",
67
+ const notes_desc = {
68
+ topic_name: "notes",
69
+ node_treedb_type: "child",
70
+ cols: [
71
+ {id: "id", flag: []},
72
+ {id: "site", flag: ["fkey"], fkey: {sites: "notes"}},
73
+ {id: "device", flag: ["fkey"], fkey: {devices: "notes"}},
74
+ ],
75
+ };
76
+ /* owners inside owners: a second HIERARCHICAL topic, on an axis the
77
+ * sites know nothing of */
78
+ const owners_desc = {
79
+ topic_name: "owners",
60
80
  node_treedb_type: "entity",
61
81
  cols: [
62
82
  {id: "id", flag: []},
63
- {id: "site", flag: ["fkey"], fkey: {sites: "buildings"}},
64
- {id: "devices", flag: ["hook"], hook: {devices: "building"}},
83
+ {id: "parent", flag: ["fkey"], fkey: {owners: "owners"}},
84
+ {id: "owners", flag: ["hook"], hook: {owners: "parent"}},
85
+ {id: "devices", flag: ["hook"], hook: {devices: "owner"}},
65
86
  ],
66
87
  };
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
88
  const groups_desc = {
75
89
  topic_name: "groups",
76
90
  node_treedb_type: "extended",
@@ -84,19 +98,20 @@ const descs = {
84
98
  __graphs__: {topic_name: "__graphs__", cols: []},
85
99
  sites: sites_desc,
86
100
  devices: devices_desc,
87
- buildings: buildings_desc,
101
+ notes: notes_desc,
102
+ owners: owners_desc,
88
103
  groups: groups_desc,
89
104
  };
90
105
 
91
- /* region > (north, south); north > site1; site1 has 30 devices and one
92
- * building b1 that also reaches devices d0..d9. */
106
+ /* region > (north, south); north > site1; site1 holds the devices and
107
+ * one note n1; the owner o1, a root of the owners tree, owns d0..d9. */
93
108
  function make_records(n_devices)
94
109
  {
95
110
  let devices = [];
96
111
  for(let i = 0; i < n_devices; i++) {
97
112
  let rec = {id: `d${i}`, site: "sites^site1^devices", photo: "x^y^photos"};
98
113
  if(i < 10) {
99
- rec.building = ["buildings^b1^devices"];
114
+ rec.owner = ["owners^o1^devices"];
100
115
  }
101
116
  devices.push(rec);
102
117
  }
@@ -108,7 +123,8 @@ function make_records(n_devices)
108
123
  {id: "site1", site: "sites^north^sites"},
109
124
  ],
110
125
  devices: devices,
111
- buildings: [{id: "b1", site: "sites^site1^buildings"}],
126
+ notes: [{id: "n1", site: "sites^site1^notes"}],
127
+ owners: [{id: "o1", parent: ""}],
112
128
  groups: [{id: "g1"}],
113
129
  };
114
130
  }
@@ -118,8 +134,8 @@ const K = (t, id) => `${t}^${id}`;
118
134
  describe("the model", () => {
119
135
  test("every record is a node, system topics are skipped", () => {
120
136
  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", "buildings", "groups"]);
137
+ expect(m.nodes.size).toBe(4 + 3 + 1 + 1 + 1);
138
+ expect(m.topics).toEqual(["sites", "devices", "notes", "owners", "groups"]);
123
139
  });
124
140
 
125
141
  test("children hang from the hook the fkey names, in record order", () => {
@@ -128,15 +144,15 @@ describe("the model", () => {
128
144
  .toEqual([K("sites", "north"), K("sites", "south")]);
129
145
  expect(m.groups.get(fold_group_key(K("sites", "site1"), "devices")))
130
146
  .toEqual([K("devices", "d0"), K("devices", "d1"), K("devices", "d2")]);
131
- expect(m.groups.get(fold_group_key(K("buildings", "b1"), "devices")))
147
+ expect(m.groups.get(fold_group_key(K("owners", "o1"), "devices")))
132
148
  .toEqual([K("devices", "d0"), K("devices", "d1"), K("devices", "d2")]);
133
149
  });
134
150
 
135
- test("a device has two parents and is one node", () => {
151
+ test("a device has two parents, of two topics, and is one node", () => {
136
152
  let m = fold_build_model(descs, make_records(3));
137
153
  let d0 = m.nodes.get(K("devices", "d0"));
138
154
  expect(d0.parents.map((p) => p.node_key).sort())
139
- .toEqual([K("buildings", "b1"), K("sites", "site1")]);
155
+ .toEqual([K("owners", "o1"), K("sites", "site1")]);
140
156
  });
141
157
 
142
158
  test("roots: no drawable parent -- and a fkey into a topic nobody fetched is not a parent", () => {
@@ -146,12 +162,15 @@ describe("the model", () => {
146
162
  /* `photo` names __assets__, which has no desc: ignored */
147
163
  expect(m.nodes.get(K("devices", "d0")).parents.length).toBe(2);
148
164
  expect(m.groups.get(fold_root_group_key("groups"))).toEqual([K("groups", "g1")]);
165
+ expect(m.groups.get(fold_root_group_key("owners"))).toEqual([K("owners", "o1")]);
149
166
  });
150
167
 
151
168
  test("a child of an `extended` parent only has no parent: the engine draws no edge to one", () => {
152
169
  let recs = make_records(1);
153
170
  recs.devices[0] = {id: "d0", group: "groups^g1^members"};
154
171
  let m = fold_build_model(descs, recs);
172
+ /* devices_desc has the fkey column `group`: the ref is read, and refused */
173
+ expect(m.nodes.get(K("devices", "d0")).parents).toEqual([]);
155
174
  expect(m.nodes.get(K("groups", "g1")).hooks).toEqual({});
156
175
  /* devices hang from sites (the main topic), so a device with
157
176
  * no parent is LOOSE, not a root -- see the "main topic" block */
@@ -165,6 +184,53 @@ describe("the model", () => {
165
184
  expect(m3.groups.get(fold_root_group_key("devices"))).toEqual([K("devices", "d0")]);
166
185
  });
167
186
 
187
+ test("a multivalued fkey names a parent in every element, not only the first", () => {
188
+ let recs = make_records(1);
189
+ recs.owners.push({id: "o2", parent: ""}, {id: "o3", parent: ""});
190
+ recs.devices[0].owner = ["owners^o1^devices", "owners^o2^devices", "owners^o3^devices"];
191
+ let m = fold_build_model(descs, recs);
192
+ expect(m.nodes.get(K("devices", "d0")).parents.map((p) => p.node_key))
193
+ .toEqual([K("sites", "site1"), K("owners", "o1"), K("owners", "o2"), K("owners", "o3")]);
194
+ for(let o of ["o1", "o2", "o3"]) {
195
+ expect(m.groups.get(fold_group_key(K("owners", o), "devices"))).toEqual([K("devices", "d0")]);
196
+ }
197
+ });
198
+
199
+ test("a hook can hold the children of two topics: one group, in topic order", () => {
200
+ /* sites.items holds devices AND notes; each child's own fkey
201
+ * column names that one hook */
202
+ let sites_items = {topic_name: "sites", node_treedb_type: "entity", cols: [
203
+ {id: "id", flag: []},
204
+ {id: "site", flag: ["fkey"], fkey: {sites: "sites"}},
205
+ {id: "sites", flag: ["hook"], hook: {sites: "site"}},
206
+ {id: "items", flag: ["hook"], hook: {devices: "place", notes: "place"}},
207
+ ]};
208
+ let devices_items = {topic_name: "devices", node_treedb_type: "child", cols: [
209
+ {id: "id", flag: []},
210
+ {id: "place", flag: ["fkey"], fkey: {sites: "items"}},
211
+ ]};
212
+ let notes_items = {topic_name: "notes", node_treedb_type: "child", cols: [
213
+ {id: "id", flag: []},
214
+ {id: "place", flag: ["fkey"], fkey: {sites: "items"}},
215
+ ]};
216
+ let d = {sites: sites_items, devices: devices_items, notes: notes_items};
217
+ let recs = {
218
+ sites: [{id: "site1", site: ""}],
219
+ devices: [{id: "d0", place: "sites^site1^items"}],
220
+ notes: [{id: "n1", place: "sites^site1^items"}, {id: "n2"}],
221
+ };
222
+ let m = fold_build_model(d, recs);
223
+ expect(m.main_topic).toBe("sites");
224
+ expect([...m.linked].sort()).toEqual(["devices", "notes", "sites"]);
225
+ expect(m.groups.get(fold_group_key(K("sites", "site1"), "items")))
226
+ .toEqual([K("devices", "d0"), K("notes", "n1")]);
227
+ expect(m.loose.notes).toEqual([K("notes", "n2")]);
228
+ let st = fold_new_state(24);
229
+ fold_expand_all(m, st);
230
+ expect([...fold_visible_set(m, st)].sort())
231
+ .toEqual([K("devices", "d0"), K("notes", "n1"), K("sites", "site1")]);
232
+ });
233
+
168
234
  test("a cycle with no way in gets one root, not a row of them", () => {
169
235
  let recs = {
170
236
  sites: [
@@ -193,13 +259,17 @@ describe("main topic, hidden topics, loose records", () => {
193
259
  expect(fold_main_topic(descs)).toBe("sites");
194
260
  let m = fold_build_model(descs, make_records(3));
195
261
  expect(m.main_topic).toBe("sites");
196
- expect([...m.linked].sort()).toEqual(["buildings", "devices", "sites"]);
262
+ expect([...m.linked].sort()).toEqual(["devices", "notes", "sites"]);
263
+ /* owners is a tree of its own: the sites reach none of it */
264
+ expect(m.linked.has("owners")).toBe(false);
197
265
  expect(m.linked.has("groups")).toBe(false);
198
266
  });
199
267
 
200
268
  test("only a topic hooked to ITSELF can be the main one", () => {
201
269
  expect(fold_is_hierarchical(descs, "sites")).toBe(true);
202
- expect(fold_is_hierarchical(descs, "buildings")).toBe(false);
270
+ expect(fold_is_hierarchical(descs, "owners")).toBe(true);
271
+ expect(fold_is_hierarchical(descs, "devices")).toBe(false);
272
+ expect(fold_is_hierarchical(descs, "notes")).toBe(false);
203
273
  expect(fold_is_hierarchical(descs, "groups")).toBe(false);
204
274
  /* c reaches x and nothing reaches itself: no trunk at all */
205
275
  let c = {topic_name: "c", cols: [{id: "id", flag: []},
@@ -210,11 +280,30 @@ describe("main topic, hidden topics, loose records", () => {
210
280
  expect(fold_main_topic({sites: sites_desc})).toBe("sites");
211
281
  });
212
282
 
283
+ test("a tie is broken by schema order: the first of the tied topics", () => {
284
+ /* without notes, sites and owners both reach devices alone */
285
+ let tied = {sites: sites_desc, owners: owners_desc, devices: devices_desc};
286
+ expect(fold_main_topic(tied)).toBe("sites");
287
+ let tied_back = {owners: owners_desc, sites: sites_desc, devices: devices_desc};
288
+ expect(fold_main_topic(tied_back)).toBe("owners");
289
+ expect(fold_build_model(tied_back, {}).main_topic).toBe("owners");
290
+ });
291
+
292
+ test("two topics marked: the first in schema order wins", () => {
293
+ let sites_marked = Object.assign({}, sites_desc, {main_topic: true});
294
+ let owners_marked = Object.assign({}, owners_desc, {main_topic: true});
295
+ /* owners first: the deduction would pick sites, the marks owners */
296
+ expect(fold_main_topic({owners: owners_marked, sites: sites_marked,
297
+ devices: devices_desc, notes: notes_desc})).toBe("owners");
298
+ expect(fold_main_topic({sites: sites_marked, owners: owners_marked,
299
+ devices: devices_desc, notes: notes_desc})).toBe("sites");
300
+ });
301
+
213
302
  test("the schema's mark wins over the deduction, among hierarchical topics", () => {
214
- let d = Object.assign({}, descs, {buildings: buildings_self});
215
- expect(fold_main_topic(d)).toBe("sites"); /* sites reaches more */
216
- let marked = Object.assign({}, d, {buildings: Object.assign({}, buildings_self, {main_topic: true})});
217
- expect(fold_main_topic(marked)).toBe("buildings");
303
+ /* two hierarchical topics; sites reaches more (devices, notes) */
304
+ expect(fold_main_topic(descs)).toBe("sites");
305
+ let marked = Object.assign({}, descs, {owners: Object.assign({}, owners_desc, {main_topic: true})});
306
+ expect(fold_main_topic(marked)).toBe("owners");
218
307
  /* a mark on a topic that is not hierarchical is not a trunk */
219
308
  let wrong = Object.assign({}, descs, {devices: Object.assign({}, devices_desc, {main_topic: true})});
220
309
  expect(fold_main_topic(wrong)).toBe("sites");
@@ -233,14 +322,13 @@ describe("main topic, hidden topics, loose records", () => {
233
322
  });
234
323
 
235
324
  test("the reader's pick wins -- if it is a hierarchical topic", () => {
236
- let d = Object.assign({}, descs, {buildings: buildings_self});
237
- let m = fold_build_model(d, make_records(3), {main_topic: "buildings"});
238
- expect(m.main_topic).toBe("buildings");
239
- expect([...m.linked].sort()).toEqual(["buildings", "devices"]);
240
- /* sites is not linked to buildings, so its roots are roots */
325
+ let m = fold_build_model(descs, make_records(3), {main_topic: "owners"});
326
+ expect(m.main_topic).toBe("owners");
327
+ expect([...m.linked].sort()).toEqual(["devices", "notes", "owners"]);
328
+ /* sites is not linked to owners, so its roots are roots */
241
329
  expect(m.groups.get(fold_root_group_key("sites"))).toEqual([K("sites", "region")]);
242
330
  /* a pick the rule refuses is ignored, and the trunk is deduced */
243
- let m2 = fold_build_model(descs, make_records(3), {main_topic: "buildings"});
331
+ let m2 = fold_build_model(descs, make_records(3), {main_topic: "devices"});
244
332
  expect(m2.main_topic).toBe("sites");
245
333
  });
246
334
 
@@ -256,42 +344,69 @@ describe("main topic, hidden topics, loose records", () => {
256
344
  expect(m2.loose.devices).toEqual([K("devices", "d_loose")]);
257
345
  });
258
346
 
259
- test("a device hanging from a loose building only is loose too, and follows it", () => {
347
+ test("a note on a loose device only is loose too, and follows it", () => {
260
348
  let recs = make_records(0);
261
- recs.buildings.push({id: "b_loose"});
262
- recs.devices.push({id: "d_under", building: ["buildings^b_loose^devices"]});
349
+ recs.devices.push({id: "d_loose"});
350
+ recs.notes.push({id: "n_under", device: ["devices^d_loose^notes"]});
263
351
  let m = fold_build_model(descs, recs);
264
- expect(m.loose.buildings).toEqual([K("buildings", "b_loose")]);
265
- expect(m.loose.devices).toEqual([K("devices", "d_under")]);
352
+ expect(m.loose.devices).toEqual([K("devices", "d_loose")]);
353
+ expect(m.loose.notes).toEqual([K("notes", "n_under")]);
266
354
  let st = fold_new_state(24);
267
355
  fold_expand_all(m, st);
268
- expect(fold_visible_set(m, st).has(K("devices", "d_under"))).toBe(false);
269
- let m2 = fold_build_model(descs, recs, {loose_topics: ["buildings"]});
356
+ expect(fold_visible_set(m, st).has(K("notes", "n_under"))).toBe(false);
357
+ let m2 = fold_build_model(descs, recs, {loose_topics: ["devices"]});
270
358
  fold_expand_all(m2, st);
271
- expect(fold_visible_set(m2, st).has(K("devices", "d_under"))).toBe(true);
359
+ expect(fold_visible_set(m2, st).has(K("notes", "n_under"))).toBe(true);
272
360
  });
273
361
 
274
362
  test("a hidden topic leaves the model whole: no node, no pill, no edge", () => {
275
363
  let m = fold_build_model(descs, make_records(30), {hidden_topics: ["devices"]});
276
- expect(m.topics).toEqual(["sites", "buildings", "groups"]);
364
+ expect(m.topics).toEqual(["sites", "notes", "owners", "groups"]);
277
365
  expect(m.totals.devices).toBe(30);
278
366
  expect(m.nodes.get(K("sites", "site1")).hooks.devices).toBeUndefined();
279
367
  expect(fold_pills_of(m, fold_new_state(24), K("sites", "site1")).map((p) => p.hook))
280
- .toEqual(["buildings"]);
368
+ .toEqual(["notes"]);
281
369
  expect(m.hidden.has("devices")).toBe(true);
282
370
  });
283
371
 
284
372
  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: ["buildings"]});
286
- /* d0..d9 hang from site1 AND b1: still under site1 */
373
+ /* devices sit between sites and notes: n_dev hangs from d0
374
+ * alone, n_both from d0 AND site1 */
375
+ let recs = make_records(2);
376
+ recs.notes.push({id: "n_dev", device: "devices^d0^notes"});
377
+ recs.notes.push({id: "n_both", site: "sites^site1^notes", device: "devices^d0^notes"});
378
+ let shown = fold_build_model(descs, recs);
379
+ expect(shown.loose.notes).toEqual([]);
380
+ expect(shown.nodes.get(K("notes", "n_dev")).parents.map((p) => p.node_key))
381
+ .toEqual([K("devices", "d0")]);
382
+ let m = fold_build_model(descs, recs, {hidden_topics: ["devices"]});
383
+ expect(m.main_topic).toBe("sites");
384
+ expect(m.nodes.get(K("notes", "n_dev")).parents).toEqual([]);
385
+ expect(m.loose.notes).toEqual([K("notes", "n_dev")]);
386
+ expect(m.groups.get(fold_root_group_key("notes"))).toBeUndefined();
387
+ expect(m.nodes.get(K("notes", "n_both")).parents.map((p) => p.node_key))
388
+ .toEqual([K("sites", "site1")]);
389
+ expect(m.groups.get(fold_group_key(K("sites", "site1"), "notes")))
390
+ .toEqual([K("notes", "n1"), K("notes", "n_both")]);
391
+ let st = fold_new_state(24);
392
+ fold_expand_all(m, st);
393
+ expect(fold_visible_set(m, st).has(K("notes", "n_dev"))).toBe(false);
394
+ let m2 = fold_build_model(descs, recs, {hidden_topics: ["devices"], loose_topics: ["notes"]});
395
+ expect(m2.groups.get(fold_root_group_key("notes"))).toEqual([K("notes", "n_dev")]);
396
+ });
397
+
398
+ test("hiding a side tree, or the main topic itself", () => {
399
+ let m = fold_build_model(descs, make_records(12), {hidden_topics: ["owners"]});
400
+ /* d0..d9 hang from site1 AND o1: still under site1 */
287
401
  expect(m.nodes.get(K("devices", "d0")).parents.length).toBe(1);
288
402
  expect(m.loose.devices).toEqual([]);
289
403
  /* sites hidden = the main topic gone: nothing governs, and
290
- * whatever has no parent left is a root -- b1, with d0 and d1
291
- * still hanging from it */
404
+ * whatever has no parent left is a root -- o1, with d0 and d1
405
+ * still hanging from it, and n1 */
292
406
  let m2 = fold_build_model(descs, make_records(2), {hidden_topics: ["sites"]});
293
407
  expect(m2.main_topic).toBe("");
294
- expect(m2.groups.get(fold_root_group_key("buildings"))).toEqual([K("buildings", "b1")]);
408
+ expect(m2.groups.get(fold_root_group_key("owners"))).toEqual([K("owners", "o1")]);
409
+ expect(m2.groups.get(fold_root_group_key("notes"))).toEqual([K("notes", "n1")]);
295
410
  expect(m2.groups.get(fold_root_group_key("devices"))).toBeUndefined();
296
411
  let m3 = fold_build_model(descs, {devices: [{id: "d9"}]}, {hidden_topics: ["sites"]});
297
412
  expect(m3.groups.get(fold_root_group_key("devices"))).toEqual([K("devices", "d9")]);
@@ -328,7 +443,7 @@ describe("depth", () => {
328
443
  let st = fold_new_state(24);
329
444
  fold_expand_to_depth(m, st, 1);
330
445
  expect([...fold_visible_set(m, st)].sort())
331
- .toEqual([K("groups", "g1"), K("sites", "region")]);
446
+ .toEqual([K("groups", "g1"), K("owners", "o1"), K("sites", "region")]);
332
447
  });
333
448
 
334
449
  test("depth 2 opens the roots' hooks on their first page", () => {
@@ -339,7 +454,9 @@ describe("depth", () => {
339
454
  expect(v.has(K("sites", "north"))).toBe(true);
340
455
  expect(v.has(K("sites", "south"))).toBe(true);
341
456
  expect(v.has(K("sites", "site1"))).toBe(false);
342
- expect(v.has(K("devices", "d0"))).toBe(false);
457
+ expect(v.has(K("devices", "d15"))).toBe(false);
458
+ /* o1 is a root: its devices are one level down */
459
+ expect(v.has(K("devices", "d0"))).toBe(true);
343
460
  });
344
461
 
345
462
  test("depth 4 reaches the devices, one page of them", () => {
@@ -350,7 +467,7 @@ describe("depth", () => {
350
467
  expect(v.has(K("devices", "d0"))).toBe(true);
351
468
  expect(v.has(K("devices", "d23"))).toBe(true);
352
469
  expect(v.has(K("devices", "d24"))).toBe(false);
353
- expect(v.has(K("buildings", "b1"))).toBe(true);
470
+ expect(v.has(K("notes", "n1"))).toBe(true);
354
471
  });
355
472
 
356
473
  test("expand all shows everything, collapse all the roots' first page", () => {
@@ -359,25 +476,29 @@ describe("depth", () => {
359
476
  fold_expand_all(m, st);
360
477
  expect(fold_visible_set(m, st).size).toBe(m.nodes.size);
361
478
  fold_collapse_all(m, st);
362
- expect(fold_visible_set(m, st).size).toBe(2);
479
+ expect(fold_visible_set(m, st).size).toBe(3);
363
480
  });
364
481
  });
365
482
 
366
483
  describe("levels of the main tree (the toolbar's stepper)", () => {
367
484
  test("levels count from the main topic's roots, down every hook", () => {
368
- let m = fold_build_model(descs, make_records(30));
369
- /* region 1, north/south 2, site1 3, its devices and b1 4 */
485
+ let recs = make_records(30);
486
+ recs.notes.push({id: "n2", site: "sites^north^notes", device: ["devices^d0^notes"]});
487
+ let m = fold_build_model(descs, recs);
488
+ /* region 1, north/south 2, site1 3, its devices and n1 4 */
370
489
  expect(m.levels).toBe(4);
371
490
  expect(m.level_of.get(K("sites", "region"))).toBe(1);
372
491
  expect(m.level_of.get(K("sites", "site1"))).toBe(3);
373
- /* d0 hangs from site1 (3) and b1 (4): the shallowest wins */
374
492
  expect(m.level_of.get(K("devices", "d0"))).toBe(4);
375
- /* groups is not tied to sites: a tree of its own, no level */
493
+ /* n2 hangs from north (2) and d0 (4): the shallowest wins */
494
+ expect(m.level_of.get(K("notes", "n2"))).toBe(3);
495
+ /* owners and groups are not tied to sites: trees of their own, no level */
496
+ expect(m.level_of.has(K("owners", "o1"))).toBe(false);
376
497
  expect(m.level_of.has(K("groups", "g1"))).toBe(false);
377
498
  });
378
499
 
379
500
  test("a hidden topic takes its levels with it", () => {
380
- let m = fold_build_model(descs, make_records(30), {hidden_topics: ["devices", "buildings"]});
501
+ let m = fold_build_model(descs, make_records(30), {hidden_topics: ["devices", "notes"]});
381
502
  expect(m.levels).toBe(3);
382
503
  let m0 = fold_build_model({}, {});
383
504
  expect(m0.levels).toBe(0);
@@ -397,7 +518,7 @@ describe("levels of the main tree (the toolbar's stepper)", () => {
397
518
  let st = fold_new_state(24);
398
519
  fold_expand_to_level(m, st, 1);
399
520
  expect([...fold_visible_set(m, st)].sort())
400
- .toEqual([K("groups", "g1"), K("sites", "region")]);
521
+ .toEqual([K("groups", "g1"), K("owners", "o1"), K("sites", "region")]);
401
522
  fold_open_levels(m, st, 2);
402
523
  let v = fold_visible_set(m, st);
403
524
  expect(v.has(K("sites", "north"))).toBe(true);
@@ -409,7 +530,9 @@ describe("levels of the main tree (the toolbar's stepper)", () => {
409
530
  v = fold_visible_set(m, st);
410
531
  expect(v.has(K("devices", "d23"))).toBe(true);
411
532
  expect(v.has(K("devices", "d24"))).toBe(false); /* one page */
412
- expect(v.has(K("buildings", "b1"))).toBe(true);
533
+ expect(v.has(K("notes", "n1"))).toBe(true);
534
+ /* the owners tree has no level: the stepper leaves it to its pills */
535
+ expect(fold_is_open(st, fold_group_key(K("owners", "o1"), "devices"))).toBe(false);
413
536
  });
414
537
 
415
538
  test("opening keeps the pages already shown; closing folds only from its level down", () => {
@@ -424,7 +547,7 @@ describe("levels of the main tree (the toolbar's stepper)", () => {
424
547
  let v = fold_visible_set(m, st);
425
548
  expect(v.has(K("sites", "site1"))).toBe(true); /* level 3 stays */
426
549
  expect(v.has(K("devices", "d0"))).toBe(false); /* its hooks folded */
427
- expect(v.has(K("buildings", "b1"))).toBe(false);
550
+ expect(v.has(K("notes", "n1"))).toBe(false);
428
551
  expect(fold_is_open(st, fold_group_key(K("sites", "north"), "sites"))).toBe(true);
429
552
  });
430
553
 
@@ -445,9 +568,9 @@ describe("toggle and pages", () => {
445
568
  fold_expand_to_depth(m, st, 3);
446
569
  let g = fold_group_key(K("sites", "site1"), "devices");
447
570
  expect(fold_toggle(m, st, g)).toBe(true);
448
- expect(fold_visible_set(m, st).has(K("devices", "d5"))).toBe(true);
571
+ expect(fold_visible_set(m, st).has(K("devices", "d15"))).toBe(true);
449
572
  expect(fold_toggle(m, st, g)).toBe(false);
450
- expect(fold_visible_set(m, st).has(K("devices", "d5"))).toBe(false);
573
+ expect(fold_visible_set(m, st).has(K("devices", "d15"))).toBe(false);
451
574
  });
452
575
 
453
576
  test("show more adds a page and stops at the total", () => {
@@ -465,22 +588,22 @@ describe("toggle and pages", () => {
465
588
  fold_expand_to_depth(m, st, 4);
466
589
  fold_toggle(m, st, fold_group_key(K("sites", "region"), "sites")); /* close */
467
590
  let v = fold_visible_set(m, st);
468
- expect(v.has(K("devices", "d0"))).toBe(false);
469
- expect(v.size).toBe(2);
591
+ expect(v.has(K("devices", "d15"))).toBe(false);
592
+ /* the three roots, and o1's ten devices, which o1 still shows */
593
+ expect(v.size).toBe(3 + 10);
470
594
  fold_toggle(m, st, fold_group_key(K("sites", "region"), "sites")); /* reopen */
471
- expect(fold_visible_set(m, st).has(K("devices", "d0"))).toBe(true);
595
+ expect(fold_visible_set(m, st).has(K("devices", "d15"))).toBe(true);
472
596
  });
473
597
 
474
598
  test("the union: folding one parent leaves the child where the other shows it", () => {
475
599
  let m = fold_build_model(descs, make_records(30));
476
600
  let st = fold_new_state(24);
477
- fold_expand_to_depth(m, st, 4);
601
+ fold_expand_to_depth(m, st, 4); /* site1's and o1's devices open */
478
602
  let g_site = fold_group_key(K("sites", "site1"), "devices");
479
- let g_bldg = fold_group_key(K("buildings", "b1"), "devices");
480
- fold_toggle(m, st, g_bldg); /* b1's devices open too */
603
+ expect(fold_is_open(st, fold_group_key(K("owners", "o1"), "devices"))).toBe(true);
481
604
  fold_toggle(m, st, g_site); /* site1's devices folded */
482
605
  let v = fold_visible_set(m, st);
483
- expect(v.has(K("devices", "d3"))).toBe(true); /* via b1 */
606
+ expect(v.has(K("devices", "d3"))).toBe(true); /* via o1 */
484
607
  expect(v.has(K("devices", "d15"))).toBe(false); /* only via site1 */
485
608
  });
486
609
 
@@ -503,9 +626,9 @@ describe("toggle and pages", () => {
503
626
  let st = fold_new_state(24);
504
627
  fold_expand_to_depth(m, st, 4);
505
628
  let pills = fold_pills_of(m, st, K("sites", "site1"));
506
- expect(pills.map((p) => p.hook)).toEqual(["devices", "buildings"]);
629
+ expect(pills.map((p) => p.hook)).toEqual(["devices", "notes"]);
507
630
  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: "buildings"});
631
+ expect(pills[1]).toMatchObject({total: 1, shown: 1, open: true, child_topic: "notes"});
509
632
  expect(fold_pills_of(m, st, K("sites", "south"))).toEqual([]);
510
633
  });
511
634
  });
@@ -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 (buildings, devices, users), a record may hang
10
- * from two parents (a device from its site AND its building), and
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 -- the site, not the
34
- * building, because the site's column came first -- and the
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 building with a hundred
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 building
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
- * c1 (hook rank 2); c1 -> d0 as well (second parent). */
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("c1", 172, 96),
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: "c1", rank: 2},
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: "c1", target: "d0", rank: 0},
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", "c1"]);
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("c1")).toEqual([]); /* d0 is site's */
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 c1 (96): row is 96 tall, the
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("c1").y).toBe(row3 + 48);
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), c1 (172) = 424 wide */
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("c1").x - pos.get("d1").x).toBe(58 + 10 + 86);
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("c1").x + 86;
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 c1 (172): column is 172 wide,
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("c1").x).toBe(col3 + 86);
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), c1 (96) = 196 tall */
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("c1").y - pos.get("d1").y).toBe(20 + 10 + 48);
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("c1").y + 48;
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("c1").y).toBe(base.get("c1").y + 50); /* pushed down, in order */
149
+ expect(pos.get("x1").y).toBe(base.get("x1").y + 50); /* pushed down, in order */
150
150
  });
151
151
  });
152
152
 
@@ -39,12 +39,12 @@ describe("entry_shown_lines", () => {
39
39
  const $e = painted({
40
40
  result: 0,
41
41
  comment: "db_history^7301: 500 nodes",
42
- data: {sites: [1, 2, 3], buildings: [4], devices: [5, 6]},
42
+ data: {sites: [1, 2, 3], owners: [4], devices: [5, 6]},
43
43
  });
44
44
  expect(entry_shown_lines($e)).toEqual([
45
45
  " • result: 0",
46
46
  " • comment: db_history^7301: 500 nodes",
47
- " ▸ data {sites:[…],buildings:[…],devices:[…]}",
47
+ " ▸ data {sites:[…],owners:[…],devices:[…]}",
48
48
  ]);
49
49
  });
50
50
 
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. Added for the node-tree
355
- * demo, but they earn their place in the set on their own: energy and
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");