@yuneta/gobj-ui 7.25.25 → 7.25.26
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
CHANGED
|
@@ -24914,6 +24914,13 @@ function subscribe_treedb$1(gobj, topic_name) {
|
|
|
24914
24914
|
"topic_name": topic_name
|
|
24915
24915
|
}
|
|
24916
24916
|
}, gobj);
|
|
24917
|
+
for (let event of ["EV_TREEDB_NODE_LINKED", "EV_TREEDB_NODE_UNLINKED"]) (0, _yuneta_gobj_js.gobj_subscribe_event)(gobj_remote_yuno, event, {
|
|
24918
|
+
__service__: treedb_name,
|
|
24919
|
+
__filter__: {
|
|
24920
|
+
"treedb_name": treedb_name,
|
|
24921
|
+
"parent_topic_name": topic_name
|
|
24922
|
+
}
|
|
24923
|
+
}, gobj);
|
|
24917
24924
|
}
|
|
24918
24925
|
/********************************************
|
|
24919
24926
|
*
|
|
@@ -24964,6 +24971,27 @@ function answered_record$1(data) {
|
|
|
24964
24971
|
return {};
|
|
24965
24972
|
}
|
|
24966
24973
|
/************************************************************
|
|
24974
|
+
* Command to remote service: one node, in the shape the table
|
|
24975
|
+
* reads its topic with (TABLE_READ_OPTIONS)
|
|
24976
|
+
************************************************************/
|
|
24977
|
+
function treedb_get_node$1(gobj, treedb_name, topic_name, node_id) {
|
|
24978
|
+
let gobj_remote_yuno = (0, _yuneta_gobj_js.gobj_read_pointer_attr)(gobj, "gobj_remote_yuno");
|
|
24979
|
+
let kw = {
|
|
24980
|
+
service: treedb_name,
|
|
24981
|
+
treedb_name,
|
|
24982
|
+
topic_name,
|
|
24983
|
+
node_id,
|
|
24984
|
+
options: Object.assign({}, TABLE_READ_OPTIONS)
|
|
24985
|
+
};
|
|
24986
|
+
kw.__md_command__ = { topic_name };
|
|
24987
|
+
let ret = (0, _yuneta_gobj_js.gobj_command)(gobj_remote_yuno, "node", kw, gobj);
|
|
24988
|
+
if (ret) {
|
|
24989
|
+
(0, _yuneta_gobj_js.log_error)(ret);
|
|
24990
|
+
return -1;
|
|
24991
|
+
}
|
|
24992
|
+
return 0;
|
|
24993
|
+
}
|
|
24994
|
+
/************************************************************
|
|
24967
24995
|
* Command to remote service
|
|
24968
24996
|
************************************************************/
|
|
24969
24997
|
function treedb_update_node$1(gobj, treedb_name, topic_name, record, options, form_write, created) {
|
|
@@ -25337,6 +25365,9 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
|
|
|
25337
25365
|
else (0, _yuneta_gobj_js.gobj_send_event)(gobj_topic_form, "EV_LOAD_NODES", answer.rows, gobj);
|
|
25338
25366
|
}
|
|
25339
25367
|
break;
|
|
25368
|
+
case "node":
|
|
25369
|
+
(0, _yuneta_gobj_js.gobj_send_event)(get_gobj_formtable(gobj, (0, _yuneta_gobj_js.kw_get_str)(gobj, kw_command, "topic_name", "", 0)), "EV_LOAD_NODE_UPDATED", [data], gobj);
|
|
25370
|
+
break;
|
|
25340
25371
|
case "create-node":
|
|
25341
25372
|
case "update-node":
|
|
25342
25373
|
case "delete-node":
|
|
@@ -25583,6 +25614,24 @@ function ac_treedb_node_updated$1(gobj, event, kw, src) {
|
|
|
25583
25614
|
}
|
|
25584
25615
|
/********************************************
|
|
25585
25616
|
* Remote subscription response
|
|
25617
|
+
* EV_TREEDB_NODE_LINKED / EV_TREEDB_NODE_UNLINKED: the relationship
|
|
25618
|
+
* ({hook_name, parent_topic_name, child_topic_name, parent_id,
|
|
25619
|
+
* child_id, treedb_name}), not a node. The parent's hook changed and
|
|
25620
|
+
* the event does not carry it: read the parent again.
|
|
25621
|
+
********************************************/
|
|
25622
|
+
function ac_treedb_node_linked$1(gobj, event, kw, src) {
|
|
25623
|
+
let treedb_name = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw, "treedb_name", "", 0);
|
|
25624
|
+
let parent_topic_name = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw, "parent_topic_name", "", 0);
|
|
25625
|
+
let parent_id = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw, "parent_id", "", 0);
|
|
25626
|
+
if (treedb_name !== (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "treedb_name")) return 0;
|
|
25627
|
+
if (!parent_topic_name || !parent_id) {
|
|
25628
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} without parent_topic_name/parent_id`);
|
|
25629
|
+
return -1;
|
|
25630
|
+
}
|
|
25631
|
+
return treedb_get_node$1(gobj, treedb_name, parent_topic_name, parent_id);
|
|
25632
|
+
}
|
|
25633
|
+
/********************************************
|
|
25634
|
+
* Remote subscription response
|
|
25586
25635
|
********************************************/
|
|
25587
25636
|
function ac_treedb_node_deleted$1(gobj, event, kw, src) {
|
|
25588
25637
|
let treedb_name = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw, "treedb_name", "", 0);
|
|
@@ -25952,6 +26001,16 @@ function create_gclass$6(gclass_name) {
|
|
|
25952
26001
|
ac_treedb_node_deleted$1,
|
|
25953
26002
|
null
|
|
25954
26003
|
],
|
|
26004
|
+
[
|
|
26005
|
+
"EV_TREEDB_NODE_LINKED",
|
|
26006
|
+
ac_treedb_node_linked$1,
|
|
26007
|
+
null
|
|
26008
|
+
],
|
|
26009
|
+
[
|
|
26010
|
+
"EV_TREEDB_NODE_UNLINKED",
|
|
26011
|
+
ac_treedb_node_linked$1,
|
|
26012
|
+
null
|
|
26013
|
+
],
|
|
25955
26014
|
[
|
|
25956
26015
|
"EV_CREATE_RECORD",
|
|
25957
26016
|
ac_create_record,
|
|
@@ -26073,6 +26132,8 @@ function create_gclass$6(gclass_name) {
|
|
|
26073
26132
|
["EV_TREEDB_NODE_CREATED", _yuneta_gobj_js.event_flag_t.EVF_PUBLIC_EVENT],
|
|
26074
26133
|
["EV_TREEDB_NODE_UPDATED", _yuneta_gobj_js.event_flag_t.EVF_PUBLIC_EVENT],
|
|
26075
26134
|
["EV_TREEDB_NODE_DELETED", _yuneta_gobj_js.event_flag_t.EVF_PUBLIC_EVENT],
|
|
26135
|
+
["EV_TREEDB_NODE_LINKED", _yuneta_gobj_js.event_flag_t.EVF_PUBLIC_EVENT],
|
|
26136
|
+
["EV_TREEDB_NODE_UNLINKED", _yuneta_gobj_js.event_flag_t.EVF_PUBLIC_EVENT],
|
|
26076
26137
|
["EV_CREATE_RECORD", 0],
|
|
26077
26138
|
["EV_UPDATE_RECORD", 0],
|
|
26078
26139
|
["EV_UPDATE_FIELD", 0],
|
|
@@ -68749,9 +68810,10 @@ function get_nodes(gobj, topic_name) {
|
|
|
68749
68810
|
* treedb_name}), with no `topic_name` — so they are subscribed ONCE, and
|
|
68750
68811
|
* filtered by treedb_name alone (a {topic_name} filter would match nothing).
|
|
68751
68812
|
*
|
|
68752
|
-
* NOTE: the backend only publishes them when its C_NODE service
|
|
68753
|
-
*
|
|
68754
|
-
* a link/unlink is announced the
|
|
68813
|
+
* NOTE: the backend only publishes them when its C_NODE service runs
|
|
68814
|
+
* with `with_link_events` (the default since SDK 7.25.23; a v1 backend
|
|
68815
|
+
* sets it off). Without it, a link/unlink is announced the
|
|
68816
|
+
* backward-compatible way — an
|
|
68755
68817
|
* EV_TREEDB_NODE_UPDATED of the PARENT — which cannot move an edge here:
|
|
68756
68818
|
* an edge IS a fkey of the CHILD (link-saves-child), and the parent's fkeys
|
|
68757
68819
|
* did not change. That is why an open Graph kept showing stale edges when
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -24909,6 +24909,13 @@ function subscribe_treedb$1(gobj, topic_name) {
|
|
|
24909
24909
|
"topic_name": topic_name
|
|
24910
24910
|
}
|
|
24911
24911
|
}, gobj);
|
|
24912
|
+
for (let event of ["EV_TREEDB_NODE_LINKED", "EV_TREEDB_NODE_UNLINKED"]) gobj_subscribe_event(gobj_remote_yuno, event, {
|
|
24913
|
+
__service__: treedb_name,
|
|
24914
|
+
__filter__: {
|
|
24915
|
+
"treedb_name": treedb_name,
|
|
24916
|
+
"parent_topic_name": topic_name
|
|
24917
|
+
}
|
|
24918
|
+
}, gobj);
|
|
24912
24919
|
}
|
|
24913
24920
|
/********************************************
|
|
24914
24921
|
*
|
|
@@ -24959,6 +24966,27 @@ function answered_record$1(data) {
|
|
|
24959
24966
|
return {};
|
|
24960
24967
|
}
|
|
24961
24968
|
/************************************************************
|
|
24969
|
+
* Command to remote service: one node, in the shape the table
|
|
24970
|
+
* reads its topic with (TABLE_READ_OPTIONS)
|
|
24971
|
+
************************************************************/
|
|
24972
|
+
function treedb_get_node$1(gobj, treedb_name, topic_name, node_id) {
|
|
24973
|
+
let gobj_remote_yuno = gobj_read_pointer_attr(gobj, "gobj_remote_yuno");
|
|
24974
|
+
let kw = {
|
|
24975
|
+
service: treedb_name,
|
|
24976
|
+
treedb_name,
|
|
24977
|
+
topic_name,
|
|
24978
|
+
node_id,
|
|
24979
|
+
options: Object.assign({}, TABLE_READ_OPTIONS)
|
|
24980
|
+
};
|
|
24981
|
+
kw.__md_command__ = { topic_name };
|
|
24982
|
+
let ret = gobj_command(gobj_remote_yuno, "node", kw, gobj);
|
|
24983
|
+
if (ret) {
|
|
24984
|
+
log_error(ret);
|
|
24985
|
+
return -1;
|
|
24986
|
+
}
|
|
24987
|
+
return 0;
|
|
24988
|
+
}
|
|
24989
|
+
/************************************************************
|
|
24962
24990
|
* Command to remote service
|
|
24963
24991
|
************************************************************/
|
|
24964
24992
|
function treedb_update_node$1(gobj, treedb_name, topic_name, record, options, form_write, created) {
|
|
@@ -25332,6 +25360,9 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
|
|
|
25332
25360
|
else gobj_send_event(gobj_topic_form, "EV_LOAD_NODES", answer.rows, gobj);
|
|
25333
25361
|
}
|
|
25334
25362
|
break;
|
|
25363
|
+
case "node":
|
|
25364
|
+
gobj_send_event(get_gobj_formtable(gobj, kw_get_str(gobj, kw_command, "topic_name", "", 0)), "EV_LOAD_NODE_UPDATED", [data], gobj);
|
|
25365
|
+
break;
|
|
25335
25366
|
case "create-node":
|
|
25336
25367
|
case "update-node":
|
|
25337
25368
|
case "delete-node":
|
|
@@ -25578,6 +25609,24 @@ function ac_treedb_node_updated$1(gobj, event, kw, src) {
|
|
|
25578
25609
|
}
|
|
25579
25610
|
/********************************************
|
|
25580
25611
|
* Remote subscription response
|
|
25612
|
+
* EV_TREEDB_NODE_LINKED / EV_TREEDB_NODE_UNLINKED: the relationship
|
|
25613
|
+
* ({hook_name, parent_topic_name, child_topic_name, parent_id,
|
|
25614
|
+
* child_id, treedb_name}), not a node. The parent's hook changed and
|
|
25615
|
+
* the event does not carry it: read the parent again.
|
|
25616
|
+
********************************************/
|
|
25617
|
+
function ac_treedb_node_linked$1(gobj, event, kw, src) {
|
|
25618
|
+
let treedb_name = kw_get_str(gobj, kw, "treedb_name", "", 0);
|
|
25619
|
+
let parent_topic_name = kw_get_str(gobj, kw, "parent_topic_name", "", 0);
|
|
25620
|
+
let parent_id = kw_get_str(gobj, kw, "parent_id", "", 0);
|
|
25621
|
+
if (treedb_name !== gobj_read_str_attr(gobj, "treedb_name")) return 0;
|
|
25622
|
+
if (!parent_topic_name || !parent_id) {
|
|
25623
|
+
log_error(`${gobj_short_name(gobj)}: ${event} without parent_topic_name/parent_id`);
|
|
25624
|
+
return -1;
|
|
25625
|
+
}
|
|
25626
|
+
return treedb_get_node$1(gobj, treedb_name, parent_topic_name, parent_id);
|
|
25627
|
+
}
|
|
25628
|
+
/********************************************
|
|
25629
|
+
* Remote subscription response
|
|
25581
25630
|
********************************************/
|
|
25582
25631
|
function ac_treedb_node_deleted$1(gobj, event, kw, src) {
|
|
25583
25632
|
let treedb_name = kw_get_str(gobj, kw, "treedb_name", "", 0);
|
|
@@ -25947,6 +25996,16 @@ function create_gclass$6(gclass_name) {
|
|
|
25947
25996
|
ac_treedb_node_deleted$1,
|
|
25948
25997
|
null
|
|
25949
25998
|
],
|
|
25999
|
+
[
|
|
26000
|
+
"EV_TREEDB_NODE_LINKED",
|
|
26001
|
+
ac_treedb_node_linked$1,
|
|
26002
|
+
null
|
|
26003
|
+
],
|
|
26004
|
+
[
|
|
26005
|
+
"EV_TREEDB_NODE_UNLINKED",
|
|
26006
|
+
ac_treedb_node_linked$1,
|
|
26007
|
+
null
|
|
26008
|
+
],
|
|
25950
26009
|
[
|
|
25951
26010
|
"EV_CREATE_RECORD",
|
|
25952
26011
|
ac_create_record,
|
|
@@ -26068,6 +26127,8 @@ function create_gclass$6(gclass_name) {
|
|
|
26068
26127
|
["EV_TREEDB_NODE_CREATED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
26069
26128
|
["EV_TREEDB_NODE_UPDATED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
26070
26129
|
["EV_TREEDB_NODE_DELETED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
26130
|
+
["EV_TREEDB_NODE_LINKED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
26131
|
+
["EV_TREEDB_NODE_UNLINKED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
26071
26132
|
["EV_CREATE_RECORD", 0],
|
|
26072
26133
|
["EV_UPDATE_RECORD", 0],
|
|
26073
26134
|
["EV_UPDATE_FIELD", 0],
|
|
@@ -68744,9 +68805,10 @@ function get_nodes(gobj, topic_name) {
|
|
|
68744
68805
|
* treedb_name}), with no `topic_name` — so they are subscribed ONCE, and
|
|
68745
68806
|
* filtered by treedb_name alone (a {topic_name} filter would match nothing).
|
|
68746
68807
|
*
|
|
68747
|
-
* NOTE: the backend only publishes them when its C_NODE service
|
|
68748
|
-
*
|
|
68749
|
-
* a link/unlink is announced the
|
|
68808
|
+
* NOTE: the backend only publishes them when its C_NODE service runs
|
|
68809
|
+
* with `with_link_events` (the default since SDK 7.25.23; a v1 backend
|
|
68810
|
+
* sets it off). Without it, a link/unlink is announced the
|
|
68811
|
+
* backward-compatible way — an
|
|
68750
68812
|
* EV_TREEDB_NODE_UPDATED of the PARENT — which cannot move an edge here:
|
|
68751
68813
|
* an edge IS a fkey of the CHILD (link-saves-child), and the parent's fkeys
|
|
68752
68814
|
* did not change. That is why an open Graph kept showing stale edges when
|
package/package.json
CHANGED
|
@@ -1889,9 +1889,10 @@ function get_nodes(gobj, topic_name)
|
|
|
1889
1889
|
* treedb_name}), with no `topic_name` — so they are subscribed ONCE, and
|
|
1890
1890
|
* filtered by treedb_name alone (a {topic_name} filter would match nothing).
|
|
1891
1891
|
*
|
|
1892
|
-
* NOTE: the backend only publishes them when its C_NODE service
|
|
1893
|
-
*
|
|
1894
|
-
* a link/unlink is announced the
|
|
1892
|
+
* NOTE: the backend only publishes them when its C_NODE service runs
|
|
1893
|
+
* with `with_link_events` (the default since SDK 7.25.23; a v1 backend
|
|
1894
|
+
* sets it off). Without it, a link/unlink is announced the
|
|
1895
|
+
* backward-compatible way — an
|
|
1895
1896
|
* EV_TREEDB_NODE_UPDATED of the PARENT — which cannot move an edge here:
|
|
1896
1897
|
* an edge IS a fkey of the CHILD (link-saves-child), and the parent's fkeys
|
|
1897
1898
|
* did not change. That is why an open Graph kept showing stale edges when
|
|
@@ -1492,6 +1492,27 @@ function subscribe_treedb(gobj, topic_name)
|
|
|
1492
1492
|
},
|
|
1493
1493
|
gobj
|
|
1494
1494
|
);
|
|
1495
|
+
|
|
1496
|
+
/*
|
|
1497
|
+
* A link/unlink changes the hook of the PARENT, and a backend with
|
|
1498
|
+
* `with_link_events` (the default since SDK 7.25.23) tells it as the
|
|
1499
|
+
* relationship, with no `topic_name`: the parent's topic is
|
|
1500
|
+
* `parent_topic_name`. The child's row moves on its own UPDATED.
|
|
1501
|
+
*/
|
|
1502
|
+
for(let event of ["EV_TREEDB_NODE_LINKED", "EV_TREEDB_NODE_UNLINKED"]) {
|
|
1503
|
+
gobj_subscribe_event(
|
|
1504
|
+
gobj_remote_yuno,
|
|
1505
|
+
event,
|
|
1506
|
+
{
|
|
1507
|
+
__service__: treedb_name,
|
|
1508
|
+
__filter__: {
|
|
1509
|
+
"treedb_name": treedb_name,
|
|
1510
|
+
"parent_topic_name": topic_name
|
|
1511
|
+
}
|
|
1512
|
+
},
|
|
1513
|
+
gobj
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1495
1516
|
}
|
|
1496
1517
|
|
|
1497
1518
|
/************************************************************
|
|
@@ -1502,9 +1523,9 @@ function subscribe_treedb(gobj, topic_name)
|
|
|
1502
1523
|
* fix, and no caller to add on that account.
|
|
1503
1524
|
*
|
|
1504
1525
|
* It is kept deliberately. It is the only place that knows the
|
|
1505
|
-
* exact shape the remote subscription was made with — the
|
|
1506
|
-
* events, `__service__` and the `treedb_name`+`topic_name`
|
|
1507
|
-
* filter — and a remote unsubscribe only lands if it matches
|
|
1526
|
+
* exact shape the remote subscription was made with — the five
|
|
1527
|
+
* events, `__service__` and the `treedb_name`+`topic_name` (or
|
|
1528
|
+
* `parent_topic_name`) filter — and a remote unsubscribe only lands if it matches
|
|
1508
1529
|
* the subscribe verbatim. Deleting it would not remove that
|
|
1509
1530
|
* knowledge, it would move it to whoever needs it next, to be
|
|
1510
1531
|
* rederived from the subscribe side and got right again.
|
|
@@ -1556,6 +1577,19 @@ function unsubscribe_treedb(gobj, topic_name)
|
|
|
1556
1577
|
},
|
|
1557
1578
|
gobj
|
|
1558
1579
|
);
|
|
1580
|
+
for(let event of ["EV_TREEDB_NODE_LINKED", "EV_TREEDB_NODE_UNLINKED"]) {
|
|
1581
|
+
gobj_unsubscribe_event(gobj_remote_yuno,
|
|
1582
|
+
event,
|
|
1583
|
+
{
|
|
1584
|
+
__service__: treedb_name,
|
|
1585
|
+
__filter__: {
|
|
1586
|
+
"treedb_name": treedb_name,
|
|
1587
|
+
"parent_topic_name": topic_name
|
|
1588
|
+
}
|
|
1589
|
+
},
|
|
1590
|
+
gobj
|
|
1591
|
+
);
|
|
1592
|
+
}
|
|
1559
1593
|
}
|
|
1560
1594
|
|
|
1561
1595
|
/********************************************
|
|
@@ -1645,6 +1679,38 @@ function answered_record(data)
|
|
|
1645
1679
|
return {};
|
|
1646
1680
|
}
|
|
1647
1681
|
|
|
1682
|
+
/************************************************************
|
|
1683
|
+
* Command to remote service: one node, in the shape the table
|
|
1684
|
+
* reads its topic with (TABLE_READ_OPTIONS)
|
|
1685
|
+
************************************************************/
|
|
1686
|
+
function treedb_get_node(gobj, treedb_name, topic_name, node_id)
|
|
1687
|
+
{
|
|
1688
|
+
let gobj_remote_yuno = gobj_read_pointer_attr(gobj, "gobj_remote_yuno");
|
|
1689
|
+
let kw = {
|
|
1690
|
+
service: treedb_name,
|
|
1691
|
+
treedb_name: treedb_name,
|
|
1692
|
+
topic_name: topic_name,
|
|
1693
|
+
node_id: node_id,
|
|
1694
|
+
options: Object.assign({}, TABLE_READ_OPTIONS)
|
|
1695
|
+
};
|
|
1696
|
+
|
|
1697
|
+
kw.__md_command__ = { // Data to be returned
|
|
1698
|
+
topic_name: topic_name,
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
let ret = gobj_command(
|
|
1702
|
+
gobj_remote_yuno,
|
|
1703
|
+
"node",
|
|
1704
|
+
kw,
|
|
1705
|
+
gobj
|
|
1706
|
+
);
|
|
1707
|
+
if(ret) {
|
|
1708
|
+
log_error(ret);
|
|
1709
|
+
return -1;
|
|
1710
|
+
}
|
|
1711
|
+
return 0;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1648
1714
|
/************************************************************
|
|
1649
1715
|
* Command to remote service
|
|
1650
1716
|
************************************************************/
|
|
@@ -2302,6 +2368,19 @@ function ac_mt_command_answer(gobj, event, kw, src)
|
|
|
2302
2368
|
}
|
|
2303
2369
|
break;
|
|
2304
2370
|
|
|
2371
|
+
case "node":
|
|
2372
|
+
/*
|
|
2373
|
+
* A parent re-read because a link or an unlink moved its hook
|
|
2374
|
+
* (ac_treedb_node_linked): an update of its row.
|
|
2375
|
+
*/
|
|
2376
|
+
gobj_send_event(
|
|
2377
|
+
get_gobj_formtable(gobj, kw_get_str(gobj, kw_command, "topic_name", "", 0)),
|
|
2378
|
+
"EV_LOAD_NODE_UPDATED",
|
|
2379
|
+
[data],
|
|
2380
|
+
gobj
|
|
2381
|
+
);
|
|
2382
|
+
break;
|
|
2383
|
+
|
|
2305
2384
|
case "create-node":
|
|
2306
2385
|
case "update-node":
|
|
2307
2386
|
case "delete-node":
|
|
@@ -2718,6 +2797,30 @@ function ac_treedb_node_updated(gobj, event, kw, src)
|
|
|
2718
2797
|
return 0;
|
|
2719
2798
|
}
|
|
2720
2799
|
|
|
2800
|
+
/********************************************
|
|
2801
|
+
* Remote subscription response
|
|
2802
|
+
* EV_TREEDB_NODE_LINKED / EV_TREEDB_NODE_UNLINKED: the relationship
|
|
2803
|
+
* ({hook_name, parent_topic_name, child_topic_name, parent_id,
|
|
2804
|
+
* child_id, treedb_name}), not a node. The parent's hook changed and
|
|
2805
|
+
* the event does not carry it: read the parent again.
|
|
2806
|
+
********************************************/
|
|
2807
|
+
function ac_treedb_node_linked(gobj, event, kw, src)
|
|
2808
|
+
{
|
|
2809
|
+
let treedb_name = kw_get_str(gobj, kw, "treedb_name", "", 0);
|
|
2810
|
+
let parent_topic_name = kw_get_str(gobj, kw, "parent_topic_name", "", 0);
|
|
2811
|
+
let parent_id = kw_get_str(gobj, kw, "parent_id", "", 0);
|
|
2812
|
+
|
|
2813
|
+
if(treedb_name !== gobj_read_str_attr(gobj, "treedb_name")) {
|
|
2814
|
+
return 0;
|
|
2815
|
+
}
|
|
2816
|
+
if(!parent_topic_name || !parent_id) {
|
|
2817
|
+
log_error(`${gobj_short_name(gobj)}: ${event} without parent_topic_name/parent_id`);
|
|
2818
|
+
return -1;
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
return treedb_get_node(gobj, treedb_name, parent_topic_name, parent_id); // Error already logged
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2721
2824
|
/********************************************
|
|
2722
2825
|
* Remote subscription response
|
|
2723
2826
|
********************************************/
|
|
@@ -3222,6 +3325,8 @@ function create_gclass(gclass_name)
|
|
|
3222
3325
|
["EV_TREEDB_NODE_CREATED", ac_treedb_node_created, null],
|
|
3223
3326
|
["EV_TREEDB_NODE_UPDATED", ac_treedb_node_updated, null],
|
|
3224
3327
|
["EV_TREEDB_NODE_DELETED", ac_treedb_node_deleted, null],
|
|
3328
|
+
["EV_TREEDB_NODE_LINKED", ac_treedb_node_linked, null],
|
|
3329
|
+
["EV_TREEDB_NODE_UNLINKED", ac_treedb_node_linked, null],
|
|
3225
3330
|
["EV_CREATE_RECORD", ac_create_record, null],
|
|
3226
3331
|
["EV_UPDATE_RECORD", ac_update_record, null],
|
|
3227
3332
|
["EV_UPDATE_FIELD", ac_update_field, null],
|
|
@@ -3256,6 +3361,8 @@ function create_gclass(gclass_name)
|
|
|
3256
3361
|
["EV_TREEDB_NODE_CREATED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
3257
3362
|
["EV_TREEDB_NODE_UPDATED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
3258
3363
|
["EV_TREEDB_NODE_DELETED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
3364
|
+
["EV_TREEDB_NODE_LINKED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
3365
|
+
["EV_TREEDB_NODE_UNLINKED", event_flag_t.EVF_PUBLIC_EVENT],
|
|
3259
3366
|
["EV_CREATE_RECORD", 0],
|
|
3260
3367
|
["EV_UPDATE_RECORD", 0],
|
|
3261
3368
|
["EV_UPDATE_FIELD", 0],
|
|
@@ -32,6 +32,7 @@ const logged = [];
|
|
|
32
32
|
const written = []; /* the EV_RECORD_WRITTEN the host heard */
|
|
33
33
|
const answers = []; /* what the fake forms were told */
|
|
34
34
|
const loaded = []; /* the rows each fake form was loaded with */
|
|
35
|
+
const updated = []; /* the rows each fake form was told changed */
|
|
35
36
|
const commands = []; /* what the fake transport was asked */
|
|
36
37
|
|
|
37
38
|
/*
|
|
@@ -65,6 +66,12 @@ function ac_form_load(gobj, event, kw, src)
|
|
|
65
66
|
return 0;
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
function ac_form_update(gobj, event, kw, src)
|
|
70
|
+
{
|
|
71
|
+
updated.push({topic: gobj.priv_topic, rows: kw});
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
let yuno = null;
|
|
69
76
|
let remote = null;
|
|
70
77
|
|
|
@@ -84,11 +91,13 @@ beforeAll(() => {
|
|
|
84
91
|
);
|
|
85
92
|
gclass_create(
|
|
86
93
|
"C_YUI_TREEDB_TOPIC_WITH_FORM",
|
|
87
|
-
[["EV_WRITE_DONE", 0], ["EV_WRITE_REFUSED", 0], ["EV_LOAD_NODES", 0]
|
|
94
|
+
[["EV_WRITE_DONE", 0], ["EV_WRITE_REFUSED", 0], ["EV_LOAD_NODES", 0],
|
|
95
|
+
["EV_LOAD_NODE_UPDATED", 0]],
|
|
88
96
|
[["ST_IDLE", [
|
|
89
97
|
["EV_WRITE_DONE", ac_form_answer, null],
|
|
90
98
|
["EV_WRITE_REFUSED", ac_form_answer, null],
|
|
91
|
-
["EV_LOAD_NODES", ac_form_load, null]
|
|
99
|
+
["EV_LOAD_NODES", ac_form_load, null],
|
|
100
|
+
["EV_LOAD_NODE_UPDATED", ac_form_update, null]
|
|
92
101
|
]]],
|
|
93
102
|
{},
|
|
94
103
|
0,
|
|
@@ -129,6 +138,7 @@ beforeEach(() => {
|
|
|
129
138
|
answers.length = 0;
|
|
130
139
|
commands.length = 0;
|
|
131
140
|
loaded.length = 0;
|
|
141
|
+
updated.length = 0;
|
|
132
142
|
});
|
|
133
143
|
|
|
134
144
|
function build(name)
|
|
@@ -511,3 +521,55 @@ describe("what the drop hid is read again on the reconnect", () => {
|
|
|
511
521
|
expect(nodes_asked().sort()).toEqual(["roles", "users"]);
|
|
512
522
|
});
|
|
513
523
|
});
|
|
524
|
+
|
|
525
|
+
/*
|
|
526
|
+
* SDK 7.25.23 turns `with_link_events` on by default: a link or an unlink
|
|
527
|
+
* no longer arrives as the parent's EV_TREEDB_NODE_UPDATED, but as the
|
|
528
|
+
* relationship, which carries no node. The parent's row (its hook column)
|
|
529
|
+
* must still move: the view reads the parent again.
|
|
530
|
+
*/
|
|
531
|
+
describe("a link told as EV_TREEDB_NODE_LINKED / UNLINKED", () => {
|
|
532
|
+
|
|
533
|
+
for(const event of ["EV_TREEDB_NODE_LINKED", "EV_TREEDB_NODE_UNLINKED"]) {
|
|
534
|
+
test(`${event} re-reads the parent and updates its row`, () => {
|
|
535
|
+
const {shell, topics} = build(`tl_${event}`);
|
|
536
|
+
yui_shell_set_connection_state(shell, true);
|
|
537
|
+
|
|
538
|
+
gobj_send_event(topics, event, {
|
|
539
|
+
treedb_name: "treedb_test",
|
|
540
|
+
hook_name: "users",
|
|
541
|
+
parent_topic_name: "roles",
|
|
542
|
+
parent_id: "admin",
|
|
543
|
+
child_topic_name: "users",
|
|
544
|
+
child_id: "alice"
|
|
545
|
+
}, remote);
|
|
546
|
+
|
|
547
|
+
const request = commands.find((c) => c.command === "node");
|
|
548
|
+
expect(request.kw.topic_name).toBe("roles");
|
|
549
|
+
expect(request.kw.node_id).toBe("admin");
|
|
550
|
+
expect(request.kw.options).toEqual({list_dict: true, hook_size: true});
|
|
551
|
+
|
|
552
|
+
gobj_send_event(topics, "EV_MT_COMMAND_ANSWER",
|
|
553
|
+
answer_ok(request, {id: "admin", users: [{size: 1}]}), remote);
|
|
554
|
+
expect(updated).toEqual([
|
|
555
|
+
{topic: "roles", rows: [{id: "admin", users: [{size: 1}]}]}
|
|
556
|
+
]);
|
|
557
|
+
expect(errors()).toEqual([]);
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
test("a link of another treedb reads nothing", () => {
|
|
562
|
+
const {shell, topics} = build("tl_other");
|
|
563
|
+
yui_shell_set_connection_state(shell, true);
|
|
564
|
+
gobj_send_event(topics, "EV_TREEDB_NODE_LINKED", {
|
|
565
|
+
treedb_name: "treedb_other",
|
|
566
|
+
hook_name: "users",
|
|
567
|
+
parent_topic_name: "roles",
|
|
568
|
+
parent_id: "admin",
|
|
569
|
+
child_topic_name: "users",
|
|
570
|
+
child_id: "alice"
|
|
571
|
+
}, remote);
|
|
572
|
+
expect(commands.filter((c) => c.command === "node")).toEqual([]);
|
|
573
|
+
expect(errors()).toEqual([]);
|
|
574
|
+
});
|
|
575
|
+
});
|