@yuneta/gobj-ui 5.17.0 → 6.0.0

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
@@ -434,15 +434,17 @@ Logical DOM classes: `JSON_VIEWER`, `JSON_TOOLBAR`, `JSON_SEARCH`, `JSON_TREE`,
434
434
 
435
435
  `C_G6_NODES_TREE` (the record graph inside `C_YUI_TREEDB_GRAPH`) labels a card
436
436
  by what NAMES the record, which is not always what KEYS it. A topic whose id
437
- column is flagged `rowid` or `uuid` keys its records by a value nobody reads —
438
- that is the point of those flags and the name lives in the secondary key the
437
+ column is flagged `rowid`, `uuid` or `qualified` keys its records by something
438
+ that is not the plain name a counter, a random string, or the name with
439
+ every ancestor in front of it — and the name lives in the secondary key the
439
440
  topic declares (`pkey2s`). `treedb_system_schema` is the case that forced it:
440
- its `topics` and `cols` records are keyed by rowid and named in `value`, so the
441
- graph drew cards reading `181`, `225`, `193`.
441
+ its `topics` and `cols` records are named in `value`, so the graph drew cards
442
+ reading `181`, `225`, `193` while they were keyed by rowid, and would read the
443
+ whole path now that they are qualified.
442
444
 
443
445
  The rule is in **`treedb_node_label.js`** (pure, unit-tested): read the pkey
444
- column's flags from the desc; if the key is synthetic, take the first `pkey2s`
445
- field the record actually carries; otherwise keep the id. **The pkey is never
446
+ column's flags from the desc; if the key is not the plain name, take the first
447
+ `pkey2s` field the record actually carries; otherwise keep the id. **The pkey is never
446
448
  lost** — it is the card's tooltip, on the chip and on the entity card alike.
447
449
 
448
450
  It needs the descriptor to carry `pkey2s`, which `tranger2_topic_desc()` only
