@yuneta/gobj-ui 7.23.187 → 7.23.189
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/dist/gobj-ui.cjs.js +43 -41
- package/dist/gobj-ui.es.js +43 -41
- package/package.json +1 -1
- package/src/c_yui_treedb_topics.js +20 -10
- package/src/treedb_node_label.js +50 -50
- package/src/treedb_node_label.test.js +57 -46
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -24751,10 +24751,9 @@ function open_json_viewer$1(gobj, opts) {
|
|
|
24751
24751
|
}
|
|
24752
24752
|
let mobile = is_mobile$2();
|
|
24753
24753
|
let shell = yui_shell_of(gobj);
|
|
24754
|
-
let
|
|
24755
|
-
|
|
24756
|
-
|
|
24757
|
-
}, gobj);
|
|
24754
|
+
let jv_kw = { subscriber: gobj };
|
|
24755
|
+
if (schema) jv_kw.json_data = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "descs");
|
|
24756
|
+
let jv = (0, _yuneta_gobj_js.gobj_create_service)(`treedb-topics-json-${(0, _yuneta_gobj_js.clean_name)((0, _yuneta_gobj_js.gobj_name)(gobj))}`, "C_YUI_JSON", jv_kw, gobj);
|
|
24758
24757
|
if (!jv) {
|
|
24759
24758
|
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot create the JSON viewer`);
|
|
24760
24759
|
return;
|
|
@@ -30399,54 +30398,57 @@ function plan_graph_saves(live, saved) {
|
|
|
30399
30398
|
* treedb_node_label.js
|
|
30400
30399
|
*
|
|
30401
30400
|
* Pure, testable logic behind the label of a node in the treedb
|
|
30402
|
-
* graph: WHAT A RECORD IS CALLED
|
|
30403
|
-
*
|
|
30404
|
-
* no DOM and no G6.
|
|
30401
|
+
* graph: WHAT A RECORD IS CALLED. Kept out of the gclass so it can
|
|
30402
|
+
* be unit-tested with no DOM and no G6.
|
|
30405
30403
|
*
|
|
30406
30404
|
* Copyright (c) 2026, ArtGins.
|
|
30407
30405
|
* All Rights Reserved.
|
|
30408
30406
|
***********************************************************************/
|
|
30409
|
-
|
|
30410
|
-
|
|
30411
|
-
*
|
|
30412
|
-
*
|
|
30413
|
-
*
|
|
30414
|
-
*
|
|
30415
|
-
*
|
|
30416
|
-
*
|
|
30417
|
-
*
|
|
30418
|
-
*
|
|
30419
|
-
*
|
|
30420
|
-
*
|
|
30421
|
-
*
|
|
30422
|
-
*
|
|
30423
|
-
*
|
|
30424
|
-
*
|
|
30425
|
-
*
|
|
30426
|
-
*
|
|
30427
|
-
*
|
|
30428
|
-
*
|
|
30429
|
-
*
|
|
30407
|
+
var SEP = " · ";
|
|
30408
|
+
/************************************************************
|
|
30409
|
+
* What a node is CALLED: **its id, and the secondary keys it
|
|
30410
|
+
* carries**.
|
|
30411
|
+
*
|
|
30412
|
+
* A record is one thing and an INSTANCE of it is another: the
|
|
30413
|
+
* topic keys the record by `id` and the instance by the
|
|
30414
|
+
* columns it declares in `pkey2s`. A card that shows one
|
|
30415
|
+
* without the other is a card that cannot be identified --
|
|
30416
|
+
* and it used to show one INSTEAD of the other, so the yunos
|
|
30417
|
+
* of an agent read `7.23.0-1`, `7.23.0-1`, `7.23.0-1` (the
|
|
30418
|
+
* release, which they share) and never said which yuno each
|
|
30419
|
+
* one was, while a `configurations` card read `1`.
|
|
30420
|
+
*
|
|
30421
|
+
* It came from the opposite case, and that one still works:
|
|
30422
|
+
* the `topics` and `cols` of treedb_system_schema are keyed
|
|
30423
|
+
* by a rowid, so the card said "181" and the name lived in
|
|
30424
|
+
* the pkey2. Now it says both -- `181 · yuno_role` -- which
|
|
30425
|
+
* is what the record is: that name, under that key.
|
|
30426
|
+
*
|
|
30427
|
+
* Rules:
|
|
30428
|
+
* - the id always opens the label;
|
|
30429
|
+
* - every pkey2 the record carries follows it, in the
|
|
30430
|
+
* order the topic declares them, separated by `·`;
|
|
30431
|
+
* - a pkey2 whose value is empty, absent or equal to the
|
|
30432
|
+
* id adds nothing;
|
|
30433
|
+
* - a desc with no `pkey2s` (an older node's schema
|
|
30434
|
+
* included) gives the bare id.
|
|
30430
30435
|
************************************************************/
|
|
30431
30436
|
function node_label(desc, record) {
|
|
30432
30437
|
let id = record.id;
|
|
30433
|
-
let
|
|
30434
|
-
if (Array.isArray(desc.cols)) {
|
|
30435
|
-
for (let col of desc.cols) if (col && col.id === (desc.pkey || "id")) {
|
|
30436
|
-
id_col = col;
|
|
30437
|
-
break;
|
|
30438
|
-
}
|
|
30439
|
-
}
|
|
30440
|
-
if (!id_col || !Array.isArray(id_col.flag)) return id;
|
|
30441
|
-
if (id_col.flag.indexOf("rowid") < 0 && id_col.flag.indexOf("uuid") < 0 && id_col.flag.indexOf("qualified") < 0) return id;
|
|
30442
|
-
let pkey2s = desc.pkey2s;
|
|
30438
|
+
let pkey2s = desc ? desc.pkey2s : null;
|
|
30443
30439
|
if (typeof pkey2s === "string") pkey2s = pkey2s ? [pkey2s] : [];
|
|
30444
|
-
if (!Array.isArray(pkey2s)) return id;
|
|
30440
|
+
if (!Array.isArray(pkey2s) || pkey2s.length === 0) return id;
|
|
30441
|
+
let parts = [];
|
|
30445
30442
|
for (let name of pkey2s) {
|
|
30443
|
+
if (!name) continue;
|
|
30446
30444
|
let value = record[name];
|
|
30447
|
-
if (typeof value === "
|
|
30445
|
+
if (typeof value === "number") value = String(value);
|
|
30446
|
+
if (typeof value !== "string" || value.length === 0) continue;
|
|
30447
|
+
if (value === String(id)) continue;
|
|
30448
|
+
parts.push(value);
|
|
30448
30449
|
}
|
|
30449
|
-
return id;
|
|
30450
|
+
if (parts.length === 0) return id;
|
|
30451
|
+
return [id, ...parts].join(SEP);
|
|
30450
30452
|
}
|
|
30451
30453
|
//#endregion
|
|
30452
30454
|
//#region src/treedb_fold_model.js
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -24746,10 +24746,9 @@ function open_json_viewer$1(gobj, opts) {
|
|
|
24746
24746
|
}
|
|
24747
24747
|
let mobile = is_mobile$2();
|
|
24748
24748
|
let shell = yui_shell_of(gobj);
|
|
24749
|
-
let
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
}, gobj);
|
|
24749
|
+
let jv_kw = { subscriber: gobj };
|
|
24750
|
+
if (schema) jv_kw.json_data = gobj_read_attr(gobj, "descs");
|
|
24751
|
+
let jv = gobj_create_service(`treedb-topics-json-${clean_name(gobj_name(gobj))}`, "C_YUI_JSON", jv_kw, gobj);
|
|
24753
24752
|
if (!jv) {
|
|
24754
24753
|
log_error(`${gobj_short_name(gobj)}: cannot create the JSON viewer`);
|
|
24755
24754
|
return;
|
|
@@ -30394,54 +30393,57 @@ function plan_graph_saves(live, saved) {
|
|
|
30394
30393
|
* treedb_node_label.js
|
|
30395
30394
|
*
|
|
30396
30395
|
* Pure, testable logic behind the label of a node in the treedb
|
|
30397
|
-
* graph: WHAT A RECORD IS CALLED
|
|
30398
|
-
*
|
|
30399
|
-
* no DOM and no G6.
|
|
30396
|
+
* graph: WHAT A RECORD IS CALLED. Kept out of the gclass so it can
|
|
30397
|
+
* be unit-tested with no DOM and no G6.
|
|
30400
30398
|
*
|
|
30401
30399
|
* Copyright (c) 2026, ArtGins.
|
|
30402
30400
|
* All Rights Reserved.
|
|
30403
30401
|
***********************************************************************/
|
|
30404
|
-
|
|
30405
|
-
|
|
30406
|
-
*
|
|
30407
|
-
*
|
|
30408
|
-
*
|
|
30409
|
-
*
|
|
30410
|
-
*
|
|
30411
|
-
*
|
|
30412
|
-
*
|
|
30413
|
-
*
|
|
30414
|
-
*
|
|
30415
|
-
*
|
|
30416
|
-
*
|
|
30417
|
-
*
|
|
30418
|
-
*
|
|
30419
|
-
*
|
|
30420
|
-
*
|
|
30421
|
-
*
|
|
30422
|
-
*
|
|
30423
|
-
*
|
|
30424
|
-
*
|
|
30402
|
+
var SEP = " · ";
|
|
30403
|
+
/************************************************************
|
|
30404
|
+
* What a node is CALLED: **its id, and the secondary keys it
|
|
30405
|
+
* carries**.
|
|
30406
|
+
*
|
|
30407
|
+
* A record is one thing and an INSTANCE of it is another: the
|
|
30408
|
+
* topic keys the record by `id` and the instance by the
|
|
30409
|
+
* columns it declares in `pkey2s`. A card that shows one
|
|
30410
|
+
* without the other is a card that cannot be identified --
|
|
30411
|
+
* and it used to show one INSTEAD of the other, so the yunos
|
|
30412
|
+
* of an agent read `7.23.0-1`, `7.23.0-1`, `7.23.0-1` (the
|
|
30413
|
+
* release, which they share) and never said which yuno each
|
|
30414
|
+
* one was, while a `configurations` card read `1`.
|
|
30415
|
+
*
|
|
30416
|
+
* It came from the opposite case, and that one still works:
|
|
30417
|
+
* the `topics` and `cols` of treedb_system_schema are keyed
|
|
30418
|
+
* by a rowid, so the card said "181" and the name lived in
|
|
30419
|
+
* the pkey2. Now it says both -- `181 · yuno_role` -- which
|
|
30420
|
+
* is what the record is: that name, under that key.
|
|
30421
|
+
*
|
|
30422
|
+
* Rules:
|
|
30423
|
+
* - the id always opens the label;
|
|
30424
|
+
* - every pkey2 the record carries follows it, in the
|
|
30425
|
+
* order the topic declares them, separated by `·`;
|
|
30426
|
+
* - a pkey2 whose value is empty, absent or equal to the
|
|
30427
|
+
* id adds nothing;
|
|
30428
|
+
* - a desc with no `pkey2s` (an older node's schema
|
|
30429
|
+
* included) gives the bare id.
|
|
30425
30430
|
************************************************************/
|
|
30426
30431
|
function node_label(desc, record) {
|
|
30427
30432
|
let id = record.id;
|
|
30428
|
-
let
|
|
30429
|
-
if (Array.isArray(desc.cols)) {
|
|
30430
|
-
for (let col of desc.cols) if (col && col.id === (desc.pkey || "id")) {
|
|
30431
|
-
id_col = col;
|
|
30432
|
-
break;
|
|
30433
|
-
}
|
|
30434
|
-
}
|
|
30435
|
-
if (!id_col || !Array.isArray(id_col.flag)) return id;
|
|
30436
|
-
if (id_col.flag.indexOf("rowid") < 0 && id_col.flag.indexOf("uuid") < 0 && id_col.flag.indexOf("qualified") < 0) return id;
|
|
30437
|
-
let pkey2s = desc.pkey2s;
|
|
30433
|
+
let pkey2s = desc ? desc.pkey2s : null;
|
|
30438
30434
|
if (typeof pkey2s === "string") pkey2s = pkey2s ? [pkey2s] : [];
|
|
30439
|
-
if (!Array.isArray(pkey2s)) return id;
|
|
30435
|
+
if (!Array.isArray(pkey2s) || pkey2s.length === 0) return id;
|
|
30436
|
+
let parts = [];
|
|
30440
30437
|
for (let name of pkey2s) {
|
|
30438
|
+
if (!name) continue;
|
|
30441
30439
|
let value = record[name];
|
|
30442
|
-
if (typeof value === "
|
|
30440
|
+
if (typeof value === "number") value = String(value);
|
|
30441
|
+
if (typeof value !== "string" || value.length === 0) continue;
|
|
30442
|
+
if (value === String(id)) continue;
|
|
30443
|
+
parts.push(value);
|
|
30443
30444
|
}
|
|
30444
|
-
return id;
|
|
30445
|
+
if (parts.length === 0) return id;
|
|
30446
|
+
return [id, ...parts].join(SEP);
|
|
30445
30447
|
}
|
|
30446
30448
|
//#endregion
|
|
30447
30449
|
//#region src/treedb_fold_model.js
|
package/package.json
CHANGED
|
@@ -1718,19 +1718,29 @@ function open_json_viewer(gobj, opts)
|
|
|
1718
1718
|
let mobile = is_mobile();
|
|
1719
1719
|
let shell = yui_shell_of(gobj);
|
|
1720
1720
|
|
|
1721
|
+
/* No `title`: the host titles it — the window's title bar on
|
|
1722
|
+
* desktop, the dialog's header on mobile. The viewer's own title
|
|
1723
|
+
* would land INSIDE that host, doubling it. */
|
|
1724
|
+
let jv_kw = {
|
|
1725
|
+
subscriber: gobj /* publishes EV_EXPAND_PATH to us */
|
|
1726
|
+
};
|
|
1727
|
+
if(schema) {
|
|
1728
|
+
/* The schema is here already and it is small: it goes in whole,
|
|
1729
|
+
* and no drill-down happens because nothing is collapsed.
|
|
1730
|
+
*
|
|
1731
|
+
* Written as `json_data: schema? descs : null` it cost two
|
|
1732
|
+
* errors on EVERY raw-json open: a `DTP_JSON` attr takes a dict
|
|
1733
|
+
* or a list, and gobj-js REFUSES a null with "attr must be a
|
|
1734
|
+
* json dict/list" -- and then json2data() fails and the create
|
|
1735
|
+
* carries on with the attr unset. An attr you have nothing to
|
|
1736
|
+
* say about is one you do not mention. */
|
|
1737
|
+
jv_kw.json_data = gobj_read_attr(gobj, "descs");
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1721
1740
|
let jv = gobj_create_service(
|
|
1722
1741
|
`treedb-topics-json-${clean_name(gobj_name(gobj))}`,
|
|
1723
1742
|
"C_YUI_JSON",
|
|
1724
|
-
|
|
1725
|
-
/* No `title`: the host titles it — the window's title bar on
|
|
1726
|
-
* desktop, the dialog's header on mobile. The viewer's own
|
|
1727
|
-
* title would land INSIDE that host, doubling it. */
|
|
1728
|
-
subscriber: gobj, /* publishes EV_EXPAND_PATH to us */
|
|
1729
|
-
/* The schema is here already and it is small: it goes in
|
|
1730
|
-
* whole, and no drill-down happens because nothing is
|
|
1731
|
-
* collapsed. */
|
|
1732
|
-
json_data: schema? gobj_read_attr(gobj, "descs") : null
|
|
1733
|
-
},
|
|
1743
|
+
jv_kw,
|
|
1734
1744
|
gobj
|
|
1735
1745
|
);
|
|
1736
1746
|
if(!jv) {
|
package/src/treedb_node_label.js
CHANGED
|
@@ -2,78 +2,78 @@
|
|
|
2
2
|
* treedb_node_label.js
|
|
3
3
|
*
|
|
4
4
|
* Pure, testable logic behind the label of a node in the treedb
|
|
5
|
-
* graph: WHAT A RECORD IS CALLED
|
|
6
|
-
*
|
|
7
|
-
* no DOM and no G6.
|
|
5
|
+
* graph: WHAT A RECORD IS CALLED. Kept out of the gclass so it can
|
|
6
|
+
* be unit-tested with no DOM and no G6.
|
|
8
7
|
*
|
|
9
8
|
* Copyright (c) 2026, ArtGins.
|
|
10
9
|
* All Rights Reserved.
|
|
11
10
|
***********************************************************************/
|
|
12
11
|
|
|
12
|
+
const SEP = " · "; /* the middle dot the shell titles use */
|
|
13
|
+
|
|
13
14
|
/************************************************************
|
|
14
|
-
* What a node is CALLED,
|
|
15
|
-
*
|
|
15
|
+
* What a node is CALLED: **its id, and the secondary keys it
|
|
16
|
+
* carries**.
|
|
16
17
|
*
|
|
17
|
-
* A
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* the graph read "181", "225", "193" while they were keyed by
|
|
26
|
-
* rowid, and reads the whole path now that they are
|
|
27
|
-
* qualified.
|
|
18
|
+
* A record is one thing and an INSTANCE of it is another: the
|
|
19
|
+
* topic keys the record by `id` and the instance by the
|
|
20
|
+
* columns it declares in `pkey2s`. A card that shows one
|
|
21
|
+
* without the other is a card that cannot be identified --
|
|
22
|
+
* and it used to show one INSTEAD of the other, so the yunos
|
|
23
|
+
* of an agent read `7.23.0-1`, `7.23.0-1`, `7.23.0-1` (the
|
|
24
|
+
* release, which they share) and never said which yuno each
|
|
25
|
+
* one was, while a `configurations` card read `1`.
|
|
28
26
|
*
|
|
29
|
-
*
|
|
27
|
+
* It came from the opposite case, and that one still works:
|
|
28
|
+
* the `topics` and `cols` of treedb_system_schema are keyed
|
|
29
|
+
* by a rowid, so the card said "181" and the name lived in
|
|
30
|
+
* the pkey2. Now it says both -- `181 · yuno_role` -- which
|
|
31
|
+
* is what the record is: that name, under that key.
|
|
30
32
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
33
|
+
* Rules:
|
|
34
|
+
* - the id always opens the label;
|
|
35
|
+
* - every pkey2 the record carries follows it, in the
|
|
36
|
+
* order the topic declares them, separated by `·`;
|
|
37
|
+
* - a pkey2 whose value is empty, absent or equal to the
|
|
38
|
+
* id adds nothing;
|
|
39
|
+
* - a desc with no `pkey2s` (an older node's schema
|
|
40
|
+
* included) gives the bare id.
|
|
34
41
|
************************************************************/
|
|
35
42
|
export function node_label(desc, record)
|
|
36
43
|
{
|
|
37
|
-
/* treedb stores every record under `id
|
|
38
|
-
* tranger2_create_topic
|
|
39
|
-
* are read from whatever column the desc names as the pkey. */
|
|
44
|
+
/* treedb stores every record under `id`: the pkey name is fixed in
|
|
45
|
+
* tranger2_create_topic, whatever the desc calls it. */
|
|
40
46
|
let id = record.id;
|
|
41
47
|
|
|
42
|
-
let
|
|
43
|
-
if(Array.isArray(desc.cols)) {
|
|
44
|
-
for(let col of desc.cols) {
|
|
45
|
-
if(col && col.id === (desc.pkey || "id")) {
|
|
46
|
-
id_col = col;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if(!id_col || !Array.isArray(id_col.flag)) {
|
|
52
|
-
return id;
|
|
53
|
-
}
|
|
54
|
-
if(id_col.flag.indexOf("rowid") < 0 &&
|
|
55
|
-
id_col.flag.indexOf("uuid") < 0 &&
|
|
56
|
-
id_col.flag.indexOf("qualified") < 0
|
|
57
|
-
) {
|
|
58
|
-
return id;
|
|
59
|
-
}
|
|
60
|
-
|
|
48
|
+
let pkey2s = desc? desc.pkey2s : null;
|
|
61
49
|
/* `pkey2s` is a list in the desc, but the schema literal may
|
|
62
|
-
* declare it as a bare string
|
|
63
|
-
let pkey2s = desc.pkey2s;
|
|
50
|
+
* declare it as a bare string -- take either. */
|
|
64
51
|
if(typeof pkey2s === "string") {
|
|
65
52
|
pkey2s = pkey2s? [pkey2s] : [];
|
|
66
53
|
}
|
|
67
|
-
if(!Array.isArray(pkey2s)) {
|
|
54
|
+
if(!Array.isArray(pkey2s) || pkey2s.length === 0) {
|
|
68
55
|
return id;
|
|
69
56
|
}
|
|
57
|
+
|
|
58
|
+
let parts = [];
|
|
70
59
|
for(let name of pkey2s) {
|
|
60
|
+
if(!name) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
71
63
|
let value = record[name];
|
|
72
|
-
if(typeof value === "
|
|
73
|
-
|
|
64
|
+
if(typeof value === "number") {
|
|
65
|
+
value = String(value);
|
|
66
|
+
}
|
|
67
|
+
if(typeof value !== "string" || value.length === 0) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if(value === String(id)) {
|
|
71
|
+
continue; /* the same thing twice says nothing */
|
|
74
72
|
}
|
|
73
|
+
parts.push(value);
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
if(parts.length === 0) {
|
|
76
|
+
return id;
|
|
77
|
+
}
|
|
78
|
+
return [id, ...parts].join(SEP);
|
|
78
79
|
}
|
|
79
|
-
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/***********************************************************************
|
|
2
2
|
* treedb_node_label.test.js
|
|
3
3
|
*
|
|
4
|
-
* The label of a treedb graph node:
|
|
5
|
-
* record
|
|
4
|
+
* The label of a treedb graph node: its id, and the secondary
|
|
5
|
+
* keys it carries. A record is one thing and an INSTANCE of it
|
|
6
|
+
* another, and a card that shows one without the other cannot be
|
|
7
|
+
* identified.
|
|
6
8
|
*
|
|
7
9
|
* Copyright (c) 2026, ArtGins.
|
|
8
10
|
* All Rights Reserved.
|
|
@@ -35,44 +37,67 @@ const REALMS_DESC = {
|
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
describe("node_label", () => {
|
|
38
|
-
|
|
40
|
+
const DOT = " \u00b7 ";
|
|
41
|
+
|
|
42
|
+
it("says the id AND the secondary key that names the record", () => {
|
|
39
43
|
expect(node_label(COLS_DESC, {id: "181", value: "yuno_role"}))
|
|
40
|
-
.toBe("yuno_role");
|
|
44
|
+
.toBe("181" + DOT + "yuno_role");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("says the id AND the instance: the case that brought it", () => {
|
|
48
|
+
/* Three yunos of one agent, all of release 7.23.0-1: the cards
|
|
49
|
+
* read `7.23.0-1` three times and never said which yuno. */
|
|
50
|
+
let yunos = {
|
|
51
|
+
topic_name: "yunos",
|
|
52
|
+
pkey: "id",
|
|
53
|
+
pkey2s: ["yuno_release"],
|
|
54
|
+
cols: [
|
|
55
|
+
{id: "id", type: "string", flag: ["persistent", "rowid"]},
|
|
56
|
+
{id: "yuno_release", type: "string", flag: ["persistent"]},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
expect(node_label(yunos, {id: "1", yuno_release: "7.23.0-1"}))
|
|
60
|
+
.toBe("1" + DOT + "7.23.0-1");
|
|
61
|
+
expect(node_label(yunos, {id: "1600", yuno_release: "1.8.1.0-2"}))
|
|
62
|
+
.toBe("1600" + DOT + "1.8.1.0-2");
|
|
41
63
|
});
|
|
42
64
|
|
|
43
|
-
it("
|
|
65
|
+
it("gives the bare id when the topic declares no secondary key", () => {
|
|
44
66
|
expect(node_label(REALMS_DESC, {id: "artgins.utilities.all", realm_name: "all"}))
|
|
45
67
|
.toBe("artgins.utilities.all");
|
|
46
68
|
});
|
|
47
69
|
|
|
48
70
|
it("accepts a pkey2s declared as a bare string", () => {
|
|
49
71
|
let desc = {...COLS_DESC, pkey2s: "value"};
|
|
50
|
-
expect(node_label(desc, {id: "181", value: "yuno_role"}))
|
|
72
|
+
expect(node_label(desc, {id: "181", value: "yuno_role"}))
|
|
73
|
+
.toBe("181" + DOT + "yuno_role");
|
|
51
74
|
});
|
|
52
75
|
|
|
53
|
-
it("
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
it("does not care what the id column is flagged", () => {
|
|
77
|
+
/* rowid, uuid, qualified or nothing at all: the id is shown
|
|
78
|
+
* either way, and the flags decide nothing here any more. */
|
|
79
|
+
for(let flag of [["persistent", "uuid"], ["persistent", "qualified"], ["persistent"]]) {
|
|
80
|
+
let desc = {
|
|
81
|
+
...COLS_DESC,
|
|
82
|
+
cols: [
|
|
83
|
+
{id: "id", type: "string", flag: flag},
|
|
84
|
+
{id: "value", type: "string", flag: ["persistent", "required"]},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
expect(node_label(desc, {id: "k", value: "named"})).toBe("k" + DOT + "named");
|
|
88
|
+
}
|
|
65
89
|
});
|
|
66
90
|
|
|
67
|
-
it("
|
|
68
|
-
let desc = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
expect(node_label(
|
|
91
|
+
it("says every secondary key the topic declares, in its order", () => {
|
|
92
|
+
let desc = {topic_name: "x", pkey: "id", pkey2s: ["a", "b"], cols: []};
|
|
93
|
+
expect(node_label(desc, {id: "7", a: "one", b: "two"}))
|
|
94
|
+
.toBe("7" + DOT + "one" + DOT + "two");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("skips a secondary key that is empty, absent or the id again", () => {
|
|
98
|
+
expect(node_label(COLS_DESC, {id: "181", value: ""})).toBe("181");
|
|
99
|
+
expect(node_label(COLS_DESC, {id: "181"})).toBe("181");
|
|
100
|
+
expect(node_label(COLS_DESC, {id: "181", value: "181"})).toBe("181");
|
|
76
101
|
});
|
|
77
102
|
|
|
78
103
|
it("falls back to the id when the desc carries no pkey2s (older node)", () => {
|
|
@@ -80,27 +105,13 @@ describe("node_label", () => {
|
|
|
80
105
|
expect(node_label(desc, {id: "181", value: "yuno_role"})).toBe("181");
|
|
81
106
|
});
|
|
82
107
|
|
|
83
|
-
it("
|
|
84
|
-
expect(node_label(COLS_DESC, {id: "
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("honours a pkey that is not called 'id'", () => {
|
|
89
|
-
let desc = {
|
|
90
|
-
topic_name: "x",
|
|
91
|
-
pkey: "key",
|
|
92
|
-
pkey2s: ["name"],
|
|
93
|
-
cols: [
|
|
94
|
-
{id: "key", type: "string", flag: ["persistent", "rowid"]},
|
|
95
|
-
{id: "name", type: "string", flag: ["persistent", "required"]},
|
|
96
|
-
/* A col called `id` that is NOT the pkey must not decide. */
|
|
97
|
-
{id: "id", type: "string", flag: ["persistent"]},
|
|
98
|
-
],
|
|
99
|
-
};
|
|
100
|
-
expect(node_label(desc, {id: "7", key: "7", name: "seven"})).toBe("seven");
|
|
108
|
+
it("takes a numeric secondary key as the text it is", () => {
|
|
109
|
+
expect(node_label(COLS_DESC, {id: "emailsender.artgins", value: 1}))
|
|
110
|
+
.toBe("emailsender.artgins" + DOT + "1");
|
|
101
111
|
});
|
|
102
112
|
|
|
103
|
-
it("survives a desc with no cols", () => {
|
|
113
|
+
it("survives a desc with no cols, and no desc at all", () => {
|
|
104
114
|
expect(node_label({topic_name: "x", pkey: "id"}, {id: "42"})).toBe("42");
|
|
115
|
+
expect(node_label(null, {id: "42"})).toBe("42");
|
|
105
116
|
});
|
|
106
117
|
});
|