@yuneta/gobj-ui 7.23.167 → 7.23.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/gobj-ui.cjs.js +448 -104
- package/dist/gobj-ui.es.js +448 -104
- package/package.json +1 -1
- package/src/broadcast_attrs.test.js +115 -0
- package/src/c_g6_nodes_tree.js +208 -19
- package/src/c_yui_treedb_graph.js +4 -1
- package/src/c_yui_treedb_topic_with_form.js +276 -98
- package/src/c_yui_treedb_topics.js +4 -1
- package/src/yui_row_search.js +56 -27
- package/src/yui_row_search.test.js +51 -1
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -24336,7 +24336,8 @@ function request_print_tranger$1(gobj, path) {
|
|
|
24336
24336
|
expanded: 1,
|
|
24337
24337
|
lists_limit: 100,
|
|
24338
24338
|
dicts_limit: 100,
|
|
24339
|
-
path: path || ""
|
|
24339
|
+
path: path || "",
|
|
24340
|
+
__md_command__: { path: path || "" }
|
|
24340
24341
|
}, gobj);
|
|
24341
24342
|
if (ret) (0, _yuneta_gobj_js.log_error)(ret);
|
|
24342
24343
|
}
|
|
@@ -25562,49 +25563,65 @@ function yui_icon_is_defined(name) {
|
|
|
25562
25563
|
/***********************************************************************
|
|
25563
25564
|
* yui_row_search.js
|
|
25564
25565
|
*
|
|
25565
|
-
*
|
|
25566
|
+
* IS THIS TERM IN THIS ROW?
|
|
25567
|
+
*
|
|
25568
|
+
* The search box of a treedb table looked at the row's values with
|
|
25569
|
+
* `String(val)`, and a treedb row is not flat: an fkey arrives as a
|
|
25570
|
+
* LIST OF OBJECTS `[{id, topic_name, hook_name}]`, and `String()`
|
|
25571
|
+
* of that is `"[object Object]"`. So looking for the workshop of
|
|
25572
|
+
* a device -- which is where the datum an operator has in mind
|
|
25573
|
+
* lives -- never found anything, and the box gave no hint that it
|
|
25574
|
+
* had looked somewhere else.
|
|
25575
|
+
*
|
|
25576
|
+
* THREE RULES, AND THE LAST TWO ARE WHAT MAKE IT USEFUL:
|
|
25577
|
+
*
|
|
25578
|
+
* - It walks down lists and objects to a short depth: an fkey is
|
|
25579
|
+
* two levels down and nothing anybody searches for is deeper.
|
|
25580
|
+
* - **Of an fkey only the `id` is looked at.** `topic_name` and
|
|
25581
|
+
* `hook_name` are the SAME two words on every row, so looking at
|
|
25582
|
+
* them turns the term into a wildcard: searching "devices" would
|
|
25583
|
+
* bring the whole topic. The `id` is the only thing that names
|
|
25584
|
+
* the linked thing.
|
|
25585
|
+
* - **A hook read as its COUNT is not looked at at all.** Since
|
|
25586
|
+
* `hook_size` (7.23.163) a topic table loads a hook as
|
|
25587
|
+
* `[{"size": N}]` instead of the id of every child, and that
|
|
25588
|
+
* number is not a value of the row: matching it made "5" answer
|
|
25589
|
+
* every row whose hook happens to hold 5 children, next to the
|
|
25590
|
+
* rows that really say 5. A count nobody can see in the cell as
|
|
25591
|
+
* text is not what a person typing in a search box is after.
|
|
25592
|
+
*
|
|
25593
|
+
* Keys that start with `_` are not looked at on any level: they
|
|
25594
|
+
* belong to the scaffolding (`_check_box_state_`, `_operation`) or
|
|
25595
|
+
* are metadata (`__md_treedb__`), and nobody searches by them.
|
|
25566
25596
|
*
|
|
25567
|
-
*
|
|
25568
|
-
* la fila con `String(val)`, y una fila de treedb no es plana: un
|
|
25569
|
-
* fkey llega como una LISTA DE OBJETOS
|
|
25570
|
-
* `[{id, topic_name, hook_name}]`, y `String()` de eso es
|
|
25571
|
-
* `"[object Object]"`. O sea que buscar el taller de un equipo --
|
|
25572
|
-
* que es donde vive el dato que un operador tiene en la cabeza --
|
|
25573
|
-
* no encontraba nunca nada, y la caja no daba ninguna pista de que
|
|
25574
|
-
* había mirado en otro sitio.
|
|
25575
|
-
*
|
|
25576
|
-
* DOS REGLAS, Y LA SEGUNDA ES LA QUE HACE QUE SIRVA:
|
|
25577
|
-
*
|
|
25578
|
-
* - Se baja por listas y objetos hasta una profundidad corta: un
|
|
25579
|
-
* fkey está a dos niveles y nada de lo que se busca está más
|
|
25580
|
-
* hondo.
|
|
25581
|
-
* - **De un fkey se mira sólo el `id`.** `topic_name` y
|
|
25582
|
-
* `hook_name` son las MISMAS dos palabras en todas las filas, así
|
|
25583
|
-
* que mirarlas convierte el término en un comodín: buscar
|
|
25584
|
-
* "devices" traería el topic entero. El `id` es lo único que
|
|
25585
|
-
* nombra la cosa enlazada.
|
|
25586
|
-
*
|
|
25587
|
-
* Las claves que empiezan por `_` no se miran en ningún nivel: son
|
|
25588
|
-
* del armazón (`_check_box_state_`, `_operation`) o metadatos
|
|
25589
|
-
* (`__md_treedb__`), y nadie busca por ellas.
|
|
25590
|
-
*
|
|
25591
|
-
* Copyright (c) 2026, ArtGins.
|
|
25597
|
+
* Copyright (c) 2024-2026, ArtGins.
|
|
25592
25598
|
* All Rights Reserved.
|
|
25593
25599
|
***********************************************************************/
|
|
25594
25600
|
var MAX_DEPTH = 4;
|
|
25595
25601
|
/***************************************************************
|
|
25596
|
-
*
|
|
25602
|
+
* An fkey, as `nodes` answers it with `list_dict`.
|
|
25597
25603
|
***************************************************************/
|
|
25598
25604
|
function is_fkey_ref(value) {
|
|
25599
25605
|
return !!value && typeof value === "object" && !Array.isArray(value) && "id" in value && "topic_name" in value && "hook_name" in value;
|
|
25600
25606
|
}
|
|
25601
25607
|
/***************************************************************
|
|
25602
|
-
*
|
|
25603
|
-
*
|
|
25608
|
+
* A hook read with `hook_size`: the COUNT of its children,
|
|
25609
|
+
* `[{"size": N}]`, in the place of the children themselves.
|
|
25610
|
+
* The same shape `delete_impact`'s `ref_count()` reads.
|
|
25611
|
+
***************************************************************/
|
|
25612
|
+
function is_hook_size(value) {
|
|
25613
|
+
if (!Array.isArray(value) || value.length !== 1) return false;
|
|
25614
|
+
const first = value[0];
|
|
25615
|
+
return !!first && typeof first === "object" && !Array.isArray(first) && typeof first.size === "number" && Object.keys(first).length === 1;
|
|
25616
|
+
}
|
|
25617
|
+
/***************************************************************
|
|
25618
|
+
* Does `value` hold the term? The term comes ALREADY in lower
|
|
25619
|
+
* case: whoever searches lowers it once, not once per cell.
|
|
25604
25620
|
***************************************************************/
|
|
25605
25621
|
function value_matches(value, term, depth) {
|
|
25606
25622
|
if (value === null || value === void 0) return false;
|
|
25607
25623
|
if (depth > MAX_DEPTH) return false;
|
|
25624
|
+
if (is_hook_size(value)) return false;
|
|
25608
25625
|
if (Array.isArray(value)) return value.some((v) => value_matches(v, term, depth + 1));
|
|
25609
25626
|
if (typeof value === "object") {
|
|
25610
25627
|
if (is_fkey_ref(value)) return value_matches(value.id, term, depth + 1);
|
|
@@ -25616,7 +25633,7 @@ function value_matches(value, term, depth) {
|
|
|
25616
25633
|
return String(value).toLowerCase().includes(term);
|
|
25617
25634
|
}
|
|
25618
25635
|
/***************************************************************
|
|
25619
|
-
*
|
|
25636
|
+
* Is the term anywhere in this row?
|
|
25620
25637
|
***************************************************************/
|
|
25621
25638
|
function row_matches(row, term) {
|
|
25622
25639
|
if (!row || typeof row !== "object" || !term) return false;
|
|
@@ -25822,8 +25839,8 @@ var attrs_table$5 = [
|
|
|
25822
25839
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "with_checkbox", 0, true, "Auxiliary first column to select rows"),
|
|
25823
25840
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "with_radio", 0, false, "Auxiliary first column to select one row"),
|
|
25824
25841
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "with_selection_bar", 0, false, "Show the shared selection bar (\"N selected\" + a way out) above the table while in edition mode. OFF by default: the bar takes its words from the HOST's i18n, and a host that has not defined \"{{n}} selected\" and \"clear selection\" would render the keys"),
|
|
25825
|
-
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "broadcast_select_rows_event", 0, false, "
|
|
25826
|
-
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "broadcast_unselect_rows_event", 0, false, "
|
|
25842
|
+
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "broadcast_select_rows_event", 0, false, "Publish EV_SELECT_ROWS to the subscriber. OFF by default: the event is an OUTPUT event, so a host that turns it on must declare EV_SELECT_ROWS in its own FSM or it answers \"Event NOT DEFINED in state\" on every selected row"),
|
|
25843
|
+
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "broadcast_unselect_rows_event", 0, false, "Publish EV_UNSELECT_ROWS to the subscriber. Same contract as broadcast_select_rows_event, and INDEPENDENT of it: a host that wants both sets both"),
|
|
25827
25844
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_JSON, "tabulator_settings", 0, {
|
|
25828
25845
|
layout: "fitDataFill",
|
|
25829
25846
|
columnDefaults: { resizable: true },
|
|
@@ -26102,7 +26119,11 @@ function build_ui$5(gobj) {
|
|
|
26102
26119
|
"button",
|
|
26103
26120
|
{
|
|
26104
26121
|
id: ``,
|
|
26105
|
-
class: "button button-edit-record mr-1"
|
|
26122
|
+
class: "button button-edit-record mr-1",
|
|
26123
|
+
title: (0, i18next.t)("edit"),
|
|
26124
|
+
"data-i18n-title": "edit",
|
|
26125
|
+
"aria-label": (0, i18next.t)("edit"),
|
|
26126
|
+
"data-i18n-aria-label": "edit"
|
|
26106
26127
|
},
|
|
26107
26128
|
[yui_toolbar_icon("yi-pen"), [
|
|
26108
26129
|
"span",
|
|
@@ -26125,6 +26146,10 @@ function build_ui$5(gobj) {
|
|
|
26125
26146
|
{
|
|
26126
26147
|
id: ``,
|
|
26127
26148
|
class: "button button-new-record mr-1",
|
|
26149
|
+
title: (0, i18next.t)("new"),
|
|
26150
|
+
"data-i18n-title": "new",
|
|
26151
|
+
"aria-label": (0, i18next.t)("new"),
|
|
26152
|
+
"data-i18n-aria-label": "new",
|
|
26128
26153
|
disabled: true
|
|
26129
26154
|
},
|
|
26130
26155
|
[yui_toolbar_icon("yi-plus"), [
|
|
@@ -26149,6 +26174,10 @@ function build_ui$5(gobj) {
|
|
|
26149
26174
|
{
|
|
26150
26175
|
id: ``,
|
|
26151
26176
|
class: "button button-delete-record mr-1",
|
|
26177
|
+
title: (0, i18next.t)("delete"),
|
|
26178
|
+
"data-i18n-title": "delete",
|
|
26179
|
+
"aria-label": (0, i18next.t)("delete"),
|
|
26180
|
+
"data-i18n-aria-label": "delete",
|
|
26152
26181
|
disabled: true
|
|
26153
26182
|
},
|
|
26154
26183
|
[yui_toolbar_icon("yi-trash"), [
|
|
@@ -26173,6 +26202,10 @@ function build_ui$5(gobj) {
|
|
|
26173
26202
|
{
|
|
26174
26203
|
id: ``,
|
|
26175
26204
|
class: "button button-copy-record mr-1",
|
|
26205
|
+
title: (0, i18next.t)("copy"),
|
|
26206
|
+
"data-i18n-title": "copy",
|
|
26207
|
+
"aria-label": (0, i18next.t)("copy"),
|
|
26208
|
+
"data-i18n-aria-label": "copy",
|
|
26176
26209
|
disabled: true
|
|
26177
26210
|
},
|
|
26178
26211
|
[yui_toolbar_icon("yi-copy"), [
|
|
@@ -26197,6 +26230,10 @@ function build_ui$5(gobj) {
|
|
|
26197
26230
|
{
|
|
26198
26231
|
id: ``,
|
|
26199
26232
|
class: "button button-paste-record mr-1",
|
|
26233
|
+
title: (0, i18next.t)("paste"),
|
|
26234
|
+
"data-i18n-title": "paste",
|
|
26235
|
+
"aria-label": (0, i18next.t)("paste"),
|
|
26236
|
+
"data-i18n-aria-label": "paste",
|
|
26200
26237
|
disabled: true
|
|
26201
26238
|
},
|
|
26202
26239
|
[yui_toolbar_icon("yi-paste"), [
|
|
@@ -26236,7 +26273,11 @@ function build_ui$5(gobj) {
|
|
|
26236
26273
|
class: "input",
|
|
26237
26274
|
type: "text",
|
|
26238
26275
|
placeholder: (0, i18next.t)("search"),
|
|
26239
|
-
"data-i18n-placeholder": "search"
|
|
26276
|
+
"data-i18n-placeholder": "search",
|
|
26277
|
+
title: (0, i18next.t)("search"),
|
|
26278
|
+
"data-i18n-title": "search",
|
|
26279
|
+
"aria-label": (0, i18next.t)("search"),
|
|
26280
|
+
"data-i18n-aria-label": "search"
|
|
26240
26281
|
}], [
|
|
26241
26282
|
"span",
|
|
26242
26283
|
{ class: "icon is-left" },
|
|
@@ -26256,7 +26297,9 @@ function build_ui$5(gobj) {
|
|
|
26256
26297
|
{
|
|
26257
26298
|
class: "button mr-1",
|
|
26258
26299
|
title: (0, i18next.t)("refresh"),
|
|
26259
|
-
"data-i18n-title": "refresh"
|
|
26300
|
+
"data-i18n-title": "refresh",
|
|
26301
|
+
"aria-label": (0, i18next.t)("refresh"),
|
|
26302
|
+
"data-i18n-aria-label": "refresh"
|
|
26260
26303
|
},
|
|
26261
26304
|
[yui_toolbar_icon("yi-arrows-rotate"), [
|
|
26262
26305
|
"span",
|
|
@@ -26789,7 +26832,7 @@ function create_tabulator(gobj) {
|
|
|
26789
26832
|
let index = cell.getRow().getPosition();
|
|
26790
26833
|
if (e.target.closest(".edit")) {
|
|
26791
26834
|
e.stopPropagation();
|
|
26792
|
-
|
|
26835
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_EDIT_RECORD", { index }, gobj);
|
|
26793
26836
|
} else if (e.target.closest(".remove")) {
|
|
26794
26837
|
e.stopPropagation();
|
|
26795
26838
|
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_DELETE_ROWS", {
|
|
@@ -27194,8 +27237,9 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
|
|
|
27194
27237
|
* C_YUI_FORM renders a col that is not `writable` read-only on
|
|
27195
27238
|
* its own (`build_form_field_conf`), so this is the whole of
|
|
27196
27239
|
* it. What must NOT follow is sending them back:
|
|
27197
|
-
* `
|
|
27198
|
-
* the reason is written
|
|
27240
|
+
* `strip_read_only_cols()` drops them from every write of the
|
|
27241
|
+
* form (`publish_treedb_write()`), and the reason is written at
|
|
27242
|
+
* `col_goes_back_to_treedb()`.
|
|
27199
27243
|
*
|
|
27200
27244
|
* Still out: hooks (a hook is not a field of the record, it is
|
|
27201
27245
|
* the children hanging off it), hidden cols, and the `_`
|
|
@@ -27250,11 +27294,11 @@ function open_form_dialog(gobj, mode, record) {
|
|
|
27250
27294
|
return;
|
|
27251
27295
|
}
|
|
27252
27296
|
let pkey = desc.pkey || "id";
|
|
27253
|
-
let title;
|
|
27254
|
-
|
|
27255
|
-
|
|
27297
|
+
let title = mode === "create" ? "new" : mode === "view" ? "view" : "edit";
|
|
27298
|
+
let title_prefix = "";
|
|
27299
|
+
if (mode !== "create") {
|
|
27256
27300
|
let rid = record ? String(record[pkey] ?? "") : "";
|
|
27257
|
-
|
|
27301
|
+
title_prefix = (0, _yuneta_gobj_js.empty_string)(rid) ? "" : rid;
|
|
27258
27302
|
}
|
|
27259
27303
|
let view_only = mode === "view";
|
|
27260
27304
|
let form_mode = view_only ? "update" : mode;
|
|
@@ -27289,6 +27333,7 @@ function open_form_dialog(gobj, mode, record) {
|
|
|
27289
27333
|
priv.form_modal = yui_shell_show_modal(shell, $body, {
|
|
27290
27334
|
dialog: true,
|
|
27291
27335
|
logical_class: "TREEDB_FORM_SHEET",
|
|
27336
|
+
title_prefix,
|
|
27292
27337
|
title,
|
|
27293
27338
|
t: i18next.t,
|
|
27294
27339
|
before_close: function() {
|
|
@@ -27317,14 +27362,7 @@ function form_may_close(gobj) {
|
|
|
27317
27362
|
let kw = {};
|
|
27318
27363
|
(0, _yuneta_gobj_js.gobj_send_event)(priv.form, "EV_WINDOW_TO_CLOSE", kw, gobj);
|
|
27319
27364
|
if (kw.abort_close) {
|
|
27320
|
-
|
|
27321
|
-
t: i18next.t,
|
|
27322
|
-
yes_label: "yes",
|
|
27323
|
-
no_label: "no",
|
|
27324
|
-
cancel_label: "cancel"
|
|
27325
|
-
}).then(function(answer) {
|
|
27326
|
-
if (answer === "yes" && priv.form_modal) priv.form_modal.close();
|
|
27327
|
-
});
|
|
27365
|
+
confirm_then$1(gobj, kw.warning || "all changes will be lost", { what: "close_form" });
|
|
27328
27366
|
return false;
|
|
27329
27367
|
}
|
|
27330
27368
|
}
|
|
@@ -27346,6 +27384,31 @@ function teardown_form_child(gobj) {
|
|
|
27346
27384
|
priv.form_modal = null;
|
|
27347
27385
|
}
|
|
27348
27386
|
/************************************************************
|
|
27387
|
+
* Ask, and turn the answer into an EVENT.
|
|
27388
|
+
*
|
|
27389
|
+
* A dialog's promise settles outside the machine: acting from its
|
|
27390
|
+
* `.then` puts the decision -- delete these records, throw these
|
|
27391
|
+
* edits away -- in a callback the `machine` trace never sees, and
|
|
27392
|
+
* in a view that may be gone by the time the person answers.
|
|
27393
|
+
*
|
|
27394
|
+
* `kw` carries an IDENTITY and never an object: the trace dumps
|
|
27395
|
+
* it, and a gobj, a Tabulator row or a DOM node in there is a
|
|
27396
|
+
* circular structure that breaks the very trace the FSM feeds.
|
|
27397
|
+
*
|
|
27398
|
+
* Same shape as C_YUI_SCHEMA_EDITOR's confirm_then().
|
|
27399
|
+
************************************************************/
|
|
27400
|
+
function confirm_then$1(gobj, message, kw) {
|
|
27401
|
+
yui_shell_confirm_yesnocancel(yui_shell_of(gobj), message, {
|
|
27402
|
+
t: i18next.t,
|
|
27403
|
+
yes_label: "yes",
|
|
27404
|
+
no_label: "no",
|
|
27405
|
+
cancel_label: "cancel"
|
|
27406
|
+
}).then(function(answer) {
|
|
27407
|
+
if (answer !== "yes" || (0, _yuneta_gobj_js.gobj_is_destroying)(gobj)) return;
|
|
27408
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CONFIRMED", kw, gobj);
|
|
27409
|
+
});
|
|
27410
|
+
}
|
|
27411
|
+
/************************************************************
|
|
27349
27412
|
* Force the dialog down (bypasses the unsaved guard): used after a
|
|
27350
27413
|
* successful save and on teardown. Closing the modal runs its
|
|
27351
27414
|
* on_close, which tears the form child down.
|
|
@@ -27926,7 +27989,7 @@ function pkey_is_rowid(gobj) {
|
|
|
27926
27989
|
* Show the edit "update" form of a row (record)
|
|
27927
27990
|
* internally called from the icon edit at Op column
|
|
27928
27991
|
************************************************************/
|
|
27929
|
-
function show_edit_form(gobj, row
|
|
27992
|
+
function show_edit_form(gobj, row) {
|
|
27930
27993
|
open_form_dialog(gobj, pkey_is_rowid(gobj) ? "create" : "update", row);
|
|
27931
27994
|
}
|
|
27932
27995
|
/************************************************************
|
|
@@ -27988,18 +28051,61 @@ function get_schema_col(gobj, id) {
|
|
|
27988
28051
|
return null;
|
|
27989
28052
|
}
|
|
27990
28053
|
/************************************************************
|
|
28054
|
+
* Does column `col` travel back to treedb on a write?
|
|
28055
|
+
*
|
|
28056
|
+
* The form SHOWS every field and sends back only what the topic
|
|
28057
|
+
* accepts: the writable cols, the fkeys (a link is edited by
|
|
28058
|
+
* linking) and the pkey, which is not written but is what
|
|
28059
|
+
* ADDRESSES the record.
|
|
28060
|
+
*
|
|
28061
|
+
* It matters because `treedb_update_node()` does not check
|
|
28062
|
+
* `writable` -- it writes any col it is handed -- so a read-only
|
|
28063
|
+
* field travelling back is written with whatever the form made of
|
|
28064
|
+
* it, and the fields that describe a record are exactly the ones
|
|
28065
|
+
* that do not survive a round trip through a widget: a `time` is an
|
|
28066
|
+
* integer rendered as a `datetime-local`, with no seconds, so every
|
|
28067
|
+
* save moved it back up to 59 s. Nothing looked wrong until the
|
|
28068
|
+
* stored timestamp had moved.
|
|
28069
|
+
*
|
|
28070
|
+
* `is_file` and not the type: a `file` column IS an fkey (it is
|
|
28071
|
+
* flagged ['fkey','file']) but answers `type: "file"`, and the write
|
|
28072
|
+
* goes out with `autolink`, which rebuilds the links from what the
|
|
28073
|
+
* record carries. Dropped, a read-only `file` column -- the one only
|
|
28074
|
+
* a load fills -- was UNLINKED by every save of any other field.
|
|
28075
|
+
************************************************************/
|
|
28076
|
+
function col_goes_back_to_treedb(gobj, col) {
|
|
28077
|
+
let pkey = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "desc").pkey || "id";
|
|
28078
|
+
const field_desc = (0, _yuneta_gobj_js.treedb_get_field_desc)(col);
|
|
28079
|
+
if (field_desc.is_writable || field_desc.type === "fkey" || field_desc.is_file || col.id === pkey) return true;
|
|
28080
|
+
return false;
|
|
28081
|
+
}
|
|
28082
|
+
/************************************************************
|
|
28083
|
+
* The record the FORM hands over, without the columns that do
|
|
28084
|
+
* not go back to treedb (see col_goes_back_to_treedb()). The
|
|
28085
|
+
* form has already encoded the values, so only the columns are
|
|
28086
|
+
* taken out; keys that are not columns are left as they are.
|
|
28087
|
+
************************************************************/
|
|
28088
|
+
function strip_read_only_cols(gobj, record) {
|
|
28089
|
+
let row = {};
|
|
28090
|
+
for (let field_name of Object.keys(record || {})) {
|
|
28091
|
+
let col = get_schema_col(gobj, field_name);
|
|
28092
|
+
if (col && !col_goes_back_to_treedb(gobj, col)) continue;
|
|
28093
|
+
row[field_name] = record[field_name];
|
|
28094
|
+
}
|
|
28095
|
+
return row;
|
|
28096
|
+
}
|
|
28097
|
+
/************************************************************
|
|
27991
28098
|
* Convert from frontend to backend
|
|
27992
28099
|
* operation: "create" "update"
|
|
27993
28100
|
************************************************************/
|
|
27994
28101
|
function transform__form_record_2_treedb_record(gobj, kw, operation) {
|
|
27995
|
-
|
|
28102
|
+
(0, _yuneta_gobj_js.gobj_read_attr)(gobj, "desc").pkey;
|
|
27996
28103
|
let row = {};
|
|
27997
28104
|
for (let field_name of Object.keys(kw)) {
|
|
27998
28105
|
if ((0, _yuneta_gobj_js.empty_string)(field_name)) continue;
|
|
27999
28106
|
let col = get_schema_col(gobj, field_name);
|
|
28000
28107
|
if (!col) continue;
|
|
28001
|
-
|
|
28002
|
-
if (!field_desc.is_writable && field_desc.type !== "fkey" && !field_desc.is_file && col.id !== pkey) continue;
|
|
28108
|
+
if (!col_goes_back_to_treedb(gobj, col)) continue;
|
|
28003
28109
|
let value = kw[field_name];
|
|
28004
28110
|
row[field_name] = transform__form_value_2_treedb_value(gobj, col, value, operation);
|
|
28005
28111
|
}
|
|
@@ -28314,10 +28420,10 @@ function ac_edition_mode(gobj, event, kw, src) {
|
|
|
28314
28420
|
tabulator.showColumn("_operation");
|
|
28315
28421
|
tabulator.showColumn("_check_box_state_");
|
|
28316
28422
|
$button_new_record.removeAttribute("disabled");
|
|
28317
|
-
$button_paste_record.removeAttribute("disabled");
|
|
28423
|
+
if ($button_paste_record) $button_paste_record.removeAttribute("disabled");
|
|
28318
28424
|
if (yui_selected_rows(tabulator).length) {
|
|
28319
28425
|
$button_delete_record.removeAttribute("disabled");
|
|
28320
|
-
$button_copy_record.removeAttribute("disabled");
|
|
28426
|
+
if ($button_copy_record) $button_copy_record.removeAttribute("disabled");
|
|
28321
28427
|
}
|
|
28322
28428
|
} else {
|
|
28323
28429
|
$button_edit_record.classList.remove("is-primary");
|
|
@@ -28327,8 +28433,8 @@ function ac_edition_mode(gobj, event, kw, src) {
|
|
|
28327
28433
|
tabulator.hideColumn("_check_box_state_");
|
|
28328
28434
|
$button_new_record.setAttribute("disabled", true);
|
|
28329
28435
|
$button_delete_record.setAttribute("disabled", true);
|
|
28330
|
-
$button_copy_record.setAttribute("disabled", true);
|
|
28331
|
-
$button_paste_record.setAttribute("disabled", true);
|
|
28436
|
+
if ($button_copy_record) $button_copy_record.setAttribute("disabled", true);
|
|
28437
|
+
if ($button_paste_record) $button_paste_record.setAttribute("disabled", true);
|
|
28332
28438
|
}
|
|
28333
28439
|
render_selection_bar(gobj);
|
|
28334
28440
|
return 0;
|
|
@@ -28382,31 +28488,57 @@ function ac_delete_rows(gobj, event, kw, src) {
|
|
|
28382
28488
|
});
|
|
28383
28489
|
return 0;
|
|
28384
28490
|
}
|
|
28385
|
-
|
|
28386
|
-
|
|
28387
|
-
|
|
28388
|
-
|
|
28389
|
-
cancel_label: "cancel"
|
|
28390
|
-
}).then(function(answer) {
|
|
28391
|
-
if (answer === "yes") for (let row of rows) (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_DELETE_RECORD", {
|
|
28392
|
-
topic_name: (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "topic_name"),
|
|
28393
|
-
record: row
|
|
28394
|
-
});
|
|
28395
|
-
});
|
|
28396
|
-
} else yui_shell_confirm_yesnocancel(yui_shell_of(gobj), build_delete_question(gobj, kw.row), {
|
|
28397
|
-
t: i18next.t,
|
|
28398
|
-
yes_label: "yes",
|
|
28399
|
-
no_label: "no",
|
|
28400
|
-
cancel_label: "cancel"
|
|
28401
|
-
}).then(function(answer) {
|
|
28402
|
-
if (answer === "yes") (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_DELETE_RECORD", {
|
|
28403
|
-
topic_name: (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "topic_name"),
|
|
28404
|
-
record: kw.row
|
|
28405
|
-
});
|
|
28491
|
+
confirm_then$1(gobj, build_delete_question(gobj, rows), { what: "delete_selection" });
|
|
28492
|
+
} else confirm_then$1(gobj, build_delete_question(gobj, kw.row), {
|
|
28493
|
+
what: "delete_row",
|
|
28494
|
+
index: kw.index
|
|
28406
28495
|
});
|
|
28407
28496
|
return 0;
|
|
28408
28497
|
}
|
|
28409
28498
|
/************************************************************
|
|
28499
|
+
* {what, ...} -- the person said yes to what confirm_then()
|
|
28500
|
+
* asked. The rows are read again HERE and not carried in the
|
|
28501
|
+
* kw: the kw is plain json, and a Tabulator row is not.
|
|
28502
|
+
************************************************************/
|
|
28503
|
+
function ac_confirmed$2(gobj, event, kw, src) {
|
|
28504
|
+
let priv = gobj.priv;
|
|
28505
|
+
let what = kw ? kw.what : "";
|
|
28506
|
+
if (what === "close_form") {
|
|
28507
|
+
if (priv.form_modal) priv.form_modal.close();
|
|
28508
|
+
return 0;
|
|
28509
|
+
}
|
|
28510
|
+
if (refuse_if_readonly$2(gobj, event)) return -1;
|
|
28511
|
+
let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
|
|
28512
|
+
let topic_name = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "topic_name");
|
|
28513
|
+
if (what === "delete_selection") {
|
|
28514
|
+
let rows = yui_selected_rows(tabulator);
|
|
28515
|
+
if (!rows.length) {
|
|
28516
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} with the selection gone`);
|
|
28517
|
+
return -1;
|
|
28518
|
+
}
|
|
28519
|
+
for (let row of rows) (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_DELETE_RECORD", {
|
|
28520
|
+
topic_name,
|
|
28521
|
+
record: row
|
|
28522
|
+
});
|
|
28523
|
+
return 0;
|
|
28524
|
+
}
|
|
28525
|
+
if (what === "delete_row") {
|
|
28526
|
+
let index = kw.index;
|
|
28527
|
+
let row = tabulator && typeof index === "number" ? tabulator.getRowFromPosition(index) : null;
|
|
28528
|
+
if (!row) {
|
|
28529
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} names no row: ${index}`);
|
|
28530
|
+
return -1;
|
|
28531
|
+
}
|
|
28532
|
+
(0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_DELETE_RECORD", {
|
|
28533
|
+
topic_name,
|
|
28534
|
+
record: row.getData()
|
|
28535
|
+
});
|
|
28536
|
+
return 0;
|
|
28537
|
+
}
|
|
28538
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} of nothing this view asked about: ${what}`);
|
|
28539
|
+
return -1;
|
|
28540
|
+
}
|
|
28541
|
+
/************************************************************
|
|
28410
28542
|
* From internal
|
|
28411
28543
|
************************************************************/
|
|
28412
28544
|
function ac_copy_rows(gobj, event, kw, src) {
|
|
@@ -28461,9 +28593,7 @@ function ac_form_save_record(gobj, event, kw, src) {
|
|
|
28461
28593
|
const cols = Object.keys(picked);
|
|
28462
28594
|
if (cols.length === 0) {
|
|
28463
28595
|
publish_treedb_write(gobj, mode, kw);
|
|
28464
|
-
|
|
28465
|
-
close_form_dialog(gobj);
|
|
28466
|
-
}, 0);
|
|
28596
|
+
(0, _yuneta_gobj_js.gobj_post_event)(gobj, "EV_CLOSE_FORM", {}, gobj);
|
|
28467
28597
|
return 0;
|
|
28468
28598
|
}
|
|
28469
28599
|
const serial = ++priv.read_serial;
|
|
@@ -28535,12 +28665,20 @@ function read_is_current(gobj, kw) {
|
|
|
28535
28665
|
function publish_treedb_write(gobj, mode, record, jn_files) {
|
|
28536
28666
|
const kw_write = {
|
|
28537
28667
|
topic_name: (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "topic_name"),
|
|
28538
|
-
record
|
|
28668
|
+
record: strip_read_only_cols(gobj, record)
|
|
28539
28669
|
};
|
|
28540
28670
|
if (jn_files && Object.keys(jn_files).length > 0) kw_write.record.__files__ = jn_files;
|
|
28541
28671
|
(0, _yuneta_gobj_js.gobj_publish_event)(gobj, mode === "create" ? "EV_CREATE_RECORD" : "EV_UPDATE_RECORD", kw_write);
|
|
28542
28672
|
}
|
|
28543
28673
|
/************************************************************
|
|
28674
|
+
* The deferred close of the form dialog, posted by the save
|
|
28675
|
+
* from inside the form child's own publish stack.
|
|
28676
|
+
************************************************************/
|
|
28677
|
+
function ac_close_form(gobj, event, kw, src) {
|
|
28678
|
+
close_form_dialog(gobj);
|
|
28679
|
+
return 0;
|
|
28680
|
+
}
|
|
28681
|
+
/************************************************************
|
|
28544
28682
|
* {mode, record, picks} -- the bytes are here now
|
|
28545
28683
|
************************************************************/
|
|
28546
28684
|
function ac_files_read(gobj, event, kw, src) {
|
|
@@ -28581,7 +28719,7 @@ function ac_select_rows(gobj, event, kw, src) {
|
|
|
28581
28719
|
************************************************************/
|
|
28582
28720
|
function ac_unselect_rows(gobj, event, kw, src) {
|
|
28583
28721
|
render_selection_state(gobj);
|
|
28584
|
-
if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "
|
|
28722
|
+
if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "broadcast_unselect_rows_event")) (0, _yuneta_gobj_js.gobj_publish_event)(gobj, event, kw);
|
|
28585
28723
|
return 0;
|
|
28586
28724
|
}
|
|
28587
28725
|
/************************************************************
|
|
@@ -29061,6 +29199,26 @@ function ac_show_record(gobj, event, kw, src) {
|
|
|
29061
29199
|
return 0;
|
|
29062
29200
|
}
|
|
29063
29201
|
/************************************************************
|
|
29202
|
+
* {index} -- the pencil of the Op column. Same shape as
|
|
29203
|
+
* EV_SHOW_RECORD: the kw carries WHICH row, and the row itself
|
|
29204
|
+
* is resolved here, where the table is.
|
|
29205
|
+
************************************************************/
|
|
29206
|
+
function ac_edit_record(gobj, event, kw, src) {
|
|
29207
|
+
let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
|
|
29208
|
+
let index = kw ? kw.index : void 0;
|
|
29209
|
+
if (!tabulator || typeof index !== "number") {
|
|
29210
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: no row ${index} to edit`);
|
|
29211
|
+
return -1;
|
|
29212
|
+
}
|
|
29213
|
+
let row = tabulator.getRowFromPosition(index);
|
|
29214
|
+
if (!row) {
|
|
29215
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: row ${index} is gone`);
|
|
29216
|
+
return -1;
|
|
29217
|
+
}
|
|
29218
|
+
show_edit_form(gobj, row.getData());
|
|
29219
|
+
return 0;
|
|
29220
|
+
}
|
|
29221
|
+
/************************************************************
|
|
29064
29222
|
* The reader picked another page size: remember it, so coming back to
|
|
29065
29223
|
* this topic opens where they left it instead of at 200.
|
|
29066
29224
|
************************************************************/
|
|
@@ -29185,6 +29343,11 @@ function create_gclass$5(gclass_name) {
|
|
|
29185
29343
|
ac_form_save_record,
|
|
29186
29344
|
null
|
|
29187
29345
|
],
|
|
29346
|
+
[
|
|
29347
|
+
"EV_CLOSE_FORM",
|
|
29348
|
+
ac_close_form,
|
|
29349
|
+
null
|
|
29350
|
+
],
|
|
29188
29351
|
[
|
|
29189
29352
|
"EV_FILES_READ",
|
|
29190
29353
|
ac_files_read,
|
|
@@ -29205,6 +29368,11 @@ function create_gclass$5(gclass_name) {
|
|
|
29205
29368
|
ac_delete_rows,
|
|
29206
29369
|
null
|
|
29207
29370
|
],
|
|
29371
|
+
[
|
|
29372
|
+
"EV_CONFIRMED",
|
|
29373
|
+
ac_confirmed$2,
|
|
29374
|
+
null
|
|
29375
|
+
],
|
|
29208
29376
|
[
|
|
29209
29377
|
"EV_SELECT_ROWS",
|
|
29210
29378
|
ac_select_rows,
|
|
@@ -29330,6 +29498,11 @@ function create_gclass$5(gclass_name) {
|
|
|
29330
29498
|
ac_show_record,
|
|
29331
29499
|
null
|
|
29332
29500
|
],
|
|
29501
|
+
[
|
|
29502
|
+
"EV_EDIT_RECORD",
|
|
29503
|
+
ac_edit_record,
|
|
29504
|
+
null
|
|
29505
|
+
],
|
|
29333
29506
|
[
|
|
29334
29507
|
"EV_TOGGLE_COLUMN",
|
|
29335
29508
|
ac_toggle_column,
|
|
@@ -29359,10 +29532,12 @@ function create_gclass$5(gclass_name) {
|
|
|
29359
29532
|
["EV_NODE_DELETED", 0],
|
|
29360
29533
|
["EV_EDITION_MODE", 0],
|
|
29361
29534
|
["EV_SAVE_RECORD", 0],
|
|
29535
|
+
["EV_CLOSE_FORM", 0],
|
|
29362
29536
|
["EV_FILES_READ", 0],
|
|
29363
29537
|
["EV_FILES_FAILED", 0],
|
|
29364
29538
|
["EV_NEW_ROW", 0],
|
|
29365
29539
|
["EV_DELETE_ROWS", 0],
|
|
29540
|
+
["EV_CONFIRMED", 0],
|
|
29366
29541
|
["EV_COPY_ROWS", 0],
|
|
29367
29542
|
["EV_PASTE_ROWS", 0],
|
|
29368
29543
|
["EV_CLEAR_SELECTION", 0],
|
|
@@ -29392,6 +29567,7 @@ function create_gclass$5(gclass_name) {
|
|
|
29392
29567
|
["EV_OPEN_COLUMNS", 0],
|
|
29393
29568
|
["EV_PAGE_SIZE_CHANGED", 0],
|
|
29394
29569
|
["EV_SHOW_RECORD", 0],
|
|
29570
|
+
["EV_EDIT_RECORD", 0],
|
|
29395
29571
|
["EV_TOGGLE_COLUMN", 0],
|
|
29396
29572
|
["EV_EXPORT_TABLE", 0],
|
|
29397
29573
|
["EV_CREATE_RECORD", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT],
|
|
@@ -57925,13 +58101,38 @@ function build_graph$1(gobj) {
|
|
|
57925
58101
|
graph.setLayout(layout);
|
|
57926
58102
|
priv.graph_rendered = false;
|
|
57927
58103
|
graph_render(gobj).then(() => {
|
|
58104
|
+
if ((0, _yuneta_gobj_js.gobj_is_destroying)(gobj) || !priv.graph) return;
|
|
57928
58105
|
configure_events(gobj);
|
|
57929
58106
|
configure_behaviour(gobj);
|
|
57930
58107
|
configure_plugins(gobj);
|
|
57931
58108
|
priv.graph_rendered = true;
|
|
58109
|
+
}).catch((e) => {
|
|
58110
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: graph render failed: ${e}`);
|
|
57932
58111
|
});
|
|
57933
58112
|
}
|
|
57934
58113
|
/************************************************************
|
|
58114
|
+
* A G6 event, as PLAIN JSON.
|
|
58115
|
+
*
|
|
58116
|
+
* A kw is dumped by the `machine` trace (`trace_json(kw)`), and a
|
|
58117
|
+
* G6 / @antv/g event is circular: serializing one THROWS, so the
|
|
58118
|
+
* first thing a kw carrying `evt` breaks is the trace the FSM
|
|
58119
|
+
* exists to feed. It also drags a live graph element into a
|
|
58120
|
+
* message that may be read after that element is gone.
|
|
58121
|
+
*
|
|
58122
|
+
* What the actions read of it is an id and three scalars. The
|
|
58123
|
+
* event itself never leaves the callback that received it.
|
|
58124
|
+
************************************************************/
|
|
58125
|
+
function g6_event_kw(evt) {
|
|
58126
|
+
let target = evt && evt.target ? evt.target : null;
|
|
58127
|
+
let client = evt && evt.client ? evt.client : null;
|
|
58128
|
+
return {
|
|
58129
|
+
id: target && target.id ? String(target.id) : "",
|
|
58130
|
+
shift: !!(evt && evt.shiftKey),
|
|
58131
|
+
client_x: client && typeof client.x === "number" ? client.x : 0,
|
|
58132
|
+
client_y: client && typeof client.y === "number" ? client.y : 0
|
|
58133
|
+
};
|
|
58134
|
+
}
|
|
58135
|
+
/************************************************************
|
|
57935
58136
|
* Configure G6 event handlers
|
|
57936
58137
|
************************************************************/
|
|
57937
58138
|
function configure_events(gobj) {
|
|
@@ -57939,7 +58140,7 @@ function configure_events(gobj) {
|
|
|
57939
58140
|
let graph = priv.graph;
|
|
57940
58141
|
graph.on(_antv_g6.CanvasEvent.CLICK, (evt) => {
|
|
57941
58142
|
if (consume_long_press_click(graph)) return;
|
|
57942
|
-
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CANVAS_CLICK",
|
|
58143
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CANVAS_CLICK", g6_event_kw(evt), gobj);
|
|
57943
58144
|
});
|
|
57944
58145
|
graph.on(_antv_g6.NodeEvent.DRAG, (evt) => {
|
|
57945
58146
|
update_resize_handles_position(gobj);
|
|
@@ -57950,21 +58151,21 @@ function configure_events(gobj) {
|
|
|
57950
58151
|
update_port_icon_position(gobj);
|
|
57951
58152
|
});
|
|
57952
58153
|
graph.on(_antv_g6.NodeEvent.DRAG_END, (evt) => {
|
|
57953
|
-
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_DRAG_END",
|
|
58154
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_DRAG_END", g6_event_kw(evt), gobj);
|
|
57954
58155
|
});
|
|
57955
58156
|
graph.on(_antv_g6.NodeEvent.CLICK, (evt) => {
|
|
57956
58157
|
if (consume_long_press_click(graph)) return;
|
|
57957
|
-
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_CLICK",
|
|
58158
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_CLICK", g6_event_kw(evt), gobj);
|
|
57958
58159
|
});
|
|
57959
58160
|
graph.on(_antv_g6.NodeEvent.CONTEXT_MENU, (evt) => {
|
|
57960
|
-
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_CONTEXT_MENU",
|
|
58161
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_CONTEXT_MENU", g6_event_kw(evt), gobj);
|
|
57961
58162
|
});
|
|
57962
58163
|
graph.on(_antv_g6.NodeEvent.DBLCLICK, (evt) => {
|
|
57963
|
-
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_DBLCLICK",
|
|
58164
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_DBLCLICK", g6_event_kw(evt), gobj);
|
|
57964
58165
|
});
|
|
57965
58166
|
graph.on(_antv_g6.EdgeEvent.CLICK, (evt) => {
|
|
57966
58167
|
if (consume_long_press_click(graph)) return;
|
|
57967
|
-
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_EDGE_CLICK",
|
|
58168
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_EDGE_CLICK", g6_event_kw(evt), gobj);
|
|
57968
58169
|
});
|
|
57969
58170
|
graph.on("aftertransform", () => {
|
|
57970
58171
|
update_resize_handles_position(gobj);
|
|
@@ -58048,7 +58249,7 @@ function configure_plugins(gobj) {
|
|
|
58048
58249
|
graph_add_plugin(gobj, "contextmenu", {
|
|
58049
58250
|
trigger: "contextmenu",
|
|
58050
58251
|
onClick: (value) => {
|
|
58051
|
-
|
|
58252
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CONTEXT_MENU_ITEM", { value: String(value) }, gobj);
|
|
58052
58253
|
},
|
|
58053
58254
|
getItems: (e) => {
|
|
58054
58255
|
return build_context_menu_items(gobj, e);
|
|
@@ -61764,7 +61965,7 @@ function show_edge_icon(gobj) {
|
|
|
61764
61965
|
if (!priv._selected_edge_id) return;
|
|
61765
61966
|
let mid = get_edge_viewport_midpoint(gobj, priv._selected_edge_id);
|
|
61766
61967
|
if (!mid) return;
|
|
61767
|
-
let icons = show_dual_icons(gobj, mid.x + 4, mid.y + floating_icon_dy(), (0, i18next.t)("edge properties"), () => toggle_edge_popover(gobj), (0, i18next.t)("unlink"), () =>
|
|
61968
|
+
let icons = show_dual_icons(gobj, mid.x + 4, mid.y + floating_icon_dy(), (0, i18next.t)("edge properties"), () => toggle_edge_popover(gobj), (0, i18next.t)("unlink"), () => (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_REQUEST_UNLINK_EDGE", {}, gobj));
|
|
61768
61969
|
priv._edge_icon_el = icons.icon_el;
|
|
61769
61970
|
priv._edge_delete_el = icons.delete_el;
|
|
61770
61971
|
}
|
|
@@ -61919,7 +62120,7 @@ function show_node_icon(gobj) {
|
|
|
61919
62120
|
if (!priv._selected_node_id || priv._selected_port_key) return;
|
|
61920
62121
|
let rect = get_node_viewport_rect(gobj, priv._selected_node_id);
|
|
61921
62122
|
if (!rect) return;
|
|
61922
|
-
let icons = show_dual_icons(gobj, rect.right + 4, rect.top + floating_icon_dy(), (0, i18next.t)("node properties"), () => toggle_node_popover(gobj), (0, i18next.t)("delete node"), () =>
|
|
62123
|
+
let icons = show_dual_icons(gobj, rect.right + 4, rect.top + floating_icon_dy(), (0, i18next.t)("node properties"), () => toggle_node_popover(gobj), (0, i18next.t)("delete node"), () => (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_REQUEST_DELETE_NODE", {}, gobj));
|
|
61923
62124
|
priv._node_icon_el = icons.icon_el;
|
|
61924
62125
|
priv._node_delete_el = icons.delete_el;
|
|
61925
62126
|
}
|
|
@@ -62632,7 +62833,10 @@ function request_delete_selection(gobj) {
|
|
|
62632
62833
|
execute_delete_selection(gobj, nodes);
|
|
62633
62834
|
return;
|
|
62634
62835
|
}
|
|
62635
|
-
show_confirm_popover(gobj, null, delete_question(nodes), "delete", "#ff4d4f", () =>
|
|
62836
|
+
show_confirm_popover(gobj, null, delete_question(nodes), "delete", "#ff4d4f", () => (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CONFIRMED", {
|
|
62837
|
+
what: "delete_selection",
|
|
62838
|
+
ids: nodes.map((nd) => String(nd.id))
|
|
62839
|
+
}, gobj), "_delete_confirm_el");
|
|
62636
62840
|
}
|
|
62637
62841
|
function execute_delete_selection(gobj, nodes) {
|
|
62638
62842
|
let priv = gobj.priv;
|
|
@@ -62649,7 +62853,10 @@ function execute_delete_selection(gobj, nodes) {
|
|
|
62649
62853
|
************************************************************/
|
|
62650
62854
|
function show_delete_confirm(gobj, nodeData) {
|
|
62651
62855
|
let priv = gobj.priv;
|
|
62652
|
-
show_confirm_popover(gobj, priv._node_delete_el, delete_question([nodeData]), "delete", "#ff4d4f", () =>
|
|
62856
|
+
show_confirm_popover(gobj, priv._node_delete_el, delete_question([nodeData]), "delete", "#ff4d4f", () => (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CONFIRMED", {
|
|
62857
|
+
what: "delete_node",
|
|
62858
|
+
id: String(nodeData.id)
|
|
62859
|
+
}, gobj), "_delete_confirm_el");
|
|
62653
62860
|
}
|
|
62654
62861
|
function hide_delete_confirm(gobj) {
|
|
62655
62862
|
hide_overlay(gobj, "_delete_confirm_el");
|
|
@@ -62747,7 +62954,10 @@ function show_create_popover(gobj) {
|
|
|
62747
62954
|
idInput.focus();
|
|
62748
62955
|
return;
|
|
62749
62956
|
}
|
|
62750
|
-
|
|
62957
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SUBMIT_NEW_NODE", {
|
|
62958
|
+
topic_name: String(topicSelect.value),
|
|
62959
|
+
id: node_id
|
|
62960
|
+
}, gobj);
|
|
62751
62961
|
}
|
|
62752
62962
|
}]);
|
|
62753
62963
|
createBtn = popover.querySelector("button:last-child");
|
|
@@ -62807,7 +63017,10 @@ function execute_unlink_edge(gobj, edgeData) {
|
|
|
62807
63017
|
function show_unlink_confirm(gobj, edgeData) {
|
|
62808
63018
|
let priv = gobj.priv;
|
|
62809
63019
|
const d = edgeData.data;
|
|
62810
|
-
show_confirm_popover(gobj, priv._edge_delete_el, (0, i18next.t)("unlink") + " " + d.child_id + " → " + d.parent_id + "?\n" + (0, i18next.t)("neither record is deleted"), "unlink", "#ff4d4f", () =>
|
|
63020
|
+
show_confirm_popover(gobj, priv._edge_delete_el, (0, i18next.t)("unlink") + " " + d.child_id + " → " + d.parent_id + "?\n" + (0, i18next.t)("neither record is deleted"), "unlink", "#ff4d4f", () => (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CONFIRMED", {
|
|
63021
|
+
what: "unlink_edge",
|
|
63022
|
+
id: String(edgeData.id)
|
|
63023
|
+
}, gobj), "_unlink_confirm_el");
|
|
62811
63024
|
}
|
|
62812
63025
|
function hide_unlink_confirm(gobj) {
|
|
62813
63026
|
hide_overlay(gobj, "_unlink_confirm_el");
|
|
@@ -64690,7 +64903,7 @@ function ac_toggle_node_mode(gobj, event, kw, src) {
|
|
|
64690
64903
|
************************************************************/
|
|
64691
64904
|
function ac_node_dblclick(gobj, event, kw, src) {
|
|
64692
64905
|
let priv = gobj.priv;
|
|
64693
|
-
let node_id = kw && kw.
|
|
64906
|
+
let node_id = kw && kw.id ? kw.id : "";
|
|
64694
64907
|
let nd = null;
|
|
64695
64908
|
try {
|
|
64696
64909
|
nd = priv.graph.getNodeData(node_id);
|
|
@@ -64886,7 +65099,7 @@ function ac_brush_select(gobj, event, kw, src) {
|
|
|
64886
65099
|
function ac_node_click$2(gobj, event, kw, src) {
|
|
64887
65100
|
let priv = gobj.priv;
|
|
64888
65101
|
let graph = priv.graph;
|
|
64889
|
-
let node_id = kw.
|
|
65102
|
+
let node_id = kw && kw.id ? kw.id : "";
|
|
64890
65103
|
let more_nd = null;
|
|
64891
65104
|
try {
|
|
64892
65105
|
more_nd = graph.getNodeData(node_id);
|
|
@@ -64913,10 +65126,10 @@ function ac_node_click$2(gobj, event, kw, src) {
|
|
|
64913
65126
|
topic_name: nodedata.data.desc.topic_name,
|
|
64914
65127
|
record: nodedata.data.record
|
|
64915
65128
|
});
|
|
64916
|
-
if (priv.edit_mode && (kw.
|
|
65129
|
+
if (priv.edit_mode && (kw.shift || priv.selection_mode)) toggle_in_selection(gobj, node_id);
|
|
64917
65130
|
else if (priv.edit_mode) {
|
|
64918
65131
|
let containerRect = priv.$container.getBoundingClientRect();
|
|
64919
|
-
let canvasPoint = graph.getCanvasByViewport([kw.
|
|
65132
|
+
let canvasPoint = graph.getCanvasByViewport([kw.client_x - containerRect.left, kw.client_y - containerRect.top]);
|
|
64920
65133
|
let port_key = detect_port_click(gobj, node_id, canvasPoint[0], canvasPoint[1]);
|
|
64921
65134
|
if (priv._linking_mode) {
|
|
64922
65135
|
if (port_key && try_complete_link(gobj, node_id, port_key)) return 0;
|
|
@@ -64939,7 +65152,7 @@ function ac_node_click$2(gobj, event, kw, src) {
|
|
|
64939
65152
|
function ac_edge_click(gobj, event, kw, src) {
|
|
64940
65153
|
let priv = gobj.priv;
|
|
64941
65154
|
let graph = priv.graph;
|
|
64942
|
-
let edge_id = kw.
|
|
65155
|
+
let edge_id = kw && kw.id ? kw.id : "";
|
|
64943
65156
|
try {
|
|
64944
65157
|
let edgedata = graph.getEdgeData(edge_id);
|
|
64945
65158
|
if (edgedata && edgedata.data) {
|
|
@@ -64968,6 +65181,106 @@ function ac_node_context_menu(gobj, event, kw, src) {
|
|
|
64968
65181
|
return 0;
|
|
64969
65182
|
}
|
|
64970
65183
|
/************************************************************
|
|
65184
|
+
* {value} -- an item of the context menu was picked.
|
|
65185
|
+
************************************************************/
|
|
65186
|
+
function ac_context_menu_item(gobj, event, kw, src) {
|
|
65187
|
+
handle_context_menu_click(gobj, kw && kw.value ? kw.value : "");
|
|
65188
|
+
return 0;
|
|
65189
|
+
}
|
|
65190
|
+
/************************************************************
|
|
65191
|
+
* The delete icon floating beside the selected node.
|
|
65192
|
+
************************************************************/
|
|
65193
|
+
function ac_request_delete_node(gobj, event, kw, src) {
|
|
65194
|
+
request_delete_node(gobj);
|
|
65195
|
+
return 0;
|
|
65196
|
+
}
|
|
65197
|
+
/************************************************************
|
|
65198
|
+
* The unlink icon floating beside the selected edge.
|
|
65199
|
+
************************************************************/
|
|
65200
|
+
function ac_request_unlink_edge(gobj, event, kw, src) {
|
|
65201
|
+
request_unlink_edge(gobj);
|
|
65202
|
+
return 0;
|
|
65203
|
+
}
|
|
65204
|
+
/************************************************************
|
|
65205
|
+
* {topic_name, id} -- the create popover was filled in.
|
|
65206
|
+
************************************************************/
|
|
65207
|
+
function ac_submit_new_node(gobj, event, kw, src) {
|
|
65208
|
+
let topic_name = kw && kw.topic_name ? kw.topic_name : "";
|
|
65209
|
+
let node_id = kw && kw.id ? kw.id : "";
|
|
65210
|
+
if (!topic_name || !node_id) {
|
|
65211
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} without topic or id`);
|
|
65212
|
+
return -1;
|
|
65213
|
+
}
|
|
65214
|
+
execute_create_node(gobj, topic_name, node_id);
|
|
65215
|
+
return 0;
|
|
65216
|
+
}
|
|
65217
|
+
/************************************************************
|
|
65218
|
+
* {what, id|ids} -- the person said yes in a confirm popover.
|
|
65219
|
+
*
|
|
65220
|
+
* The kw carries IDS and not the graph elements they name: a kw
|
|
65221
|
+
* is plain json, and a node/edge datum of a live graph is not
|
|
65222
|
+
* something to park in a message. They are resolved here, where
|
|
65223
|
+
* the graph is -- and an id that no longer names anything is a
|
|
65224
|
+
* loud refusal instead of a silent nothing.
|
|
65225
|
+
************************************************************/
|
|
65226
|
+
function ac_confirmed$1(gobj, event, kw, src) {
|
|
65227
|
+
let graph = gobj.priv.graph;
|
|
65228
|
+
let what = kw && kw.what ? kw.what : "";
|
|
65229
|
+
if (!graph) {
|
|
65230
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} with no graph`);
|
|
65231
|
+
return -1;
|
|
65232
|
+
}
|
|
65233
|
+
if (what === "delete_selection") {
|
|
65234
|
+
let ids = kw && Array.isArray(kw.ids) ? kw.ids : [];
|
|
65235
|
+
let nodes = [];
|
|
65236
|
+
for (let id of ids) {
|
|
65237
|
+
let nd = null;
|
|
65238
|
+
try {
|
|
65239
|
+
nd = graph.getNodeData(id);
|
|
65240
|
+
} catch (e) {
|
|
65241
|
+
nd = null;
|
|
65242
|
+
}
|
|
65243
|
+
if (nd && nd.data && nd.data.desc) nodes.push(nd);
|
|
65244
|
+
}
|
|
65245
|
+
if (!nodes.length) {
|
|
65246
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} names no node any more`);
|
|
65247
|
+
return -1;
|
|
65248
|
+
}
|
|
65249
|
+
execute_delete_selection(gobj, nodes);
|
|
65250
|
+
return 0;
|
|
65251
|
+
}
|
|
65252
|
+
if (what === "delete_node") {
|
|
65253
|
+
let nd = null;
|
|
65254
|
+
try {
|
|
65255
|
+
nd = graph.getNodeData(kw.id);
|
|
65256
|
+
} catch (e) {
|
|
65257
|
+
nd = null;
|
|
65258
|
+
}
|
|
65259
|
+
if (!nd || !nd.data || !nd.data.desc) {
|
|
65260
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} names no node: ${kw.id}`);
|
|
65261
|
+
return -1;
|
|
65262
|
+
}
|
|
65263
|
+
execute_delete_node(gobj, nd);
|
|
65264
|
+
return 0;
|
|
65265
|
+
}
|
|
65266
|
+
if (what === "unlink_edge") {
|
|
65267
|
+
let ed = null;
|
|
65268
|
+
try {
|
|
65269
|
+
ed = graph.getEdgeData(kw.id);
|
|
65270
|
+
} catch (e) {
|
|
65271
|
+
ed = null;
|
|
65272
|
+
}
|
|
65273
|
+
if (!ed || !ed.data) {
|
|
65274
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} names no edge: ${kw.id}`);
|
|
65275
|
+
return -1;
|
|
65276
|
+
}
|
|
65277
|
+
execute_unlink_edge(gobj, ed);
|
|
65278
|
+
return 0;
|
|
65279
|
+
}
|
|
65280
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} of nothing this view asked about: ${what}`);
|
|
65281
|
+
return -1;
|
|
65282
|
+
}
|
|
65283
|
+
/************************************************************
|
|
64971
65284
|
* Canvas click
|
|
64972
65285
|
************************************************************/
|
|
64973
65286
|
function ac_canvas_click(gobj, event, kw, src) {
|
|
@@ -65131,6 +65444,31 @@ function create_gclass$4(gclass_name) {
|
|
|
65131
65444
|
ac_node_context_menu,
|
|
65132
65445
|
null
|
|
65133
65446
|
],
|
|
65447
|
+
[
|
|
65448
|
+
"EV_CONTEXT_MENU_ITEM",
|
|
65449
|
+
ac_context_menu_item,
|
|
65450
|
+
null
|
|
65451
|
+
],
|
|
65452
|
+
[
|
|
65453
|
+
"EV_REQUEST_DELETE_NODE",
|
|
65454
|
+
ac_request_delete_node,
|
|
65455
|
+
null
|
|
65456
|
+
],
|
|
65457
|
+
[
|
|
65458
|
+
"EV_REQUEST_UNLINK_EDGE",
|
|
65459
|
+
ac_request_unlink_edge,
|
|
65460
|
+
null
|
|
65461
|
+
],
|
|
65462
|
+
[
|
|
65463
|
+
"EV_SUBMIT_NEW_NODE",
|
|
65464
|
+
ac_submit_new_node,
|
|
65465
|
+
null
|
|
65466
|
+
],
|
|
65467
|
+
[
|
|
65468
|
+
"EV_CONFIRMED",
|
|
65469
|
+
ac_confirmed$1,
|
|
65470
|
+
null
|
|
65471
|
+
],
|
|
65134
65472
|
[
|
|
65135
65473
|
"EV_CANVAS_CLICK",
|
|
65136
65474
|
ac_canvas_click,
|
|
@@ -65347,6 +65685,11 @@ function create_gclass$4(gclass_name) {
|
|
|
65347
65685
|
["EV_NODE_CLICK", 0],
|
|
65348
65686
|
["EV_EDGE_CLICK", 0],
|
|
65349
65687
|
["EV_NODE_CONTEXT_MENU", 0],
|
|
65688
|
+
["EV_CONTEXT_MENU_ITEM", 0],
|
|
65689
|
+
["EV_REQUEST_DELETE_NODE", 0],
|
|
65690
|
+
["EV_REQUEST_UNLINK_EDGE", 0],
|
|
65691
|
+
["EV_SUBMIT_NEW_NODE", 0],
|
|
65692
|
+
["EV_CONFIRMED", 0],
|
|
65350
65693
|
["EV_CANVAS_CLICK", 0],
|
|
65351
65694
|
["EV_NODE_DRAG_END", 0],
|
|
65352
65695
|
["EV_BRUSH_SELECT", 0],
|
|
@@ -66411,7 +66754,8 @@ function request_print_tranger(gobj, path) {
|
|
|
66411
66754
|
expanded: 1,
|
|
66412
66755
|
lists_limit: 100,
|
|
66413
66756
|
dicts_limit: 100,
|
|
66414
|
-
path: path || ""
|
|
66757
|
+
path: path || "",
|
|
66758
|
+
__md_command__: { path: path || "" }
|
|
66415
66759
|
}, gobj);
|
|
66416
66760
|
if (ret) (0, _yuneta_gobj_js.log_error)(ret);
|
|
66417
66761
|
}
|