@@ -6472,6 +6472,7 @@ function build_form_field_conf(gobj, field_desc) {
6472
6472
  field_conf.extras.pattern = "^-?\\d+(\\.\\d+)?$";
6473
6473
  break;
6474
6474
  case "rowid":
6475
+ case "qualified":
6475
6476
  field_conf.tag = "input";
6476
6477
  field_conf.inputType = "text";
6477
6478
  break;
@@ -6613,7 +6614,8 @@ function build_fkey_ref$1(gobj, field_desc, value) {
6613
6614
  /************************************************************
6614
6615
  * Apply the form mode to the pkey field:
6615
6616
  * "update" -> pkey readonly, not required
6616
- * "create" -> pkey writable and required (readonly if rowid)
6617
+ * "create" -> pkey writable and required, unless the store
6618
+ * hands the key out itself (rowid, qualified)
6617
6619
  * Empty form_mode keeps the template-declared behaviour
6618
6620
  * (backward compatible).
6619
6621
  ************************************************************/
@@ -6626,8 +6628,8 @@ function apply_form_mode(gobj, $form) {
6626
6628
  (0, _yuneta_gobj_js.log_error)((0, _yuneta_gobj_js.sprintf)("%s: form_mode '%s' but form has no pkey field '%s'", (0, _yuneta_gobj_js.gobj_short_name)(gobj), mode, pkey));
6627
6629
  return;
6628
6630
  }
6629
- let is_rowid = $input.field_desc && $input.field_desc.type === "rowid";
6630
- if (mode === "create" && !is_rowid) {
6631
+ let type = $input.field_desc ? $input.field_desc.type : "";
6632
+ if (mode === "create" && !(type === "rowid" || type === "qualified")) {
6631
6633
  $input.removeAttribute("readonly");
6632
6634
  $input.setAttribute("required", "");
6633
6635
  } else {
@@ -7405,6 +7407,7 @@ function template2columns(gobj, columns, template, sub_elements) {
7405
7407
  };
7406
7408
  break;
7407
7409
  case "rowid":
7410
+ case "qualified":
7408
7411
  column = null;
7409
7412
  break;
7410
7413
  case "boolean":
@@ -7770,6 +7773,7 @@ function treedb_value_2_form_value(gobj, field_desc, value) {
7770
7773
  case "enum":
7771
7774
  case "uuid":
7772
7775
  case "rowid":
7776
+ case "qualified":
7773
7777
  case "password":
7774
7778
  case "email":
7775
7779
  case "url": break;
@@ -7853,6 +7857,7 @@ function form_value_2_treedb_value(gobj, field_desc, value) {
7853
7857
  case "enum":
7854
7858
  case "uuid":
7855
7859
  case "rowid":
7860
+ case "qualified":
7856
7861
  case "password":
7857
7862
  case "email":
7858
7863
  case "url": break;
@@ -16930,7 +16935,8 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
16930
16935
  case "email":
16931
16936
  case "tel":
16932
16937
  case "url":
16933
- case "rowid": break;
16938
+ case "rowid":
16939
+ case "qualified": break;
16934
16940
  case "integer": break;
16935
16941
  case "real": break;
16936
16942
  case "boolean": break;
@@ -17393,6 +17399,7 @@ function transform__form_value_2_treedb_value(gobj, col, value, operation) {
17393
17399
  const field_desc = (0, _yuneta_gobj_js.treedb_get_field_desc)(col);
17394
17400
  switch (field_desc.type) {
17395
17401
  case "rowid":
17402
+ case "qualified":
17396
17403
  if (operation === "create") value = "";
17397
17404
  break;
17398
17405
  case "string":
@@ -20355,14 +20362,17 @@ function register_c_yui_treedb_schema() {
20355
20362
  * What a node is CALLED, which is not always what it is
20356
20363
  * keyed by.
20357
20364
  *
20358
- * A topic whose id column is flagged `rowid` or `uuid` keys
20359
- * its records by a value nobody reads — that is the point of
20360
- * those flags and the name a human knows the record by
20361
- * lives in the secondary key the topic declares (`pkey2s`,
20362
- * carried in the desc since SDK > 7.13.0). The `topics` and
20363
- * `cols` topics of treedb_system_schema are the case that
20364
- * forced this: keyed by rowid, named in `value`, so every
20365
- * card in the graph read "181", "225", "193".
20365
+ * A topic whose id column is flagged `rowid`, `uuid` or
20366
+ * `qualified` keys its records by something that is not the
20367
+ * namea counter, a random string, or the name with every
20368
+ * ancestor in front of it — and the name a human knows the
20369
+ * record by lives in the secondary key the topic declares
20370
+ * (`pkey2s`, carried in the desc since SDK > 7.13.0). The
20371
+ * `topics` and `cols` topics of treedb_system_schema are the
20372
+ * case that forced this: named in `value`, so every card in
20373
+ * the graph read "181", "225", "193" while they were keyed by
20374
+ * rowid, and reads the whole path now that they are
20375
+ * qualified.
20366
20376
  *
20367
20377
  * The pkey stays reachable: it is the card's tooltip.
20368
20378
  *
@@ -20380,7 +20390,7 @@ function node_label(desc, record) {
20380
20390
  }
20381
20391
  }
20382
20392
  if (!id_col || !Array.isArray(id_col.flag)) return id;
20383
- if (id_col.flag.indexOf("rowid") < 0 && id_col.flag.indexOf("uuid") < 0) return id;
20393
+ if (id_col.flag.indexOf("rowid") < 0 && id_col.flag.indexOf("uuid") < 0 && id_col.flag.indexOf("qualified") < 0) return id;
20384
20394
  let pkey2s = desc.pkey2s;
20385
20395
  if (typeof pkey2s === "string") pkey2s = pkey2s ? [pkey2s] : [];
20386
20396
  if (!Array.isArray(pkey2s)) return id;
@@ -6467,6 +6467,7 @@ function build_form_field_conf(gobj, field_desc) {
6467
6467
  field_conf.extras.pattern = "^-?\\d+(\\.\\d+)?$";
6468
6468
  break;
6469
6469
  case "rowid":
6470
+ case "qualified":
6470
6471
  field_conf.tag = "input";
6471
6472
  field_conf.inputType = "text";
6472
6473
  break;
@@ -6608,7 +6609,8 @@ function build_fkey_ref$1(gobj, field_desc, value) {
6608
6609
  /************************************************************
6609
6610
  * Apply the form mode to the pkey field:
6610
6611
  * "update" -> pkey readonly, not required
6611
- * "create" -> pkey writable and required (readonly if rowid)
6612
+ * "create" -> pkey writable and required, unless the store
6613
+ * hands the key out itself (rowid, qualified)
6612
6614
  * Empty form_mode keeps the template-declared behaviour
6613
6615
  * (backward compatible).
6614
6616
  ************************************************************/
@@ -6621,8 +6623,8 @@ function apply_form_mode(gobj, $form) {
6621
6623
  log_error(sprintf("%s: form_mode '%s' but form has no pkey field '%s'", gobj_short_name(gobj), mode, pkey));
6622
6624
  return;
6623
6625
  }
6624
- let is_rowid = $input.field_desc && $input.field_desc.type === "rowid";
6625
- if (mode === "create" && !is_rowid) {
6626
+ let type = $input.field_desc ? $input.field_desc.type : "";
6627
+ if (mode === "create" && !(type === "rowid" || type === "qualified")) {
6626
6628
  $input.removeAttribute("readonly");
6627
6629
  $input.setAttribute("required", "");
6628
6630
  } else {
@@ -7400,6 +7402,7 @@ function template2columns(gobj, columns, template, sub_elements) {
7400
7402
  };
7401
7403
  break;
7402
7404
  case "rowid":
7405
+ case "qualified":
7403
7406
  column = null;
7404
7407
  break;
7405
7408
  case "boolean":
@@ -7765,6 +7768,7 @@ function treedb_value_2_form_value(gobj, field_desc, value) {
7765
7768
  case "enum":
7766
7769
  case "uuid":
7767
7770
  case "rowid":
7771
+ case "qualified":
7768
7772
  case "password":
7769
7773
  case "email":
7770
7774
  case "url": break;
@@ -7848,6 +7852,7 @@ function form_value_2_treedb_value(gobj, field_desc, value) {
7848
7852
  case "enum":
7849
7853
  case "uuid":
7850
7854
  case "rowid":
7855
+ case "qualified":
7851
7856
  case "password":
7852
7857
  case "email":
7853
7858
  case "url": break;
@@ -16925,7 +16930,8 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
16925
16930
  case "email":
16926
16931
  case "tel":
16927
16932
  case "url":
16928
- case "rowid": break;
16933
+ case "rowid":
16934
+ case "qualified": break;
16929
16935
  case "integer": break;
16930
16936
  case "real": break;
16931
16937
  case "boolean": break;
@@ -17388,6 +17394,7 @@ function transform__form_value_2_treedb_value(gobj, col, value, operation) {
17388
17394
  const field_desc = treedb_get_field_desc(col);
17389
17395
  switch (field_desc.type) {
17390
17396
  case "rowid":
17397
+ case "qualified":
17391
17398
  if (operation === "create") value = "";
17392
17399
  break;
17393
17400
  case "string":
@@ -20342,14 +20349,17 @@ function register_c_yui_treedb_schema() {
20342
20349
  * What a node is CALLED, which is not always what it is
20343
20350
  * keyed by.
20344
20351
  *
20345
- * A topic whose id column is flagged `rowid` or `uuid` keys
20346
- * its records by a value nobody reads — that is the point of
20347
- * those flags and the name a human knows the record by
20348
- * lives in the secondary key the topic declares (`pkey2s`,
20349
- * carried in the desc since SDK > 7.13.0). The `topics` and
20350
- * `cols` topics of treedb_system_schema are the case that
20351
- * forced this: keyed by rowid, named in `value`, so every
20352
- * card in the graph read "181", "225", "193".
20352
+ * A topic whose id column is flagged `rowid`, `uuid` or
20353
+ * `qualified` keys its records by something that is not the
20354
+ * namea counter, a random string, or the name with every
20355
+ * ancestor in front of it — and the name a human knows the
20356
+ * record by lives in the secondary key the topic declares
20357
+ * (`pkey2s`, carried in the desc since SDK > 7.13.0). The
20358
+ * `topics` and `cols` topics of treedb_system_schema are the
20359
+ * case that forced this: named in `value`, so every card in
20360
+ * the graph read "181", "225", "193" while they were keyed by
20361
+ * rowid, and reads the whole path now that they are
20362
+ * qualified.
20353
20363
  *
20354
20364
  * The pkey stays reachable: it is the card's tooltip.
20355
20365
  *
@@ -20367,7 +20377,7 @@ function node_label(desc, record) {
20367
20377
  }
20368
20378
  }
20369
20379
  if (!id_col || !Array.isArray(id_col.flag)) return id;
20370
- if (id_col.flag.indexOf("rowid") < 0 && id_col.flag.indexOf("uuid") < 0) return id;
20380
+ if (id_col.flag.indexOf("rowid") < 0 && id_col.flag.indexOf("uuid") < 0 && id_col.flag.indexOf("qualified") < 0) return id;
20371
20381
  let pkey2s = desc.pkey2s;
20372
20382
  if (typeof pkey2s === "string") pkey2s = pkey2s ? [pkey2s] : [];
20373
20383
  if (!Array.isArray(pkey2s)) return id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "5.17.0",
3
+ "version": "6.0.0",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -29,13 +29,13 @@
29
29
  "devDependencies": {
30
30
  "@rollup/plugin-terser": "^1.0.0",
31
31
  "@vitest/coverage-v8": "^4.1.10",
32
- "@yuneta/gobj-js": "^7.8.7",
32
+ "@yuneta/gobj-js": "^7.13.2",
33
33
  "vite": "^8.2.1",
34
34
  "vitest": "^4.1.10"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@antv/g6": "^5.1.0",
38
- "@yuneta/gobj-js": "^7.8.7",
38
+ "@yuneta/gobj-js": "^7.13.2",
39
39
  "bulma": "^1.0.4",
40
40
  "i18next": "^26.3.6",
41
41
  "maplibre-gl": "^6.1.0",
package/src/c_yui_form.js CHANGED
@@ -676,6 +676,7 @@ function build_form_field_conf(gobj, field_desc)
676
676
  break;
677
677
 
678
678
  case "rowid":
679
+ case "qualified":
679
680
  field_conf.tag = 'input';
680
681
  field_conf.inputType = 'text';
681
682
  break;
@@ -878,7 +879,8 @@ function build_fkey_ref(gobj, field_desc, value)
878
879
  /************************************************************
879
880
  * Apply the form mode to the pkey field:
880
881
  * "update" -> pkey readonly, not required
881
- * "create" -> pkey writable and required (readonly if rowid)
882
+ * "create" -> pkey writable and required, unless the store
883
+ * hands the key out itself (rowid, qualified)
882
884
  * Empty form_mode keeps the template-declared behaviour
883
885
  * (backward compatible).
884
886
  ************************************************************/
@@ -898,8 +900,11 @@ function apply_form_mode(gobj, $form)
898
900
  return;
899
901
  }
900
902
 
901
- let is_rowid = $input.field_desc && $input.field_desc.type === "rowid";
902
- if(mode === "create" && !is_rowid) {
903
+ /* A key the store composes is never typed: a rowid comes from the
904
+ * topic size, a qualified id from the parent and the name. */
905
+ let type = $input.field_desc? $input.field_desc.type: "";
906
+ let store_makes_the_key = (type === "rowid" || type === "qualified");
907
+ if(mode === "create" && !store_makes_the_key) {
903
908
  $input.removeAttribute("readonly");
904
909
  $input.setAttribute("required", "");
905
910
  } else {
@@ -1826,6 +1831,7 @@ function template2columns(gobj, columns, template, sub_elements)
1826
1831
  break;
1827
1832
 
1828
1833
  case "rowid":
1834
+ case "qualified":
1829
1835
  // field_conf.tag = 'input';
1830
1836
  // field_conf.inputType = 'text';
1831
1837
  column = null;
@@ -2448,6 +2454,7 @@ function treedb_value_2_form_value(gobj, field_desc, value)
2448
2454
  case "enum":
2449
2455
  case "uuid":
2450
2456
  case "rowid":
2457
+ case "qualified":
2451
2458
  case "password":
2452
2459
  case "email":
2453
2460
  case "url":
@@ -2572,6 +2579,7 @@ function form_value_2_treedb_value(gobj, field_desc, value)
2572
2579
  case "enum":
2573
2580
  case "uuid":
2574
2581
  case "rowid":
2582
+ case "qualified":
2575
2583
  case "password":
2576
2584
  case "email":
2577
2585
  case "url":
@@ -1082,7 +1082,8 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field)
1082
1082
  case "email": // string subtype — plain text in the cell
1083
1083
  case "tel": // string subtype — plain text in the cell
1084
1084
  case "url": // string subtype — plain text in the cell
1085
- case "rowid": // the record's own key — shown as it comes
1085
+ case "rowid": // the record's own key — shown as it comes
1086
+ case "qualified": // idem, the name with its ancestors in front
1086
1087
  break;
1087
1088
  case "integer":
1088
1089
  break;
@@ -1758,6 +1759,9 @@ function transform__form_value_2_treedb_value(gobj, col, value, operation)
1758
1759
 
1759
1760
  switch(field_desc.type) {
1760
1761
  case "rowid":
1762
+ case "qualified":
1763
+ /* The store hands the key out: a rowid from the topic size, a
1764
+ * qualified id from the parent and the name. */
1761
1765
  if(operation==="create") {
1762
1766
  value = "";
1763
1767
  }
@@ -14,14 +14,17 @@
14
14
  * What a node is CALLED, which is not always what it is
15
15
  * keyed by.
16
16
  *
17
- * A topic whose id column is flagged `rowid` or `uuid` keys
18
- * its records by a value nobody reads — that is the point of
19
- * those flags and the name a human knows the record by
20
- * lives in the secondary key the topic declares (`pkey2s`,
21
- * carried in the desc since SDK > 7.13.0). The `topics` and
22
- * `cols` topics of treedb_system_schema are the case that
23
- * forced this: keyed by rowid, named in `value`, so every
24
- * card in the graph read "181", "225", "193".
17
+ * A topic whose id column is flagged `rowid`, `uuid` or
18
+ * `qualified` keys its records by something that is not the
19
+ * namea counter, a random string, or the name with every
20
+ * ancestor in front of it — and the name a human knows the
21
+ * record by lives in the secondary key the topic declares
22
+ * (`pkey2s`, carried in the desc since SDK > 7.13.0). The
23
+ * `topics` and `cols` topics of treedb_system_schema are the
24
+ * case that forced this: named in `value`, so every card in
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.
25
28
  *
26
29
  * The pkey stays reachable: it is the card's tooltip.
27
30
  *
@@ -48,7 +51,10 @@ export function node_label(desc, record)
48
51
  if(!id_col || !Array.isArray(id_col.flag)) {
49
52
  return id;
50
53
  }
51
- if(id_col.flag.indexOf("rowid") < 0 && id_col.flag.indexOf("uuid") < 0) {
54
+ if(id_col.flag.indexOf("rowid") < 0 &&
55
+ id_col.flag.indexOf("uuid") < 0 &&
56
+ id_col.flag.indexOf("qualified") < 0
57
+ ) {
52
58
  return id;
53
59
  }
54
60
 
@@ -50,6 +50,20 @@ describe("node_label", () => {
50
50
  expect(node_label(desc, {id: "181", value: "yuno_role"})).toBe("yuno_role");
51
51
  });
52
52
 
53
+ it("treats a qualified pkey like a rowid one", () => {
54
+ let desc = {
55
+ ...COLS_DESC,
56
+ cols: [
57
+ {id: "id", type: "string", flag: ["persistent", "qualified"]},
58
+ {id: "value", type: "string", flag: ["persistent", "required"]},
59
+ ],
60
+ };
61
+ expect(node_label(desc, {
62
+ id: "treedb_yunovatioscodb.yunos.yuno_role",
63
+ value: "yuno_role",
64
+ })).toBe("yuno_role");
65
+ });
66
+
53
67
  it("treats a uuid pkey like a rowid one", () => {
54
68
  let desc = {
55
69
  ...COLS_DESC,