@yuneta/gobj-ui 7.25.24 → 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 +191 -6
- package/dist/gobj-ui.es.js +191 -6
- package/package.json +1 -1
- package/src/c_yui_schema_editor.js +148 -2
- package/src/c_yui_treedb_graph.js +4 -3
- package/src/c_yui_treedb_topics.js +110 -3
- package/src/schema_editor_column_data.wiring.test.js +267 -0
- package/src/schema_editor_reload.wiring.test.js +17 -0
- package/src/treedb_topics_transport.wiring.test.js +64 -2
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
|
|
@@ -72586,6 +72648,8 @@ var HOOK_COLS = "cols";
|
|
|
72586
72648
|
var DIAGRAM_SEG = "diagram";
|
|
72587
72649
|
var PURPOSE = "schema_editor";
|
|
72588
72650
|
var DIALOGS_THAT_READ_NOTHING = ["SCHEMA_EXPORT_DIALOG", "SCHEMA_REPORT_DIALOG"];
|
|
72651
|
+
var COLUMN_CHECK_PAGE = 500;
|
|
72652
|
+
var COLUMN_CHECK_PAGES = 10;
|
|
72589
72653
|
/***************************************************************
|
|
72590
72654
|
* Attrs
|
|
72591
72655
|
***************************************************************/
|
|
@@ -72599,6 +72663,8 @@ var attrs_table$1 = [
|
|
|
72599
72663
|
(0, _yuneta_gobj_js.SDATA_END)()
|
|
72600
72664
|
];
|
|
72601
72665
|
var PRIVATE_DATA$1 = {
|
|
72666
|
+
column_check: null,
|
|
72667
|
+
column_check_seq: 0,
|
|
72602
72668
|
records: null,
|
|
72603
72669
|
records_before: null,
|
|
72604
72670
|
model: null,
|
|
@@ -75742,6 +75808,7 @@ function ac_mt_command_answer(gobj, event, kw, src) {
|
|
|
75742
75808
|
let kw_command = (0, _yuneta_gobj_js.kw_get_dict)(gobj, __command__, "kw", {}, 0);
|
|
75743
75809
|
let md = (0, _yuneta_gobj_js.is_object)(kw_command.__md_command__) ? kw_command.__md_command__ : kw_command;
|
|
75744
75810
|
if ((0, _yuneta_gobj_js.kw_get_str)(gobj, md, "purpose", "", 0) !== PURPOSE) return 0;
|
|
75811
|
+
if (command === "nodes" && (0, _yuneta_gobj_js.kw_get_int)(gobj, md, "column_check", 0, 0)) return column_check_answered(gobj, md, result, comment, data);
|
|
75745
75812
|
if (result < 0 && !transport_in_session(gobj) && ((0, _yuneta_gobj_js.gobj_current_state)(gobj) === "ST_LOADING" || (0, _yuneta_gobj_js.gobj_current_state)(gobj) === "ST_SAVING")) {
|
|
75746
75813
|
if (command === "nodes" && is_current_load(gobj, md) || command !== "nodes" && is_current_write(gobj, md)) return transport_dropped(gobj);
|
|
75747
75814
|
}
|
|
@@ -76192,10 +76259,128 @@ function ac_delete_column(gobj, event, kw, src) {
|
|
|
76192
76259
|
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} names no column: ${kw.col}`);
|
|
76193
76260
|
return -1;
|
|
76194
76261
|
}
|
|
76195
|
-
|
|
76262
|
+
return start_column_check(gobj, topic.name, col.name);
|
|
76263
|
+
}
|
|
76264
|
+
/***************************************************************
|
|
76265
|
+
* A column deleted with values behind it: the records keep them, and
|
|
76266
|
+
* no reader shows them any more. Before the confirmation, the
|
|
76267
|
+
* topic's records are read (of the treedb whose schema this is, not
|
|
76268
|
+
* of the system schema), a page at a time, until one holds a value in
|
|
76269
|
+
* the column, the topic ends, or COLUMN_CHECK_PAGES are read; the
|
|
76270
|
+
* confirmation then says which. A check that cannot be made does not
|
|
76271
|
+
* stop the delete: the confirmation says so. Up to 7.25.24 the
|
|
76272
|
+
* confirmation was the same with data or without.
|
|
76273
|
+
***************************************************************/
|
|
76274
|
+
function start_column_check(gobj, topic_name, col_name) {
|
|
76275
|
+
let priv = gobj.priv;
|
|
76276
|
+
priv.column_check_seq++;
|
|
76277
|
+
priv.column_check = {
|
|
76278
|
+
seq: priv.column_check_seq,
|
|
76279
|
+
topic: topic_name,
|
|
76280
|
+
col: col_name,
|
|
76281
|
+
from: 1,
|
|
76282
|
+
pages: 0,
|
|
76283
|
+
scanned: 0
|
|
76284
|
+
};
|
|
76285
|
+
if (ask_column_page(gobj) < 0) return confirm_column_delete(gobj, "unknown");
|
|
76286
|
+
return 0;
|
|
76287
|
+
}
|
|
76288
|
+
function ask_column_page(gobj) {
|
|
76289
|
+
let priv = gobj.priv;
|
|
76290
|
+
let c = priv.column_check;
|
|
76291
|
+
return remote_command(gobj, "nodes", {
|
|
76292
|
+
service: priv.treedb_id,
|
|
76293
|
+
treedb_name: priv.treedb_id,
|
|
76294
|
+
topic_name: c.topic,
|
|
76295
|
+
from: c.from,
|
|
76296
|
+
limit: COLUMN_CHECK_PAGE
|
|
76297
|
+
}, { column_check: c.seq });
|
|
76298
|
+
}
|
|
76299
|
+
function value_is_empty(v) {
|
|
76300
|
+
if (v === void 0 || v === null || v === "") return true;
|
|
76301
|
+
if (Array.isArray(v)) return v.length === 0;
|
|
76302
|
+
if ((0, _yuneta_gobj_js.is_object)(v)) return Object.keys(v).length === 0;
|
|
76303
|
+
return false;
|
|
76304
|
+
}
|
|
76305
|
+
function column_check_answered(gobj, md, result, comment, data) {
|
|
76306
|
+
let priv = gobj.priv;
|
|
76307
|
+
let c = priv.column_check;
|
|
76308
|
+
if (!c || (0, _yuneta_gobj_js.kw_get_int)(gobj, md, "column_check", 0, 0) !== c.seq) {
|
|
76309
|
+
(0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: 'nodes' of a column check that is over: ignored`);
|
|
76310
|
+
return 0;
|
|
76311
|
+
}
|
|
76312
|
+
if ((0, _yuneta_gobj_js.gobj_current_state)(gobj) !== "ST_COLUMNS") {
|
|
76313
|
+
priv.column_check = null;
|
|
76314
|
+
(0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: the check of column '${c.topic}.${c.col}' answered after the view left the columns: no delete asked`);
|
|
76315
|
+
return 0;
|
|
76316
|
+
}
|
|
76317
|
+
if (result < 0) {
|
|
76318
|
+
(0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot read '${c.topic}' to check column '${c.col}': ${comment}`);
|
|
76319
|
+
return confirm_column_delete(gobj, "unknown");
|
|
76320
|
+
}
|
|
76321
|
+
let page = (0, _yuneta_gobj_js.is_object)(data) && Array.isArray(data.data) ? data.data : null;
|
|
76322
|
+
if (!page) {
|
|
76323
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: 'nodes' of '${c.topic}' answered no page to the check of column '${c.col}'`);
|
|
76324
|
+
return confirm_column_delete(gobj, "unknown");
|
|
76325
|
+
}
|
|
76326
|
+
for (const record of page) if ((0, _yuneta_gobj_js.is_object)(record) && !value_is_empty(record[c.col])) return confirm_column_delete(gobj, "found");
|
|
76327
|
+
c.pages++;
|
|
76328
|
+
c.scanned += page.length;
|
|
76329
|
+
c.from += page.length;
|
|
76330
|
+
if (page.length === 0 || c.scanned >= (0, _yuneta_gobj_js.kw_get_int)(gobj, data, "total_rows", 0, 0)) return confirm_column_delete(gobj, "empty");
|
|
76331
|
+
if (c.pages >= COLUMN_CHECK_PAGES) return confirm_column_delete(gobj, "capped");
|
|
76332
|
+
if (ask_column_page(gobj) < 0) return confirm_column_delete(gobj, "unknown");
|
|
76333
|
+
return 0;
|
|
76334
|
+
}
|
|
76335
|
+
function confirm_column_delete(gobj, verdict) {
|
|
76336
|
+
let priv = gobj.priv;
|
|
76337
|
+
let c = priv.column_check;
|
|
76338
|
+
priv.column_check = null;
|
|
76339
|
+
const NOTES = {
|
|
76340
|
+
found: "records of this topic hold values in this column: they keep them, but no reader shows them any more",
|
|
76341
|
+
capped: "the records read hold no value in this column, but not all were read: the rest may hold values that no reader will show any more",
|
|
76342
|
+
unknown: "the records of this topic could not be read: if they hold values in this column, they keep them, but no reader shows them any more"
|
|
76343
|
+
};
|
|
76344
|
+
let message = "delete this column?";
|
|
76345
|
+
if (NOTES[verdict]) {
|
|
76346
|
+
let children = [[
|
|
76347
|
+
"p",
|
|
76348
|
+
{
|
|
76349
|
+
class: "CONFIRM_MSG yui-confirm-msg",
|
|
76350
|
+
i18n: message
|
|
76351
|
+
},
|
|
76352
|
+
(0, i18next.t)(message)
|
|
76353
|
+
], [
|
|
76354
|
+
"p",
|
|
76355
|
+
{
|
|
76356
|
+
class: "SCHEMA_COLUMN_DATA_NOTE has-text-danger",
|
|
76357
|
+
i18n: NOTES[verdict]
|
|
76358
|
+
},
|
|
76359
|
+
(0, i18next.t)(NOTES[verdict])
|
|
76360
|
+
]];
|
|
76361
|
+
if (verdict === "capped") children.push([
|
|
76362
|
+
"p",
|
|
76363
|
+
{ class: "SCHEMA_COLUMN_DATA_READ" },
|
|
76364
|
+
[[
|
|
76365
|
+
"span",
|
|
76366
|
+
{ i18n: "records read" },
|
|
76367
|
+
(0, i18next.t)("records read")
|
|
76368
|
+
], [
|
|
76369
|
+
"span",
|
|
76370
|
+
{ class: "ml-1" },
|
|
76371
|
+
String(c.scanned)
|
|
76372
|
+
]]
|
|
76373
|
+
]);
|
|
76374
|
+
message = (0, _yuneta_gobj_js.createElement2)([
|
|
76375
|
+
"div",
|
|
76376
|
+
{ class: "SCHEMA_COLUMN_DATA_WARNING" },
|
|
76377
|
+
children
|
|
76378
|
+
]);
|
|
76379
|
+
}
|
|
76380
|
+
confirm_then(gobj, message, `${c.topic}.${c.col}`, {
|
|
76196
76381
|
what: "column",
|
|
76197
|
-
topic: topic
|
|
76198
|
-
col: col
|
|
76382
|
+
topic: c.topic,
|
|
76383
|
+
col: c.col
|
|
76199
76384
|
});
|
|
76200
76385
|
return 0;
|
|
76201
76386
|
}
|
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
|
|
@@ -72581,6 +72643,8 @@ var HOOK_COLS = "cols";
|
|
|
72581
72643
|
var DIAGRAM_SEG = "diagram";
|
|
72582
72644
|
var PURPOSE = "schema_editor";
|
|
72583
72645
|
var DIALOGS_THAT_READ_NOTHING = ["SCHEMA_EXPORT_DIALOG", "SCHEMA_REPORT_DIALOG"];
|
|
72646
|
+
var COLUMN_CHECK_PAGE = 500;
|
|
72647
|
+
var COLUMN_CHECK_PAGES = 10;
|
|
72584
72648
|
/***************************************************************
|
|
72585
72649
|
* Attrs
|
|
72586
72650
|
***************************************************************/
|
|
@@ -72594,6 +72658,8 @@ var attrs_table$1 = [
|
|
|
72594
72658
|
SDATA_END()
|
|
72595
72659
|
];
|
|
72596
72660
|
var PRIVATE_DATA$1 = {
|
|
72661
|
+
column_check: null,
|
|
72662
|
+
column_check_seq: 0,
|
|
72597
72663
|
records: null,
|
|
72598
72664
|
records_before: null,
|
|
72599
72665
|
model: null,
|
|
@@ -75737,6 +75803,7 @@ function ac_mt_command_answer(gobj, event, kw, src) {
|
|
|
75737
75803
|
let kw_command = kw_get_dict(gobj, __command__, "kw", {}, 0);
|
|
75738
75804
|
let md = is_object(kw_command.__md_command__) ? kw_command.__md_command__ : kw_command;
|
|
75739
75805
|
if (kw_get_str(gobj, md, "purpose", "", 0) !== PURPOSE) return 0;
|
|
75806
|
+
if (command === "nodes" && kw_get_int(gobj, md, "column_check", 0, 0)) return column_check_answered(gobj, md, result, comment, data);
|
|
75740
75807
|
if (result < 0 && !transport_in_session(gobj) && (gobj_current_state(gobj) === "ST_LOADING" || gobj_current_state(gobj) === "ST_SAVING")) {
|
|
75741
75808
|
if (command === "nodes" && is_current_load(gobj, md) || command !== "nodes" && is_current_write(gobj, md)) return transport_dropped(gobj);
|
|
75742
75809
|
}
|
|
@@ -76187,10 +76254,128 @@ function ac_delete_column(gobj, event, kw, src) {
|
|
|
76187
76254
|
log_error(`${gobj_short_name(gobj)}: ${event} names no column: ${kw.col}`);
|
|
76188
76255
|
return -1;
|
|
76189
76256
|
}
|
|
76190
|
-
|
|
76257
|
+
return start_column_check(gobj, topic.name, col.name);
|
|
76258
|
+
}
|
|
76259
|
+
/***************************************************************
|
|
76260
|
+
* A column deleted with values behind it: the records keep them, and
|
|
76261
|
+
* no reader shows them any more. Before the confirmation, the
|
|
76262
|
+
* topic's records are read (of the treedb whose schema this is, not
|
|
76263
|
+
* of the system schema), a page at a time, until one holds a value in
|
|
76264
|
+
* the column, the topic ends, or COLUMN_CHECK_PAGES are read; the
|
|
76265
|
+
* confirmation then says which. A check that cannot be made does not
|
|
76266
|
+
* stop the delete: the confirmation says so. Up to 7.25.24 the
|
|
76267
|
+
* confirmation was the same with data or without.
|
|
76268
|
+
***************************************************************/
|
|
76269
|
+
function start_column_check(gobj, topic_name, col_name) {
|
|
76270
|
+
let priv = gobj.priv;
|
|
76271
|
+
priv.column_check_seq++;
|
|
76272
|
+
priv.column_check = {
|
|
76273
|
+
seq: priv.column_check_seq,
|
|
76274
|
+
topic: topic_name,
|
|
76275
|
+
col: col_name,
|
|
76276
|
+
from: 1,
|
|
76277
|
+
pages: 0,
|
|
76278
|
+
scanned: 0
|
|
76279
|
+
};
|
|
76280
|
+
if (ask_column_page(gobj) < 0) return confirm_column_delete(gobj, "unknown");
|
|
76281
|
+
return 0;
|
|
76282
|
+
}
|
|
76283
|
+
function ask_column_page(gobj) {
|
|
76284
|
+
let priv = gobj.priv;
|
|
76285
|
+
let c = priv.column_check;
|
|
76286
|
+
return remote_command(gobj, "nodes", {
|
|
76287
|
+
service: priv.treedb_id,
|
|
76288
|
+
treedb_name: priv.treedb_id,
|
|
76289
|
+
topic_name: c.topic,
|
|
76290
|
+
from: c.from,
|
|
76291
|
+
limit: COLUMN_CHECK_PAGE
|
|
76292
|
+
}, { column_check: c.seq });
|
|
76293
|
+
}
|
|
76294
|
+
function value_is_empty(v) {
|
|
76295
|
+
if (v === void 0 || v === null || v === "") return true;
|
|
76296
|
+
if (Array.isArray(v)) return v.length === 0;
|
|
76297
|
+
if (is_object(v)) return Object.keys(v).length === 0;
|
|
76298
|
+
return false;
|
|
76299
|
+
}
|
|
76300
|
+
function column_check_answered(gobj, md, result, comment, data) {
|
|
76301
|
+
let priv = gobj.priv;
|
|
76302
|
+
let c = priv.column_check;
|
|
76303
|
+
if (!c || kw_get_int(gobj, md, "column_check", 0, 0) !== c.seq) {
|
|
76304
|
+
log_warning(`${gobj_short_name(gobj)}: 'nodes' of a column check that is over: ignored`);
|
|
76305
|
+
return 0;
|
|
76306
|
+
}
|
|
76307
|
+
if (gobj_current_state(gobj) !== "ST_COLUMNS") {
|
|
76308
|
+
priv.column_check = null;
|
|
76309
|
+
log_warning(`${gobj_short_name(gobj)}: the check of column '${c.topic}.${c.col}' answered after the view left the columns: no delete asked`);
|
|
76310
|
+
return 0;
|
|
76311
|
+
}
|
|
76312
|
+
if (result < 0) {
|
|
76313
|
+
log_warning(`${gobj_short_name(gobj)}: cannot read '${c.topic}' to check column '${c.col}': ${comment}`);
|
|
76314
|
+
return confirm_column_delete(gobj, "unknown");
|
|
76315
|
+
}
|
|
76316
|
+
let page = is_object(data) && Array.isArray(data.data) ? data.data : null;
|
|
76317
|
+
if (!page) {
|
|
76318
|
+
log_error(`${gobj_short_name(gobj)}: 'nodes' of '${c.topic}' answered no page to the check of column '${c.col}'`);
|
|
76319
|
+
return confirm_column_delete(gobj, "unknown");
|
|
76320
|
+
}
|
|
76321
|
+
for (const record of page) if (is_object(record) && !value_is_empty(record[c.col])) return confirm_column_delete(gobj, "found");
|
|
76322
|
+
c.pages++;
|
|
76323
|
+
c.scanned += page.length;
|
|
76324
|
+
c.from += page.length;
|
|
76325
|
+
if (page.length === 0 || c.scanned >= kw_get_int(gobj, data, "total_rows", 0, 0)) return confirm_column_delete(gobj, "empty");
|
|
76326
|
+
if (c.pages >= COLUMN_CHECK_PAGES) return confirm_column_delete(gobj, "capped");
|
|
76327
|
+
if (ask_column_page(gobj) < 0) return confirm_column_delete(gobj, "unknown");
|
|
76328
|
+
return 0;
|
|
76329
|
+
}
|
|
76330
|
+
function confirm_column_delete(gobj, verdict) {
|
|
76331
|
+
let priv = gobj.priv;
|
|
76332
|
+
let c = priv.column_check;
|
|
76333
|
+
priv.column_check = null;
|
|
76334
|
+
const NOTES = {
|
|
76335
|
+
found: "records of this topic hold values in this column: they keep them, but no reader shows them any more",
|
|
76336
|
+
capped: "the records read hold no value in this column, but not all were read: the rest may hold values that no reader will show any more",
|
|
76337
|
+
unknown: "the records of this topic could not be read: if they hold values in this column, they keep them, but no reader shows them any more"
|
|
76338
|
+
};
|
|
76339
|
+
let message = "delete this column?";
|
|
76340
|
+
if (NOTES[verdict]) {
|
|
76341
|
+
let children = [[
|
|
76342
|
+
"p",
|
|
76343
|
+
{
|
|
76344
|
+
class: "CONFIRM_MSG yui-confirm-msg",
|
|
76345
|
+
i18n: message
|
|
76346
|
+
},
|
|
76347
|
+
t(message)
|
|
76348
|
+
], [
|
|
76349
|
+
"p",
|
|
76350
|
+
{
|
|
76351
|
+
class: "SCHEMA_COLUMN_DATA_NOTE has-text-danger",
|
|
76352
|
+
i18n: NOTES[verdict]
|
|
76353
|
+
},
|
|
76354
|
+
t(NOTES[verdict])
|
|
76355
|
+
]];
|
|
76356
|
+
if (verdict === "capped") children.push([
|
|
76357
|
+
"p",
|
|
76358
|
+
{ class: "SCHEMA_COLUMN_DATA_READ" },
|
|
76359
|
+
[[
|
|
76360
|
+
"span",
|
|
76361
|
+
{ i18n: "records read" },
|
|
76362
|
+
t("records read")
|
|
76363
|
+
], [
|
|
76364
|
+
"span",
|
|
76365
|
+
{ class: "ml-1" },
|
|
76366
|
+
String(c.scanned)
|
|
76367
|
+
]]
|
|
76368
|
+
]);
|
|
76369
|
+
message = createElement2([
|
|
76370
|
+
"div",
|
|
76371
|
+
{ class: "SCHEMA_COLUMN_DATA_WARNING" },
|
|
76372
|
+
children
|
|
76373
|
+
]);
|
|
76374
|
+
}
|
|
76375
|
+
confirm_then(gobj, message, `${c.topic}.${c.col}`, {
|
|
76191
76376
|
what: "column",
|
|
76192
|
-
topic: topic
|
|
76193
|
-
col: col
|
|
76377
|
+
topic: c.topic,
|
|
76378
|
+
col: c.col
|
|
76194
76379
|
});
|
|
76195
76380
|
return 0;
|
|
76196
76381
|
}
|
package/package.json
CHANGED
|
@@ -193,6 +193,14 @@ const PURPOSE = "schema_editor";
|
|
|
193
193
|
* close_dialog_left_behind()). */
|
|
194
194
|
const DIALOGS_THAT_READ_NOTHING = ["SCHEMA_EXPORT_DIALOG", "SCHEMA_REPORT_DIALOG"];
|
|
195
195
|
|
|
196
|
+
/* The read of a topic's records before one of its columns is deleted
|
|
197
|
+
* (start_column_check()): pages of this many records, this many pages at
|
|
198
|
+
* most. A column with data behind it is a legal schema and a data
|
|
199
|
+
* decision: the records keep the values, and no reader shows them any
|
|
200
|
+
* more. The operator is told so, not stopped. */
|
|
201
|
+
const COLUMN_CHECK_PAGE = 500;
|
|
202
|
+
const COLUMN_CHECK_PAGES = 10;
|
|
203
|
+
|
|
196
204
|
|
|
197
205
|
/***************************************************************
|
|
198
206
|
* Attrs
|
|
@@ -208,6 +216,11 @@ SDATA_END()
|
|
|
208
216
|
];
|
|
209
217
|
|
|
210
218
|
let PRIVATE_DATA = {
|
|
219
|
+
/* The read of a column's records before its delete is confirmed:
|
|
220
|
+
* {seq, topic, col, from, pages, scanned}, or null */
|
|
221
|
+
column_check: null,
|
|
222
|
+
column_check_seq: 0,
|
|
223
|
+
|
|
211
224
|
/* What the store answered, and what it means */
|
|
212
225
|
records: null, /* {treedbs, topics, cols} as they arrived */
|
|
213
226
|
records_before: null, /* the records of the model shown, while a load replaces them */
|
|
@@ -3356,6 +3369,10 @@ function ac_mt_command_answer(gobj, event, kw, src)
|
|
|
3356
3369
|
return 0; /* another panel's answer on a shared transport */
|
|
3357
3370
|
}
|
|
3358
3371
|
|
|
3372
|
+
if(command === "nodes" && kw_get_int(gobj, md, "column_check", 0, 0)) {
|
|
3373
|
+
return column_check_answered(gobj, md, result, comment, data);
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3359
3376
|
/* A failure while the transport is not in session is the DROP, not a
|
|
3360
3377
|
* refusal: a routing adapter settles what it had in flight when its
|
|
3361
3378
|
* session closes, and that can arrive before the host's
|
|
@@ -4016,8 +4033,137 @@ function ac_delete_column(gobj, event, kw, src)
|
|
|
4016
4033
|
return -1;
|
|
4017
4034
|
}
|
|
4018
4035
|
|
|
4019
|
-
|
|
4020
|
-
|
|
4036
|
+
return start_column_check(gobj, topic.name, col.name);
|
|
4037
|
+
}
|
|
4038
|
+
|
|
4039
|
+
/***************************************************************
|
|
4040
|
+
* A column deleted with values behind it: the records keep them, and
|
|
4041
|
+
* no reader shows them any more. Before the confirmation, the
|
|
4042
|
+
* topic's records are read (of the treedb whose schema this is, not
|
|
4043
|
+
* of the system schema), a page at a time, until one holds a value in
|
|
4044
|
+
* the column, the topic ends, or COLUMN_CHECK_PAGES are read; the
|
|
4045
|
+
* confirmation then says which. A check that cannot be made does not
|
|
4046
|
+
* stop the delete: the confirmation says so. Up to 7.25.24 the
|
|
4047
|
+
* confirmation was the same with data or without.
|
|
4048
|
+
***************************************************************/
|
|
4049
|
+
function start_column_check(gobj, topic_name, col_name)
|
|
4050
|
+
{
|
|
4051
|
+
let priv = gobj.priv;
|
|
4052
|
+
priv.column_check_seq++;
|
|
4053
|
+
priv.column_check = {
|
|
4054
|
+
seq: priv.column_check_seq, topic: topic_name, col: col_name,
|
|
4055
|
+
from: 1, pages: 0, scanned: 0
|
|
4056
|
+
};
|
|
4057
|
+
if(ask_column_page(gobj) < 0) {
|
|
4058
|
+
return confirm_column_delete(gobj, "unknown"); // Error already logged
|
|
4059
|
+
}
|
|
4060
|
+
return 0;
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4063
|
+
function ask_column_page(gobj)
|
|
4064
|
+
{
|
|
4065
|
+
let priv = gobj.priv;
|
|
4066
|
+
let c = priv.column_check;
|
|
4067
|
+
return remote_command(gobj, "nodes", {
|
|
4068
|
+
service: priv.treedb_id,
|
|
4069
|
+
treedb_name: priv.treedb_id,
|
|
4070
|
+
topic_name: c.topic,
|
|
4071
|
+
from: c.from,
|
|
4072
|
+
limit: COLUMN_CHECK_PAGE
|
|
4073
|
+
}, {column_check: c.seq});
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
function value_is_empty(v)
|
|
4077
|
+
{
|
|
4078
|
+
if(v === undefined || v === null || v === "") {
|
|
4079
|
+
return true;
|
|
4080
|
+
}
|
|
4081
|
+
if(Array.isArray(v)) {
|
|
4082
|
+
return v.length === 0;
|
|
4083
|
+
}
|
|
4084
|
+
if(is_object(v)) {
|
|
4085
|
+
return Object.keys(v).length === 0;
|
|
4086
|
+
}
|
|
4087
|
+
return false;
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
/* An answer of the read: the EV_MT_COMMAND_ANSWER that carried it is
|
|
4091
|
+
* the event; this decides the next page or the confirmation. */
|
|
4092
|
+
function column_check_answered(gobj, md, result, comment, data)
|
|
4093
|
+
{
|
|
4094
|
+
let priv = gobj.priv;
|
|
4095
|
+
let c = priv.column_check;
|
|
4096
|
+
if(!c || kw_get_int(gobj, md, "column_check", 0, 0) !== c.seq) {
|
|
4097
|
+
log_warning(`${gobj_short_name(gobj)}: 'nodes' of a column check that is over: ignored`);
|
|
4098
|
+
return 0;
|
|
4099
|
+
}
|
|
4100
|
+
if(gobj_current_state(gobj) !== "ST_COLUMNS") {
|
|
4101
|
+
priv.column_check = null;
|
|
4102
|
+
log_warning(`${gobj_short_name(gobj)}: the check of column '${c.topic}.${c.col}' ` +
|
|
4103
|
+
`answered after the view left the columns: no delete asked`);
|
|
4104
|
+
return 0;
|
|
4105
|
+
}
|
|
4106
|
+
if(result < 0) {
|
|
4107
|
+
log_warning(`${gobj_short_name(gobj)}: cannot read '${c.topic}' to check column ` +
|
|
4108
|
+
`'${c.col}': ${comment}`);
|
|
4109
|
+
return confirm_column_delete(gobj, "unknown");
|
|
4110
|
+
}
|
|
4111
|
+
let page = is_object(data) && Array.isArray(data.data) ? data.data : null;
|
|
4112
|
+
if(!page) {
|
|
4113
|
+
log_error(`${gobj_short_name(gobj)}: 'nodes' of '${c.topic}' answered no page ` +
|
|
4114
|
+
`to the check of column '${c.col}'`);
|
|
4115
|
+
return confirm_column_delete(gobj, "unknown");
|
|
4116
|
+
}
|
|
4117
|
+
for(const record of page) {
|
|
4118
|
+
if(is_object(record) && !value_is_empty(record[c.col])) {
|
|
4119
|
+
return confirm_column_delete(gobj, "found");
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
c.pages++;
|
|
4123
|
+
c.scanned += page.length;
|
|
4124
|
+
c.from += page.length;
|
|
4125
|
+
if(page.length === 0 || c.scanned >= kw_get_int(gobj, data, "total_rows", 0, 0)) {
|
|
4126
|
+
return confirm_column_delete(gobj, "empty");
|
|
4127
|
+
}
|
|
4128
|
+
if(c.pages >= COLUMN_CHECK_PAGES) {
|
|
4129
|
+
return confirm_column_delete(gobj, "capped");
|
|
4130
|
+
}
|
|
4131
|
+
if(ask_column_page(gobj) < 0) {
|
|
4132
|
+
return confirm_column_delete(gobj, "unknown"); // Error already logged
|
|
4133
|
+
}
|
|
4134
|
+
return 0;
|
|
4135
|
+
}
|
|
4136
|
+
|
|
4137
|
+
/* The confirmation, with what the read found: "empty" asks as always;
|
|
4138
|
+
* "found", "capped" and "unknown" say what becomes of the values. */
|
|
4139
|
+
function confirm_column_delete(gobj, verdict)
|
|
4140
|
+
{
|
|
4141
|
+
let priv = gobj.priv;
|
|
4142
|
+
let c = priv.column_check;
|
|
4143
|
+
priv.column_check = null;
|
|
4144
|
+
|
|
4145
|
+
const NOTES = {
|
|
4146
|
+
found: "records of this topic hold values in this column: they keep them, but no reader shows them any more",
|
|
4147
|
+
capped: "the records read hold no value in this column, but not all were read: the rest may hold values that no reader will show any more",
|
|
4148
|
+
unknown: "the records of this topic could not be read: if they hold values in this column, they keep them, but no reader shows them any more"
|
|
4149
|
+
};
|
|
4150
|
+
let message = "delete this column?";
|
|
4151
|
+
if(NOTES[verdict]) {
|
|
4152
|
+
let children = [
|
|
4153
|
+
["p", {class: "CONFIRM_MSG yui-confirm-msg", i18n: message}, t(message)],
|
|
4154
|
+
["p", {class: "SCHEMA_COLUMN_DATA_NOTE has-text-danger", i18n: NOTES[verdict]},
|
|
4155
|
+
t(NOTES[verdict])]
|
|
4156
|
+
];
|
|
4157
|
+
if(verdict === "capped") {
|
|
4158
|
+
children.push(["p", {class: "SCHEMA_COLUMN_DATA_READ"}, [
|
|
4159
|
+
["span", {i18n: "records read"}, t("records read")],
|
|
4160
|
+
["span", {class: "ml-1"}, String(c.scanned)]
|
|
4161
|
+
]]);
|
|
4162
|
+
}
|
|
4163
|
+
message = createElement2(["div", {class: "SCHEMA_COLUMN_DATA_WARNING"}, children]);
|
|
4164
|
+
}
|
|
4165
|
+
confirm_then(gobj, message, `${c.topic}.${c.col}`,
|
|
4166
|
+
{what: "column", topic: c.topic, col: c.col});
|
|
4021
4167
|
return 0;
|
|
4022
4168
|
}
|
|
4023
4169
|
|
|
@@ -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],
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* schema_editor_column_data.wiring.test.js
|
|
3
|
+
*
|
|
4
|
+
* C_YUI_SCHEMA_EDITOR deleting a column with data behind it. The
|
|
5
|
+
* records keep their values for the column, and no reader shows
|
|
6
|
+
* them any more: a legal schema and a data decision, so the
|
|
7
|
+
* operator is WARNED, not stopped. Before the confirmation the
|
|
8
|
+
* editor reads the topic's records of the treedb whose schema it
|
|
9
|
+
* is (paged `nodes`), until one holds a value in the column, the
|
|
10
|
+
* topic ends, or the read is capped; the confirmation says which.
|
|
11
|
+
* Up to 7.25.24 it asked the same with data or without.
|
|
12
|
+
*
|
|
13
|
+
* Driven through the FSM on a document double, with a fake
|
|
14
|
+
* transport whose state is the one the library reads.
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2026, ArtGins.
|
|
17
|
+
* All Rights Reserved.
|
|
18
|
+
***********************************************************************/
|
|
19
|
+
import {describe, test, expect, beforeAll, beforeEach, vi} from "vitest";
|
|
20
|
+
import {install_dom_double} from "../test/dom_double.js";
|
|
21
|
+
|
|
22
|
+
install_dom_double();
|
|
23
|
+
|
|
24
|
+
const confirms = [];
|
|
25
|
+
vi.mock("./shell_modals.js", () => ({
|
|
26
|
+
yui_shell_show_error: () => ({close() {}}),
|
|
27
|
+
yui_shell_show_info: () => ({close() {}}),
|
|
28
|
+
yui_shell_show_modal: () => ({close() {}}),
|
|
29
|
+
yui_shell_confirm_danger: (shell, message, opts) => {
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
confirms.push({message, opts, resolve});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
SDATA_END,
|
|
38
|
+
gclass_create,
|
|
39
|
+
gobj_start_up, gobj_create_yuno, gobj_create, gobj_create_service,
|
|
40
|
+
gobj_start, gobj_send_event,
|
|
41
|
+
gobj_change_state, gobj_current_state,
|
|
42
|
+
set_log_callback,
|
|
43
|
+
} = await import("@yuneta/gobj-js");
|
|
44
|
+
const {register_c_yui_schema_editor} = await import("./c_yui_schema_editor.js");
|
|
45
|
+
|
|
46
|
+
const logged = [];
|
|
47
|
+
const commands = [];
|
|
48
|
+
|
|
49
|
+
const RECORDS = {
|
|
50
|
+
treedbs: [{id: "db", schema_version: 4}],
|
|
51
|
+
topics: [
|
|
52
|
+
{id: "db.users", value: "users", order: 1, pkey: "id", topic_version: 2,
|
|
53
|
+
treedbs: ["treedbs^db^topics"]},
|
|
54
|
+
],
|
|
55
|
+
cols: [
|
|
56
|
+
{id: "db.users.id", value: "id", order: 1, type: "string",
|
|
57
|
+
flag: ["persistent", "required"], topics: ["topics^db.users^cols"]},
|
|
58
|
+
{id: "db.users.name", value: "name", order: 2, type: "string",
|
|
59
|
+
flag: ["persistent"], topics: ["topics^db.users^cols"]},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const FOUND = "records of this topic hold values in this column: they keep them, but no reader shows them any more";
|
|
64
|
+
const CAPPED = "the records read hold no value in this column, but not all were read: the rest may hold values that no reader will show any more";
|
|
65
|
+
const UNKNOWN = "the records of this topic could not be read: if they hold values in this column, they keep them, but no reader shows them any more";
|
|
66
|
+
|
|
67
|
+
function remote_command_parser(gobj, command, kw, src)
|
|
68
|
+
{
|
|
69
|
+
if(gobj_current_state(gobj) !== "ST_SESSION") {
|
|
70
|
+
return `${command}: not in session`;
|
|
71
|
+
}
|
|
72
|
+
commands.push({command, kw, src});
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let yuno = null;
|
|
77
|
+
|
|
78
|
+
beforeAll(() => {
|
|
79
|
+
gobj_start_up(null, null, null, null, null, null, null);
|
|
80
|
+
set_log_callback((level, msg) => {
|
|
81
|
+
logged.push({level: String(level), msg: String(msg)});
|
|
82
|
+
});
|
|
83
|
+
gclass_create("C_TEST_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
84
|
+
const heard = () => 0;
|
|
85
|
+
gclass_create(
|
|
86
|
+
"C_TEST_EDITOR_HOST",
|
|
87
|
+
[["EV_POSITION_CHANGED", 0], ["EV_RECORD_WRITTEN", 0], ["EV_SCHEMA_CHECKED", 0]],
|
|
88
|
+
[["ST_IDLE", [
|
|
89
|
+
["EV_POSITION_CHANGED", heard, null],
|
|
90
|
+
["EV_RECORD_WRITTEN", heard, null],
|
|
91
|
+
["EV_SCHEMA_CHECKED", heard, null]
|
|
92
|
+
]]],
|
|
93
|
+
{}, 0, [SDATA_END()], {}, 0, 0, 0, 0
|
|
94
|
+
);
|
|
95
|
+
gclass_create(
|
|
96
|
+
"C_TEST_REMOTE",
|
|
97
|
+
[],
|
|
98
|
+
[["ST_DISCONNECTED", []], ["ST_SESSION", []]],
|
|
99
|
+
{mt_command_parser: remote_command_parser},
|
|
100
|
+
0, [SDATA_END()], {}, 0, 0, 0, 0
|
|
101
|
+
);
|
|
102
|
+
register_c_yui_schema_editor();
|
|
103
|
+
yuno = gobj_create_yuno("column_data_yuno", "C_TEST_HOST", {});
|
|
104
|
+
gobj_start(yuno);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
beforeEach(() => {
|
|
108
|
+
logged.length = 0;
|
|
109
|
+
commands.length = 0;
|
|
110
|
+
confirms.length = 0;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
function take(filter)
|
|
114
|
+
{
|
|
115
|
+
const out = commands.filter(filter);
|
|
116
|
+
for(const c of out) {
|
|
117
|
+
commands.splice(commands.indexOf(c), 1);
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function is_check(c)
|
|
123
|
+
{
|
|
124
|
+
return c.command === "nodes" && c.kw.__md_command__ && c.kw.__md_command__.column_check;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function answer(editor, remote, request, result, data, comment)
|
|
128
|
+
{
|
|
129
|
+
gobj_send_event(editor, "EV_MT_COMMAND_ANSWER", {
|
|
130
|
+
result: result,
|
|
131
|
+
comment: comment || "",
|
|
132
|
+
data: data,
|
|
133
|
+
__md_iev__: {command_stack: [{command: request.command, kw: request.kw}]}
|
|
134
|
+
}, remote);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function build(name)
|
|
138
|
+
{
|
|
139
|
+
const remote = gobj_create_service(`${name}_remote`, "C_TEST_REMOTE", {}, yuno);
|
|
140
|
+
gobj_change_state(remote, "ST_SESSION");
|
|
141
|
+
const host = gobj_create(`${name}_host`, "C_TEST_EDITOR_HOST", {}, yuno);
|
|
142
|
+
const editor = gobj_create(`${name}_editor`, "C_YUI_SCHEMA_EDITOR", {
|
|
143
|
+
gobj_remote_yuno: remote,
|
|
144
|
+
treedb_name: "treedb_system_schema",
|
|
145
|
+
base_route: "/schemas"
|
|
146
|
+
}, host);
|
|
147
|
+
gobj_start(editor);
|
|
148
|
+
gobj_send_event(editor, "EV_TRANSPORT_STATE", {connected: true}, host);
|
|
149
|
+
const load = take((c) => c.command === "nodes");
|
|
150
|
+
expect(load.length).toBe(3);
|
|
151
|
+
for(const c of load) {
|
|
152
|
+
answer(editor, remote, c, 0, JSON.parse(JSON.stringify(RECORDS[c.kw.topic_name])));
|
|
153
|
+
}
|
|
154
|
+
gobj_send_event(editor, "EV_SHOW", {subpath: "db/users"}, host);
|
|
155
|
+
expect(gobj_current_state(editor)).toBe("ST_COLUMNS");
|
|
156
|
+
return {editor, remote, host};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function page(records, total)
|
|
160
|
+
{
|
|
161
|
+
return {total_rows: total, pages: Math.ceil(total / 500) || 1, data: records};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* What the confirmation says: its key when it is the plain question,
|
|
165
|
+
* else the key of its warning and the count of the records read (the
|
|
166
|
+
* locale is not loaded here: the keys are what re-translate). */
|
|
167
|
+
function text_of(message)
|
|
168
|
+
{
|
|
169
|
+
if(typeof message === "string") {
|
|
170
|
+
return message;
|
|
171
|
+
}
|
|
172
|
+
const $note = message.querySelector(".SCHEMA_COLUMN_DATA_NOTE");
|
|
173
|
+
const $read = message.querySelector(".SCHEMA_COLUMN_DATA_READ");
|
|
174
|
+
return [
|
|
175
|
+
$note ? $note.getAttribute("data-i18n") : "",
|
|
176
|
+
$read ? $read.textContent : ""
|
|
177
|
+
].join(" ");
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
describe("deleting a column reads its records first", () => {
|
|
181
|
+
|
|
182
|
+
test("the topic's records are asked of the treedb whose schema it is, a page at a time", () => {
|
|
183
|
+
const {editor, host} = build("c1");
|
|
184
|
+
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "name"}, host);
|
|
185
|
+
const [ask] = take(is_check);
|
|
186
|
+
expect(ask).toBeTruthy();
|
|
187
|
+
expect(ask.kw.service).toBe("db");
|
|
188
|
+
expect(ask.kw.treedb_name).toBe("db");
|
|
189
|
+
expect(ask.kw.topic_name).toBe("users");
|
|
190
|
+
expect(ask.kw.from).toBe(1);
|
|
191
|
+
expect(ask.kw.limit).toBe(500);
|
|
192
|
+
expect(confirms.length).toBe(0); /* no confirmation before the answer */
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("a record holding a value: the confirmation warns what becomes of it", () => {
|
|
196
|
+
const {editor, remote, host} = build("c2");
|
|
197
|
+
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "name"}, host);
|
|
198
|
+
const [ask] = take(is_check);
|
|
199
|
+
answer(editor, remote, ask, 0, page([{id: "a"}, {id: "b", name: "Bob"}], 2));
|
|
200
|
+
expect(confirms.length).toBe(1);
|
|
201
|
+
expect(text_of(confirms[0].message)).toContain(FOUND);
|
|
202
|
+
expect(take(is_check).length).toBe(0);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test("no record holding a value: the plain confirmation, as before", () => {
|
|
206
|
+
const {editor, remote, host} = build("c3");
|
|
207
|
+
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "name"}, host);
|
|
208
|
+
const [ask] = take(is_check);
|
|
209
|
+
answer(editor, remote, ask, 0, page([{id: "a"}, {id: "b", name: ""}, {id: "c", name: null}], 3));
|
|
210
|
+
expect(confirms.length).toBe(1);
|
|
211
|
+
expect(confirms[0].message).toBe("delete this column?");
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("the read is capped: the confirmation says the rest was not read", () => {
|
|
215
|
+
const {editor, remote, host} = build("c4");
|
|
216
|
+
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "name"}, host);
|
|
217
|
+
const empty_page = Array.from({length: 500}, (_, i) => ({id: `r${i}`}));
|
|
218
|
+
for(let i = 0; i < 10; i++) {
|
|
219
|
+
const [ask] = take(is_check);
|
|
220
|
+
expect(ask.kw.from).toBe(1 + i * 500);
|
|
221
|
+
answer(editor, remote, ask, 0, page(empty_page, 100000));
|
|
222
|
+
}
|
|
223
|
+
expect(take(is_check).length).toBe(0);
|
|
224
|
+
expect(confirms.length).toBe(1);
|
|
225
|
+
const text = text_of(confirms[0].message);
|
|
226
|
+
expect(text).toContain(CAPPED);
|
|
227
|
+
expect(text).toContain("5000");
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("the read fails: the confirmation says it could not check, the delete is not blocked", async () => {
|
|
231
|
+
const {editor, remote, host} = build("c5");
|
|
232
|
+
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "name"}, host);
|
|
233
|
+
const [ask] = take(is_check);
|
|
234
|
+
answer(editor, remote, ask, -1, null, "no such topic");
|
|
235
|
+
expect(confirms.length).toBe(1);
|
|
236
|
+
expect(text_of(confirms[0].message)).toContain(UNKNOWN);
|
|
237
|
+
expect(logged.some((l) => /cannot read 'users' to check column 'name'/.test(l.msg))).toBe(true);
|
|
238
|
+
|
|
239
|
+
confirms[0].resolve(true);
|
|
240
|
+
await Promise.resolve();
|
|
241
|
+
await Promise.resolve();
|
|
242
|
+
const writes = take((c) => c.command === "delete-node");
|
|
243
|
+
expect(writes.length).toBe(1);
|
|
244
|
+
expect(writes[0].kw.topic_name).toBe("cols");
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("no transport in session: the confirmation says it could not check", () => {
|
|
248
|
+
const {editor, remote, host} = build("c6");
|
|
249
|
+
gobj_change_state(remote, "ST_DISCONNECTED");
|
|
250
|
+
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "name"}, host);
|
|
251
|
+
expect(take(is_check).length).toBe(0);
|
|
252
|
+
expect(confirms.length).toBe(1);
|
|
253
|
+
expect(text_of(confirms[0].message)).toContain(UNKNOWN);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test("an answer after the view left the columns asks nothing", () => {
|
|
257
|
+
const {editor, remote, host} = build("c7");
|
|
258
|
+
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "name"}, host);
|
|
259
|
+
const [ask] = take(is_check);
|
|
260
|
+
gobj_send_event(editor, "EV_SHOW", {subpath: "db"}, host);
|
|
261
|
+
expect(gobj_current_state(editor)).not.toBe("ST_COLUMNS");
|
|
262
|
+
answer(editor, remote, ask, 0, page([{id: "b", name: "Bob"}], 1));
|
|
263
|
+
expect(confirms.length).toBe(0);
|
|
264
|
+
expect(logged.some((l) => /answered after the view left the columns/.test(l.msg))).toBe(true);
|
|
265
|
+
expect(logged.some((l) => /NOT DEFINED/i.test(l.msg))).toBe(false);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
@@ -212,6 +212,20 @@ function answer_the_load(editor, remote)
|
|
|
212
212
|
return asked.length;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
/* A column delete reads the topic's records before it asks
|
|
216
|
+
* (schema_editor_column_data.wiring.test.js): answered with none
|
|
217
|
+
* holding a value, the confirmation is the plain one. */
|
|
218
|
+
function answer_the_column_check(editor, remote)
|
|
219
|
+
{
|
|
220
|
+
const asked = commands.filter((c) => c.command === "nodes" &&
|
|
221
|
+
c.kw.__md_command__ && c.kw.__md_command__.column_check);
|
|
222
|
+
for(const c of asked) {
|
|
223
|
+
commands.splice(commands.indexOf(c), 1);
|
|
224
|
+
answer(editor, remote, c, 0, {total_rows: 0, pages: 1, data: []});
|
|
225
|
+
}
|
|
226
|
+
return asked.length;
|
|
227
|
+
}
|
|
228
|
+
|
|
215
229
|
function drop(editor, remote, host)
|
|
216
230
|
{
|
|
217
231
|
gobj_change_state(remote, "ST_DISCONNECTED");
|
|
@@ -1092,6 +1106,7 @@ describe("the answers of the editor's confirmations are i18n keys", () => {
|
|
|
1092
1106
|
test("a column delete asks with `delete` / `cancel`", () => {
|
|
1093
1107
|
const {editor, remote, host} = build("k1", "db/users");
|
|
1094
1108
|
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "id"}, host);
|
|
1109
|
+
expect(answer_the_column_check(editor, remote)).toBe(1);
|
|
1095
1110
|
expect(confirms.length).toBe(1);
|
|
1096
1111
|
expect([confirms[0].opts.confirm_label, confirms[0].opts.cancel_label])
|
|
1097
1112
|
.toEqual(["delete", "cancel"]);
|
|
@@ -1384,6 +1399,7 @@ describe("a move sent by the host while a dialog is up", () => {
|
|
|
1384
1399
|
expect(gobj_current_state(editor)).toBe("ST_COLUMNS");
|
|
1385
1400
|
|
|
1386
1401
|
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "id"}, host);
|
|
1402
|
+
expect(answer_the_column_check(editor, remote)).toBe(1);
|
|
1387
1403
|
expect(confirms.length).toBe(1);
|
|
1388
1404
|
gobj_send_event(editor, "EV_SHOW", {subpath: "db2/users"}, host);
|
|
1389
1405
|
expect(gobj_current_state(editor)).toBe("ST_COLUMNS");
|
|
@@ -1399,6 +1415,7 @@ describe("a move sent by the host while a dialog is up", () => {
|
|
|
1399
1415
|
test("a confirmation answered on the screen it was asked from still runs", async () => {
|
|
1400
1416
|
const {editor, remote, host} = build("mv7", "db/users");
|
|
1401
1417
|
gobj_send_event(editor, "EV_DELETE_COLUMN", {col: "id"}, host);
|
|
1418
|
+
expect(answer_the_column_check(editor, remote)).toBe(1);
|
|
1402
1419
|
confirms[0].resolve(true);
|
|
1403
1420
|
await settle();
|
|
1404
1421
|
expect(take("delete-node").length).toBe(1);
|
|
@@ -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
|
+
});
|