@yuneta/gobj-ui 7.25.23 → 7.25.25
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
|
@@ -72586,6 +72586,8 @@ var HOOK_COLS = "cols";
|
|
|
72586
72586
|
var DIAGRAM_SEG = "diagram";
|
|
72587
72587
|
var PURPOSE = "schema_editor";
|
|
72588
72588
|
var DIALOGS_THAT_READ_NOTHING = ["SCHEMA_EXPORT_DIALOG", "SCHEMA_REPORT_DIALOG"];
|
|
72589
|
+
var COLUMN_CHECK_PAGE = 500;
|
|
72590
|
+
var COLUMN_CHECK_PAGES = 10;
|
|
72589
72591
|
/***************************************************************
|
|
72590
72592
|
* Attrs
|
|
72591
72593
|
***************************************************************/
|
|
@@ -72599,6 +72601,8 @@ var attrs_table$1 = [
|
|
|
72599
72601
|
(0, _yuneta_gobj_js.SDATA_END)()
|
|
72600
72602
|
];
|
|
72601
72603
|
var PRIVATE_DATA$1 = {
|
|
72604
|
+
column_check: null,
|
|
72605
|
+
column_check_seq: 0,
|
|
72602
72606
|
records: null,
|
|
72603
72607
|
records_before: null,
|
|
72604
72608
|
model: null,
|
|
@@ -75742,6 +75746,7 @@ function ac_mt_command_answer(gobj, event, kw, src) {
|
|
|
75742
75746
|
let kw_command = (0, _yuneta_gobj_js.kw_get_dict)(gobj, __command__, "kw", {}, 0);
|
|
75743
75747
|
let md = (0, _yuneta_gobj_js.is_object)(kw_command.__md_command__) ? kw_command.__md_command__ : kw_command;
|
|
75744
75748
|
if ((0, _yuneta_gobj_js.kw_get_str)(gobj, md, "purpose", "", 0) !== PURPOSE) return 0;
|
|
75749
|
+
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
75750
|
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
75751
|
if (command === "nodes" && is_current_load(gobj, md) || command !== "nodes" && is_current_write(gobj, md)) return transport_dropped(gobj);
|
|
75747
75752
|
}
|
|
@@ -76192,10 +76197,128 @@ function ac_delete_column(gobj, event, kw, src) {
|
|
|
76192
76197
|
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} names no column: ${kw.col}`);
|
|
76193
76198
|
return -1;
|
|
76194
76199
|
}
|
|
76195
|
-
|
|
76200
|
+
return start_column_check(gobj, topic.name, col.name);
|
|
76201
|
+
}
|
|
76202
|
+
/***************************************************************
|
|
76203
|
+
* A column deleted with values behind it: the records keep them, and
|
|
76204
|
+
* no reader shows them any more. Before the confirmation, the
|
|
76205
|
+
* topic's records are read (of the treedb whose schema this is, not
|
|
76206
|
+
* of the system schema), a page at a time, until one holds a value in
|
|
76207
|
+
* the column, the topic ends, or COLUMN_CHECK_PAGES are read; the
|
|
76208
|
+
* confirmation then says which. A check that cannot be made does not
|
|
76209
|
+
* stop the delete: the confirmation says so. Up to 7.25.24 the
|
|
76210
|
+
* confirmation was the same with data or without.
|
|
76211
|
+
***************************************************************/
|
|
76212
|
+
function start_column_check(gobj, topic_name, col_name) {
|
|
76213
|
+
let priv = gobj.priv;
|
|
76214
|
+
priv.column_check_seq++;
|
|
76215
|
+
priv.column_check = {
|
|
76216
|
+
seq: priv.column_check_seq,
|
|
76217
|
+
topic: topic_name,
|
|
76218
|
+
col: col_name,
|
|
76219
|
+
from: 1,
|
|
76220
|
+
pages: 0,
|
|
76221
|
+
scanned: 0
|
|
76222
|
+
};
|
|
76223
|
+
if (ask_column_page(gobj) < 0) return confirm_column_delete(gobj, "unknown");
|
|
76224
|
+
return 0;
|
|
76225
|
+
}
|
|
76226
|
+
function ask_column_page(gobj) {
|
|
76227
|
+
let priv = gobj.priv;
|
|
76228
|
+
let c = priv.column_check;
|
|
76229
|
+
return remote_command(gobj, "nodes", {
|
|
76230
|
+
service: priv.treedb_id,
|
|
76231
|
+
treedb_name: priv.treedb_id,
|
|
76232
|
+
topic_name: c.topic,
|
|
76233
|
+
from: c.from,
|
|
76234
|
+
limit: COLUMN_CHECK_PAGE
|
|
76235
|
+
}, { column_check: c.seq });
|
|
76236
|
+
}
|
|
76237
|
+
function value_is_empty(v) {
|
|
76238
|
+
if (v === void 0 || v === null || v === "") return true;
|
|
76239
|
+
if (Array.isArray(v)) return v.length === 0;
|
|
76240
|
+
if ((0, _yuneta_gobj_js.is_object)(v)) return Object.keys(v).length === 0;
|
|
76241
|
+
return false;
|
|
76242
|
+
}
|
|
76243
|
+
function column_check_answered(gobj, md, result, comment, data) {
|
|
76244
|
+
let priv = gobj.priv;
|
|
76245
|
+
let c = priv.column_check;
|
|
76246
|
+
if (!c || (0, _yuneta_gobj_js.kw_get_int)(gobj, md, "column_check", 0, 0) !== c.seq) {
|
|
76247
|
+
(0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: 'nodes' of a column check that is over: ignored`);
|
|
76248
|
+
return 0;
|
|
76249
|
+
}
|
|
76250
|
+
if ((0, _yuneta_gobj_js.gobj_current_state)(gobj) !== "ST_COLUMNS") {
|
|
76251
|
+
priv.column_check = null;
|
|
76252
|
+
(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`);
|
|
76253
|
+
return 0;
|
|
76254
|
+
}
|
|
76255
|
+
if (result < 0) {
|
|
76256
|
+
(0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot read '${c.topic}' to check column '${c.col}': ${comment}`);
|
|
76257
|
+
return confirm_column_delete(gobj, "unknown");
|
|
76258
|
+
}
|
|
76259
|
+
let page = (0, _yuneta_gobj_js.is_object)(data) && Array.isArray(data.data) ? data.data : null;
|
|
76260
|
+
if (!page) {
|
|
76261
|
+
(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}'`);
|
|
76262
|
+
return confirm_column_delete(gobj, "unknown");
|
|
76263
|
+
}
|
|
76264
|
+
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");
|
|
76265
|
+
c.pages++;
|
|
76266
|
+
c.scanned += page.length;
|
|
76267
|
+
c.from += page.length;
|
|
76268
|
+
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");
|
|
76269
|
+
if (c.pages >= COLUMN_CHECK_PAGES) return confirm_column_delete(gobj, "capped");
|
|
76270
|
+
if (ask_column_page(gobj) < 0) return confirm_column_delete(gobj, "unknown");
|
|
76271
|
+
return 0;
|
|
76272
|
+
}
|
|
76273
|
+
function confirm_column_delete(gobj, verdict) {
|
|
76274
|
+
let priv = gobj.priv;
|
|
76275
|
+
let c = priv.column_check;
|
|
76276
|
+
priv.column_check = null;
|
|
76277
|
+
const NOTES = {
|
|
76278
|
+
found: "records of this topic hold values in this column: they keep them, but no reader shows them any more",
|
|
76279
|
+
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",
|
|
76280
|
+
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"
|
|
76281
|
+
};
|
|
76282
|
+
let message = "delete this column?";
|
|
76283
|
+
if (NOTES[verdict]) {
|
|
76284
|
+
let children = [[
|
|
76285
|
+
"p",
|
|
76286
|
+
{
|
|
76287
|
+
class: "CONFIRM_MSG yui-confirm-msg",
|
|
76288
|
+
i18n: message
|
|
76289
|
+
},
|
|
76290
|
+
(0, i18next.t)(message)
|
|
76291
|
+
], [
|
|
76292
|
+
"p",
|
|
76293
|
+
{
|
|
76294
|
+
class: "SCHEMA_COLUMN_DATA_NOTE has-text-danger",
|
|
76295
|
+
i18n: NOTES[verdict]
|
|
76296
|
+
},
|
|
76297
|
+
(0, i18next.t)(NOTES[verdict])
|
|
76298
|
+
]];
|
|
76299
|
+
if (verdict === "capped") children.push([
|
|
76300
|
+
"p",
|
|
76301
|
+
{ class: "SCHEMA_COLUMN_DATA_READ" },
|
|
76302
|
+
[[
|
|
76303
|
+
"span",
|
|
76304
|
+
{ i18n: "records read" },
|
|
76305
|
+
(0, i18next.t)("records read")
|
|
76306
|
+
], [
|
|
76307
|
+
"span",
|
|
76308
|
+
{ class: "ml-1" },
|
|
76309
|
+
String(c.scanned)
|
|
76310
|
+
]]
|
|
76311
|
+
]);
|
|
76312
|
+
message = (0, _yuneta_gobj_js.createElement2)([
|
|
76313
|
+
"div",
|
|
76314
|
+
{ class: "SCHEMA_COLUMN_DATA_WARNING" },
|
|
76315
|
+
children
|
|
76316
|
+
]);
|
|
76317
|
+
}
|
|
76318
|
+
confirm_then(gobj, message, `${c.topic}.${c.col}`, {
|
|
76196
76319
|
what: "column",
|
|
76197
|
-
topic: topic
|
|
76198
|
-
col: col
|
|
76320
|
+
topic: c.topic,
|
|
76321
|
+
col: c.col
|
|
76199
76322
|
});
|
|
76200
76323
|
return 0;
|
|
76201
76324
|
}
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -72581,6 +72581,8 @@ var HOOK_COLS = "cols";
|
|
|
72581
72581
|
var DIAGRAM_SEG = "diagram";
|
|
72582
72582
|
var PURPOSE = "schema_editor";
|
|
72583
72583
|
var DIALOGS_THAT_READ_NOTHING = ["SCHEMA_EXPORT_DIALOG", "SCHEMA_REPORT_DIALOG"];
|
|
72584
|
+
var COLUMN_CHECK_PAGE = 500;
|
|
72585
|
+
var COLUMN_CHECK_PAGES = 10;
|
|
72584
72586
|
/***************************************************************
|
|
72585
72587
|
* Attrs
|
|
72586
72588
|
***************************************************************/
|
|
@@ -72594,6 +72596,8 @@ var attrs_table$1 = [
|
|
|
72594
72596
|
SDATA_END()
|
|
72595
72597
|
];
|
|
72596
72598
|
var PRIVATE_DATA$1 = {
|
|
72599
|
+
column_check: null,
|
|
72600
|
+
column_check_seq: 0,
|
|
72597
72601
|
records: null,
|
|
72598
72602
|
records_before: null,
|
|
72599
72603
|
model: null,
|
|
@@ -75737,6 +75741,7 @@ function ac_mt_command_answer(gobj, event, kw, src) {
|
|
|
75737
75741
|
let kw_command = kw_get_dict(gobj, __command__, "kw", {}, 0);
|
|
75738
75742
|
let md = is_object(kw_command.__md_command__) ? kw_command.__md_command__ : kw_command;
|
|
75739
75743
|
if (kw_get_str(gobj, md, "purpose", "", 0) !== PURPOSE) return 0;
|
|
75744
|
+
if (command === "nodes" && kw_get_int(gobj, md, "column_check", 0, 0)) return column_check_answered(gobj, md, result, comment, data);
|
|
75740
75745
|
if (result < 0 && !transport_in_session(gobj) && (gobj_current_state(gobj) === "ST_LOADING" || gobj_current_state(gobj) === "ST_SAVING")) {
|
|
75741
75746
|
if (command === "nodes" && is_current_load(gobj, md) || command !== "nodes" && is_current_write(gobj, md)) return transport_dropped(gobj);
|
|
75742
75747
|
}
|
|
@@ -76187,10 +76192,128 @@ function ac_delete_column(gobj, event, kw, src) {
|
|
|
76187
76192
|
log_error(`${gobj_short_name(gobj)}: ${event} names no column: ${kw.col}`);
|
|
76188
76193
|
return -1;
|
|
76189
76194
|
}
|
|
76190
|
-
|
|
76195
|
+
return start_column_check(gobj, topic.name, col.name);
|
|
76196
|
+
}
|
|
76197
|
+
/***************************************************************
|
|
76198
|
+
* A column deleted with values behind it: the records keep them, and
|
|
76199
|
+
* no reader shows them any more. Before the confirmation, the
|
|
76200
|
+
* topic's records are read (of the treedb whose schema this is, not
|
|
76201
|
+
* of the system schema), a page at a time, until one holds a value in
|
|
76202
|
+
* the column, the topic ends, or COLUMN_CHECK_PAGES are read; the
|
|
76203
|
+
* confirmation then says which. A check that cannot be made does not
|
|
76204
|
+
* stop the delete: the confirmation says so. Up to 7.25.24 the
|
|
76205
|
+
* confirmation was the same with data or without.
|
|
76206
|
+
***************************************************************/
|
|
76207
|
+
function start_column_check(gobj, topic_name, col_name) {
|
|
76208
|
+
let priv = gobj.priv;
|
|
76209
|
+
priv.column_check_seq++;
|
|
76210
|
+
priv.column_check = {
|
|
76211
|
+
seq: priv.column_check_seq,
|
|
76212
|
+
topic: topic_name,
|
|
76213
|
+
col: col_name,
|
|
76214
|
+
from: 1,
|
|
76215
|
+
pages: 0,
|
|
76216
|
+
scanned: 0
|
|
76217
|
+
};
|
|
76218
|
+
if (ask_column_page(gobj) < 0) return confirm_column_delete(gobj, "unknown");
|
|
76219
|
+
return 0;
|
|
76220
|
+
}
|
|
76221
|
+
function ask_column_page(gobj) {
|
|
76222
|
+
let priv = gobj.priv;
|
|
76223
|
+
let c = priv.column_check;
|
|
76224
|
+
return remote_command(gobj, "nodes", {
|
|
76225
|
+
service: priv.treedb_id,
|
|
76226
|
+
treedb_name: priv.treedb_id,
|
|
76227
|
+
topic_name: c.topic,
|
|
76228
|
+
from: c.from,
|
|
76229
|
+
limit: COLUMN_CHECK_PAGE
|
|
76230
|
+
}, { column_check: c.seq });
|
|
76231
|
+
}
|
|
76232
|
+
function value_is_empty(v) {
|
|
76233
|
+
if (v === void 0 || v === null || v === "") return true;
|
|
76234
|
+
if (Array.isArray(v)) return v.length === 0;
|
|
76235
|
+
if (is_object(v)) return Object.keys(v).length === 0;
|
|
76236
|
+
return false;
|
|
76237
|
+
}
|
|
76238
|
+
function column_check_answered(gobj, md, result, comment, data) {
|
|
76239
|
+
let priv = gobj.priv;
|
|
76240
|
+
let c = priv.column_check;
|
|
76241
|
+
if (!c || kw_get_int(gobj, md, "column_check", 0, 0) !== c.seq) {
|
|
76242
|
+
log_warning(`${gobj_short_name(gobj)}: 'nodes' of a column check that is over: ignored`);
|
|
76243
|
+
return 0;
|
|
76244
|
+
}
|
|
76245
|
+
if (gobj_current_state(gobj) !== "ST_COLUMNS") {
|
|
76246
|
+
priv.column_check = null;
|
|
76247
|
+
log_warning(`${gobj_short_name(gobj)}: the check of column '${c.topic}.${c.col}' answered after the view left the columns: no delete asked`);
|
|
76248
|
+
return 0;
|
|
76249
|
+
}
|
|
76250
|
+
if (result < 0) {
|
|
76251
|
+
log_warning(`${gobj_short_name(gobj)}: cannot read '${c.topic}' to check column '${c.col}': ${comment}`);
|
|
76252
|
+
return confirm_column_delete(gobj, "unknown");
|
|
76253
|
+
}
|
|
76254
|
+
let page = is_object(data) && Array.isArray(data.data) ? data.data : null;
|
|
76255
|
+
if (!page) {
|
|
76256
|
+
log_error(`${gobj_short_name(gobj)}: 'nodes' of '${c.topic}' answered no page to the check of column '${c.col}'`);
|
|
76257
|
+
return confirm_column_delete(gobj, "unknown");
|
|
76258
|
+
}
|
|
76259
|
+
for (const record of page) if (is_object(record) && !value_is_empty(record[c.col])) return confirm_column_delete(gobj, "found");
|
|
76260
|
+
c.pages++;
|
|
76261
|
+
c.scanned += page.length;
|
|
76262
|
+
c.from += page.length;
|
|
76263
|
+
if (page.length === 0 || c.scanned >= kw_get_int(gobj, data, "total_rows", 0, 0)) return confirm_column_delete(gobj, "empty");
|
|
76264
|
+
if (c.pages >= COLUMN_CHECK_PAGES) return confirm_column_delete(gobj, "capped");
|
|
76265
|
+
if (ask_column_page(gobj) < 0) return confirm_column_delete(gobj, "unknown");
|
|
76266
|
+
return 0;
|
|
76267
|
+
}
|
|
76268
|
+
function confirm_column_delete(gobj, verdict) {
|
|
76269
|
+
let priv = gobj.priv;
|
|
76270
|
+
let c = priv.column_check;
|
|
76271
|
+
priv.column_check = null;
|
|
76272
|
+
const NOTES = {
|
|
76273
|
+
found: "records of this topic hold values in this column: they keep them, but no reader shows them any more",
|
|
76274
|
+
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",
|
|
76275
|
+
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"
|
|
76276
|
+
};
|
|
76277
|
+
let message = "delete this column?";
|
|
76278
|
+
if (NOTES[verdict]) {
|
|
76279
|
+
let children = [[
|
|
76280
|
+
"p",
|
|
76281
|
+
{
|
|
76282
|
+
class: "CONFIRM_MSG yui-confirm-msg",
|
|
76283
|
+
i18n: message
|
|
76284
|
+
},
|
|
76285
|
+
t(message)
|
|
76286
|
+
], [
|
|
76287
|
+
"p",
|
|
76288
|
+
{
|
|
76289
|
+
class: "SCHEMA_COLUMN_DATA_NOTE has-text-danger",
|
|
76290
|
+
i18n: NOTES[verdict]
|
|
76291
|
+
},
|
|
76292
|
+
t(NOTES[verdict])
|
|
76293
|
+
]];
|
|
76294
|
+
if (verdict === "capped") children.push([
|
|
76295
|
+
"p",
|
|
76296
|
+
{ class: "SCHEMA_COLUMN_DATA_READ" },
|
|
76297
|
+
[[
|
|
76298
|
+
"span",
|
|
76299
|
+
{ i18n: "records read" },
|
|
76300
|
+
t("records read")
|
|
76301
|
+
], [
|
|
76302
|
+
"span",
|
|
76303
|
+
{ class: "ml-1" },
|
|
76304
|
+
String(c.scanned)
|
|
76305
|
+
]]
|
|
76306
|
+
]);
|
|
76307
|
+
message = createElement2([
|
|
76308
|
+
"div",
|
|
76309
|
+
{ class: "SCHEMA_COLUMN_DATA_WARNING" },
|
|
76310
|
+
children
|
|
76311
|
+
]);
|
|
76312
|
+
}
|
|
76313
|
+
confirm_then(gobj, message, `${c.topic}.${c.col}`, {
|
|
76191
76314
|
what: "column",
|
|
76192
|
-
topic: topic
|
|
76193
|
-
col: col
|
|
76315
|
+
topic: c.topic,
|
|
76316
|
+
col: c.col
|
|
76194
76317
|
});
|
|
76195
76318
|
return 0;
|
|
76196
76319
|
}
|
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
|
|
package/src/c_yui_shell.css
CHANGED
|
@@ -175,6 +175,8 @@
|
|
|
175
175
|
display: flex;
|
|
176
176
|
justify-content: flex-start;
|
|
177
177
|
align-items: stretch;
|
|
178
|
+
gap: 0; /* Bulma's .level puts 0.75rem between the padded items: five
|
|
179
|
+
labels of gui_agent scrolled at 360px (Spanish 29px over) */
|
|
178
180
|
margin: 0;
|
|
179
181
|
padding: 0.25rem 0;
|
|
180
182
|
width: 100%;
|
|
@@ -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);
|