@yuneta/gobj-ui 7.31.7 → 7.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -7
- package/dist/gobj-ui.cjs.js +219 -53
- package/dist/gobj-ui.es.js +219 -53
- package/package.json +1 -1
- package/src/c_yui_json_graph.js +247 -76
- package/src/c_yui_treedb_topics.js +16 -2
- package/src/fmt_date_time.test.js +55 -0
- package/src/json_graph_lit_edge.wiring.test.js +90 -4
- package/src/treedb_topics_transport.wiring.test.js +55 -2
- package/src/yui_date_text.js +27 -2
package/src/c_yui_json_graph.js
CHANGED
|
@@ -239,6 +239,8 @@ let PRIVATE_DATA = {
|
|
|
239
239
|
lit_parent_path: "", // path of its PARENT card
|
|
240
240
|
lit_port: "", // the parent's port the edge leaves from: its row is washed
|
|
241
241
|
lit_found: false, // the last build drew it
|
|
242
|
+
lit_edge_id: "", // the id of the lit edge in the graph drawn now
|
|
243
|
+
cards: null, // Map path -> {id, kw, has_parent}: a card repainted alone
|
|
242
244
|
};
|
|
243
245
|
|
|
244
246
|
let __gclass__ = null;
|
|
@@ -774,6 +776,24 @@ function build_graph(gobj)
|
|
|
774
776
|
lineWidth: 1,
|
|
775
777
|
endArrow: true,
|
|
776
778
|
},
|
|
779
|
+
/* An edge lit by a click (light_edge): a state, so lighting
|
|
780
|
+
* it redraws the line and its two cards, not the graph. A
|
|
781
|
+
* callback, so a theme switch paints the other amber. */
|
|
782
|
+
state: {
|
|
783
|
+
lit: () => {
|
|
784
|
+
let dark = yui_is_dark();
|
|
785
|
+
let lit_color = dark? LIT_COLOR_DARK : LIT_COLOR_LIGHT;
|
|
786
|
+
return {
|
|
787
|
+
stroke: lit_color,
|
|
788
|
+
lineWidth: 3,
|
|
789
|
+
halo: true,
|
|
790
|
+
haloStroke: dark? LIT_HALO_DARK : LIT_HALO_LIGHT,
|
|
791
|
+
haloLineWidth: 8,
|
|
792
|
+
endArrowFill: lit_color,
|
|
793
|
+
endArrowStroke: lit_color,
|
|
794
|
+
};
|
|
795
|
+
},
|
|
796
|
+
},
|
|
777
797
|
},
|
|
778
798
|
|
|
779
799
|
layout: layout_cfg.g6_layout,
|
|
@@ -1173,29 +1193,25 @@ function get_group_label(path)
|
|
|
1173
1193
|
}
|
|
1174
1194
|
|
|
1175
1195
|
/************************************************************
|
|
1176
|
-
*
|
|
1196
|
+
* The rows of the card of `path`: one per key of `kw`, the
|
|
1197
|
+
* containers among them (`pending_complex`, each with the port
|
|
1198
|
+
* and the row it opens), and how many rows the find matched.
|
|
1177
1199
|
************************************************************/
|
|
1178
|
-
function
|
|
1200
|
+
function card_rows_of(gobj, path, kw)
|
|
1179
1201
|
{
|
|
1180
|
-
let
|
|
1202
|
+
let priv = gobj.priv;
|
|
1181
1203
|
let is_dict = is_object(kw);
|
|
1182
|
-
let is_list = is_array(kw);
|
|
1183
|
-
|
|
1184
|
-
if(!is_dict && !is_list) {
|
|
1185
|
-
return null;
|
|
1186
|
-
}
|
|
1187
1204
|
|
|
1188
1205
|
/*
|
|
1189
|
-
* Build HTML content for this group.
|
|
1190
1206
|
* The theme is read live as the card is drawn (like the gobj-tree's
|
|
1191
1207
|
* cards): ac_theme rebuilds on a switch, so this is always current.
|
|
1192
1208
|
*/
|
|
1193
|
-
let priv = gobj.priv;
|
|
1194
1209
|
let needle = priv.search || "";
|
|
1195
1210
|
let dark = yui_is_dark();
|
|
1196
1211
|
let lines = [];
|
|
1197
1212
|
let pending_complex = [];
|
|
1198
1213
|
let card_matched = false;
|
|
1214
|
+
let matches = 0;
|
|
1199
1215
|
|
|
1200
1216
|
let colors = json_card_style(
|
|
1201
1217
|
is_dict ? GROUP_COLORS.dict : GROUP_COLORS.list, dark
|
|
@@ -1208,7 +1224,7 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1208
1224
|
let matched = cell_matches(key, value, type, needle);
|
|
1209
1225
|
if(matched) {
|
|
1210
1226
|
card_matched = true;
|
|
1211
|
-
|
|
1227
|
+
matches++;
|
|
1212
1228
|
}
|
|
1213
1229
|
|
|
1214
1230
|
/*
|
|
@@ -1249,40 +1265,32 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1249
1265
|
lines.push(build_cell_html(key, value, type, dark, matched, fold));
|
|
1250
1266
|
}
|
|
1251
1267
|
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
nodes,
|
|
1279
|
-
edges,
|
|
1280
|
-
parent_id,
|
|
1281
|
-
parent_port
|
|
1282
|
-
);
|
|
1283
|
-
}
|
|
1284
|
-
return parent_id;
|
|
1285
|
-
}
|
|
1268
|
+
return {
|
|
1269
|
+
is_dict: is_dict,
|
|
1270
|
+
dark: dark,
|
|
1271
|
+
colors: colors,
|
|
1272
|
+
lines: lines,
|
|
1273
|
+
pending_complex: pending_complex,
|
|
1274
|
+
card_matched: card_matched,
|
|
1275
|
+
matches: matches,
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/************************************************************
|
|
1280
|
+
* The html of the card of `path`, from its rows (card_rows_of),
|
|
1281
|
+
* lit or not as priv.lit_* says now. The build draws every card
|
|
1282
|
+
* with it, and repaint_cards() one card alone: the same moment
|
|
1283
|
+
* reads the same either way.
|
|
1284
|
+
************************************************************/
|
|
1285
|
+
function card_html_of(gobj, path, rows, has_parent)
|
|
1286
|
+
{
|
|
1287
|
+
let priv = gobj.priv;
|
|
1288
|
+
let is_dict = rows.is_dict;
|
|
1289
|
+
let dark = rows.dark;
|
|
1290
|
+
let colors = rows.colors;
|
|
1291
|
+
let lines = rows.lines;
|
|
1292
|
+
let pending_complex = rows.pending_complex;
|
|
1293
|
+
let card_matched = rows.card_matched;
|
|
1286
1294
|
|
|
1287
1295
|
let label = get_group_label(path) || (is_dict ? "{}" : "[]");
|
|
1288
1296
|
|
|
@@ -1305,7 +1313,7 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1305
1313
|
* the line says which key it is.
|
|
1306
1314
|
*/
|
|
1307
1315
|
let lit_color = dark? LIT_COLOR_DARK : LIT_COLOR_LIGHT;
|
|
1308
|
-
let lit_child =
|
|
1316
|
+
let lit_child = has_parent && !empty_string(priv.lit_path) && path === priv.lit_path;
|
|
1309
1317
|
let lit_row = -1;
|
|
1310
1318
|
let lit_parent = !empty_string(priv.lit_path) && path === priv.lit_parent_path;
|
|
1311
1319
|
if(lit_parent) {
|
|
@@ -1317,9 +1325,6 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1317
1325
|
}
|
|
1318
1326
|
}
|
|
1319
1327
|
let lit_card = lit_child || lit_parent;
|
|
1320
|
-
if(lit_child) {
|
|
1321
|
-
priv.lit_found = true;
|
|
1322
|
-
}
|
|
1323
1328
|
if(lit_card) {
|
|
1324
1329
|
border_color = lit_color;
|
|
1325
1330
|
border_width = 3;
|
|
@@ -1373,6 +1378,79 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1373
1378
|
${content_html}
|
|
1374
1379
|
</div>`;
|
|
1375
1380
|
|
|
1381
|
+
return {
|
|
1382
|
+
node_html: node_html,
|
|
1383
|
+
min_width: min_width,
|
|
1384
|
+
card_height: card_height,
|
|
1385
|
+
folded: folded,
|
|
1386
|
+
lit_child: lit_child,
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/************************************************************
|
|
1391
|
+
* Recursively build nodes and edges from JSON
|
|
1392
|
+
************************************************************/
|
|
1393
|
+
function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
1394
|
+
{
|
|
1395
|
+
let group_id = gen_node_id(gobj);
|
|
1396
|
+
let is_dict = is_object(kw);
|
|
1397
|
+
let is_list = is_array(kw);
|
|
1398
|
+
|
|
1399
|
+
if(!is_dict && !is_list) {
|
|
1400
|
+
return null;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
let priv = gobj.priv;
|
|
1404
|
+
let rows = card_rows_of(gobj, path, kw);
|
|
1405
|
+
let dark = rows.dark;
|
|
1406
|
+
let colors = rows.colors;
|
|
1407
|
+
let pending_complex = rows.pending_complex;
|
|
1408
|
+
priv.match_count += rows.matches;
|
|
1409
|
+
|
|
1410
|
+
/*
|
|
1411
|
+
* A pure collection is not drawn: its row above names it and its
|
|
1412
|
+
* children hang from THIS card's parent. The root always gets a
|
|
1413
|
+
* card, or a document that is a plain list of records would have
|
|
1414
|
+
* nothing to hang anything from.
|
|
1415
|
+
*/
|
|
1416
|
+
if(parent_id && is_pure_collection(kw)) {
|
|
1417
|
+
if(priv.collapsed.has(path)) {
|
|
1418
|
+
/* Folded, and it draws nothing of its own -- so the space
|
|
1419
|
+
* its children were taking is left HERE, in their place
|
|
1420
|
+
* among the parent's other children. */
|
|
1421
|
+
push_fold_phantom(gobj, path, parent_id, parent_port, nodes, edges);
|
|
1422
|
+
return parent_id;
|
|
1423
|
+
}
|
|
1424
|
+
for(let pending of pending_complex) {
|
|
1425
|
+
/*
|
|
1426
|
+
* `parent_port` and not one of ours: this collection has no
|
|
1427
|
+
* card, so the port its row opened in the PARENT is the one
|
|
1428
|
+
* every one of these lines leaves from -- fourteen columns
|
|
1429
|
+
* out of the single `cols` port, which is what the document
|
|
1430
|
+
* says and what the reader traces back.
|
|
1431
|
+
*/
|
|
1432
|
+
build_json_nodes(
|
|
1433
|
+
gobj,
|
|
1434
|
+
add_segment(path, pending.key),
|
|
1435
|
+
pending.value,
|
|
1436
|
+
nodes,
|
|
1437
|
+
edges,
|
|
1438
|
+
parent_id,
|
|
1439
|
+
parent_port
|
|
1440
|
+
);
|
|
1441
|
+
}
|
|
1442
|
+
return parent_id;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
let card = card_html_of(gobj, path, rows, !!parent_id);
|
|
1446
|
+
let folded = card.folded;
|
|
1447
|
+
let lit_child = card.lit_child;
|
|
1448
|
+
let min_width = card.min_width;
|
|
1449
|
+
let card_height = card.card_height;
|
|
1450
|
+
if(lit_child) {
|
|
1451
|
+
priv.lit_found = true;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1376
1454
|
/*
|
|
1377
1455
|
* ONE PORT PER CONTAINER KEY, ON THE LINE OF ITS OWN ROW.
|
|
1378
1456
|
*
|
|
@@ -1441,7 +1519,7 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1441
1519
|
|
|
1442
1520
|
},
|
|
1443
1521
|
style: {
|
|
1444
|
-
innerHTML: node_html,
|
|
1522
|
+
innerHTML: card.node_html,
|
|
1445
1523
|
size: [min_width, card_height],
|
|
1446
1524
|
dx: -(min_width / 2),
|
|
1447
1525
|
dy: -(card_height / 2),
|
|
@@ -1452,12 +1530,15 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1452
1530
|
},
|
|
1453
1531
|
};
|
|
1454
1532
|
nodes.push(node);
|
|
1533
|
+
priv.cards.set(path, {id: group_id, kw: kw, has_parent: !!parent_id});
|
|
1455
1534
|
|
|
1456
1535
|
/*
|
|
1457
1536
|
* Edge from parent to this group, out of the port its key opened.
|
|
1537
|
+
* Its id is its child card's: a card has one edge coming in.
|
|
1458
1538
|
*/
|
|
1459
1539
|
if(parent_id) {
|
|
1460
1540
|
let edge = {
|
|
1541
|
+
id: "je-" + group_id,
|
|
1461
1542
|
source: parent_id,
|
|
1462
1543
|
target: group_id,
|
|
1463
1544
|
style: {
|
|
@@ -1489,15 +1570,8 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1489
1570
|
edge.style.sourcePort = parent_port;
|
|
1490
1571
|
}
|
|
1491
1572
|
if(lit_child) {
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
lineWidth: 3,
|
|
1495
|
-
halo: true,
|
|
1496
|
-
haloStroke: dark? LIT_HALO_DARK : LIT_HALO_LIGHT,
|
|
1497
|
-
haloLineWidth: 8,
|
|
1498
|
-
endArrowFill: lit_color,
|
|
1499
|
-
endArrowStroke: lit_color,
|
|
1500
|
-
});
|
|
1573
|
+
edge.states = ["lit"];
|
|
1574
|
+
priv.lit_edge_id = edge.id;
|
|
1501
1575
|
}
|
|
1502
1576
|
edges.push(edge);
|
|
1503
1577
|
}
|
|
@@ -1621,6 +1695,8 @@ function load_json(gobj)
|
|
|
1621
1695
|
priv.node_counter = 0;
|
|
1622
1696
|
priv.match_count = 0;
|
|
1623
1697
|
priv.lit_found = false;
|
|
1698
|
+
priv.lit_edge_id = "";
|
|
1699
|
+
priv.cards = new Map();
|
|
1624
1700
|
|
|
1625
1701
|
let nodes = [];
|
|
1626
1702
|
let edges = [];
|
|
@@ -1895,6 +1971,101 @@ function refresh_json(gobj, opts)
|
|
|
1895
1971
|
}
|
|
1896
1972
|
}
|
|
1897
1973
|
|
|
1974
|
+
/************************************************************
|
|
1975
|
+
* Repaint the cards of these paths alone, lit or not as
|
|
1976
|
+
* priv.lit_* says now, and draw once. A click on an edge
|
|
1977
|
+
* changes two cards: rebuilding the graph for them redrew
|
|
1978
|
+
* every card, the layout and the camera's frame.
|
|
1979
|
+
************************************************************/
|
|
1980
|
+
function repaint_cards(gobj, paths)
|
|
1981
|
+
{
|
|
1982
|
+
let priv = gobj.priv;
|
|
1983
|
+
let graph = priv.graph;
|
|
1984
|
+
|
|
1985
|
+
if(!graph || !priv.cards) {
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
let updates = [];
|
|
1989
|
+
for(let path of paths) {
|
|
1990
|
+
let c = priv.cards.get(path);
|
|
1991
|
+
if(!c) {
|
|
1992
|
+
continue; /* a path with no card of its own: nothing to repaint */
|
|
1993
|
+
}
|
|
1994
|
+
let rows = card_rows_of(gobj, path, c.kw);
|
|
1995
|
+
let card = card_html_of(gobj, path, rows, c.has_parent);
|
|
1996
|
+
updates.push({id: c.id, style: {innerHTML: card.node_html}});
|
|
1997
|
+
}
|
|
1998
|
+
try {
|
|
1999
|
+
if(updates.length) {
|
|
2000
|
+
graph.updateNodeData(updates);
|
|
2001
|
+
}
|
|
2002
|
+
Promise.resolve(graph.draw()).then(() => {
|
|
2003
|
+
/* A repainted card is new DOM: put the anchor's mark back. */
|
|
2004
|
+
paint_anchor_mark(gobj);
|
|
2005
|
+
}).catch((e) => {
|
|
2006
|
+
log_error(`${gobj_short_name(gobj)}: redraw failed: ${e}`);
|
|
2007
|
+
});
|
|
2008
|
+
} catch(e) {
|
|
2009
|
+
log_error(`${gobj_short_name(gobj)}: cannot repaint the cards: ${e}`);
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
/************************************************************
|
|
2014
|
+
* Put the lit edge out: its state off, and the paths of its
|
|
2015
|
+
* two cards returned, to be repainted plain. Draws nothing:
|
|
2016
|
+
* the caller repaints once, and two draws race. [] when
|
|
2017
|
+
* nothing is lit.
|
|
2018
|
+
************************************************************/
|
|
2019
|
+
function put_out_edge(gobj)
|
|
2020
|
+
{
|
|
2021
|
+
let priv = gobj.priv;
|
|
2022
|
+
let graph = priv.graph;
|
|
2023
|
+
|
|
2024
|
+
if(empty_string(priv.lit_path)) {
|
|
2025
|
+
return [];
|
|
2026
|
+
}
|
|
2027
|
+
let paths = [priv.lit_path, priv.lit_parent_path];
|
|
2028
|
+
let edge_id = priv.lit_edge_id;
|
|
2029
|
+
|
|
2030
|
+
priv.lit_path = "";
|
|
2031
|
+
priv.lit_parent_path = "";
|
|
2032
|
+
priv.lit_port = "";
|
|
2033
|
+
priv.lit_edge_id = "";
|
|
2034
|
+
|
|
2035
|
+
if(graph && !empty_string(edge_id)) {
|
|
2036
|
+
try {
|
|
2037
|
+
graph.updateData({edges: [{id: edge_id, states: []}]});
|
|
2038
|
+
} catch(e) {
|
|
2039
|
+
log_error(`${gobj_short_name(gobj)}: edge state not cleared: ${e}`);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
return paths;
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
/************************************************************
|
|
2046
|
+
* Light an edge: its `lit` state on, and the paths of its two
|
|
2047
|
+
* cards returned, to be repainted with the ring (the parent's
|
|
2048
|
+
* row of the key it leaves from washed). The cards are html,
|
|
2049
|
+
* where G6 paints no state, so their mark is in their html.
|
|
2050
|
+
* Draws nothing, as put_out_edge().
|
|
2051
|
+
************************************************************/
|
|
2052
|
+
function light_edge(gobj, edge_id, child_path, parent_path, port)
|
|
2053
|
+
{
|
|
2054
|
+
let priv = gobj.priv;
|
|
2055
|
+
|
|
2056
|
+
priv.lit_path = child_path;
|
|
2057
|
+
priv.lit_parent_path = parent_path;
|
|
2058
|
+
priv.lit_port = port;
|
|
2059
|
+
priv.lit_edge_id = edge_id;
|
|
2060
|
+
|
|
2061
|
+
try {
|
|
2062
|
+
priv.graph.updateData({edges: [{id: edge_id, states: ["lit"]}]});
|
|
2063
|
+
} catch(e) {
|
|
2064
|
+
log_error(`${gobj_short_name(gobj)}: edge state not set: ${e}`);
|
|
2065
|
+
}
|
|
2066
|
+
return [child_path, parent_path];
|
|
2067
|
+
}
|
|
2068
|
+
|
|
1898
2069
|
/************************************************************
|
|
1899
2070
|
* Custom tree layout for JSON visualization
|
|
1900
2071
|
************************************************************/
|
|
@@ -2093,6 +2264,7 @@ function ac_load_data(gobj, event, kw, src)
|
|
|
2093
2264
|
gobj.priv.lit_path = "";
|
|
2094
2265
|
gobj.priv.lit_parent_path = "";
|
|
2095
2266
|
gobj.priv.lit_port = "";
|
|
2267
|
+
gobj.priv.lit_edge_id = "";
|
|
2096
2268
|
}
|
|
2097
2269
|
|
|
2098
2270
|
refresh_json(gobj);
|
|
@@ -2276,10 +2448,10 @@ function ac_collapse_all(gobj, event, kw, src)
|
|
|
2276
2448
|
* EV_EDGE_CLICK { id }
|
|
2277
2449
|
*
|
|
2278
2450
|
* Light the edge and its two ends, or put it out when it is
|
|
2279
|
-
* the lit one.
|
|
2280
|
-
*
|
|
2281
|
-
*
|
|
2282
|
-
*
|
|
2451
|
+
* the lit one. Only the edge and its two cards are redrawn
|
|
2452
|
+
* (light_edge). The edge is kept by the PATH of its child
|
|
2453
|
+
* card, which a rebuild (a fold, a find) keeps and the ids do
|
|
2454
|
+
* not: the rebuild lights it again.
|
|
2283
2455
|
************************************************************/
|
|
2284
2456
|
function ac_edge_click(gobj, event, kw, src)
|
|
2285
2457
|
{
|
|
@@ -2305,16 +2477,18 @@ function ac_edge_click(gobj, event, kw, src)
|
|
|
2305
2477
|
return 0; /* the invisible edge a fold leaves */
|
|
2306
2478
|
}
|
|
2307
2479
|
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2480
|
+
let same = (priv.lit_path === tdata.path);
|
|
2481
|
+
let paths = put_out_edge(gobj);
|
|
2482
|
+
if(!same) {
|
|
2483
|
+
paths = paths.concat(light_edge(
|
|
2484
|
+
gobj,
|
|
2485
|
+
edge.id,
|
|
2486
|
+
tdata.path,
|
|
2487
|
+
(source && source.data && source.data.path) || "",
|
|
2488
|
+
(edge.style && edge.style.sourcePort) || ""
|
|
2489
|
+
));
|
|
2316
2490
|
}
|
|
2317
|
-
|
|
2491
|
+
repaint_cards(gobj, new Set(paths));
|
|
2318
2492
|
return 0;
|
|
2319
2493
|
}
|
|
2320
2494
|
|
|
@@ -2328,10 +2502,7 @@ function ac_canvas_click(gobj, event, kw, src)
|
|
|
2328
2502
|
if(empty_string(priv.lit_path)) {
|
|
2329
2503
|
return 0;
|
|
2330
2504
|
}
|
|
2331
|
-
|
|
2332
|
-
priv.lit_parent_path = "";
|
|
2333
|
-
priv.lit_port = "";
|
|
2334
|
-
refresh_json(gobj, {preserve_view: true});
|
|
2505
|
+
repaint_cards(gobj, put_out_edge(gobj));
|
|
2335
2506
|
return 0;
|
|
2336
2507
|
}
|
|
2337
2508
|
|
|
@@ -1269,6 +1269,19 @@ function topic_is_shown(topic_name)
|
|
|
1269
1269
|
return topic_name.substring(0, 2) !== "__" || topic_name === ICONS_TOPIC;
|
|
1270
1270
|
}
|
|
1271
1271
|
|
|
1272
|
+
/************************************************************
|
|
1273
|
+
* The topics in ALPHABETICAL order, for the cards, the tabs
|
|
1274
|
+
* and the site map: the backend's order is not the same from
|
|
1275
|
+
* one load to the next, and a reader finds a topic by its
|
|
1276
|
+
* place. The system topics (__*__) sort first.
|
|
1277
|
+
************************************************************/
|
|
1278
|
+
function sorted_topic_names(descs)
|
|
1279
|
+
{
|
|
1280
|
+
return Object.keys(descs).sort((a, b) => {
|
|
1281
|
+
return a.localeCompare(b);
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1272
1285
|
/************************************************************
|
|
1273
1286
|
* The nodes of __icons__ are the user icons of the app: each
|
|
1274
1287
|
* load and each write of them goes to the icon registry
|
|
@@ -1322,7 +1335,8 @@ function process_treedb_descs(gobj)
|
|
|
1322
1335
|
let system = gobj_read_bool_attr(gobj, "system");
|
|
1323
1336
|
let treedb_name = gobj_read_str_attr(gobj, "treedb_name");
|
|
1324
1337
|
let readonly = gobj_read_bool_attr(gobj, "readonly");
|
|
1325
|
-
for(const
|
|
1338
|
+
for(const key of sorted_topic_names(descs)) {
|
|
1339
|
+
let desc = descs[key];
|
|
1326
1340
|
if(!system && !topic_is_shown(key)) {
|
|
1327
1341
|
continue;
|
|
1328
1342
|
}
|
|
@@ -1454,7 +1468,7 @@ function register_sub_routes(gobj)
|
|
|
1454
1468
|
icon: "yi-compass-drafting", gclass: "C_YUI_TREEDB_SCHEMA"});
|
|
1455
1469
|
}
|
|
1456
1470
|
if(is_object(descs)) {
|
|
1457
|
-
for(let topic of
|
|
1471
|
+
for(let topic of sorted_topic_names(descs)) {
|
|
1458
1472
|
if(!system && !topic_is_shown(topic)) {
|
|
1459
1473
|
continue;
|
|
1460
1474
|
}
|
|
@@ -165,3 +165,58 @@ describe("the moments uPlot writes (yui_uplot_time.js)", () => {
|
|
|
165
165
|
expect(fmt("{h}:{mm}{aa}")(AFTERNOON)).toBe("15:05");
|
|
166
166
|
});
|
|
167
167
|
});
|
|
168
|
+
|
|
169
|
+
describe("one formatter per locale and time zone", () => {
|
|
170
|
+
const with_counted_intl = (fn) => {
|
|
171
|
+
const Real = Intl.DateTimeFormat;
|
|
172
|
+
let built = 0;
|
|
173
|
+
Intl.DateTimeFormat = function(...args) {
|
|
174
|
+
built++;
|
|
175
|
+
return new Real(...args);
|
|
176
|
+
};
|
|
177
|
+
try {
|
|
178
|
+
fn();
|
|
179
|
+
} finally {
|
|
180
|
+
Intl.DateTimeFormat = Real;
|
|
181
|
+
}
|
|
182
|
+
return built;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
test("a filter over many rows builds the formatter once", () => {
|
|
186
|
+
const built = with_counted_intl(() => {
|
|
187
|
+
for(let i = 0; i < 1000; i++) {
|
|
188
|
+
fmt_date_time(new Date(D.getTime() + i * 1000), "fr");
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
expect(built).toBe(1);
|
|
192
|
+
expect(fmt_date_time(D, "fr")).toBe(new Intl.DateTimeFormat("fr", {
|
|
193
|
+
day: "numeric", month: "short", year: "numeric",
|
|
194
|
+
hour: "2-digit", minute: "2-digit", second: "2-digit", hourCycle: "h23"
|
|
195
|
+
}).format(D));
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("a change of language writes in the new language at once", () => {
|
|
199
|
+
expect(fmt_date_time(D, "es")).toBe("14 oct 2026, 15:05:09");
|
|
200
|
+
expect(fmt_date_time(D, "en")).toBe("Oct 14, 2026, 15:05:09");
|
|
201
|
+
expect(fmt_date_time(D, "es")).toBe("14 oct 2026, 15:05:09");
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("a change of time zone writes in the new zone", () => {
|
|
205
|
+
const tz = process.env.TZ;
|
|
206
|
+
const instant = new Date(Date.UTC(2026, 0, 15, 12, 0, 0));
|
|
207
|
+
try {
|
|
208
|
+
process.env.TZ = "UTC";
|
|
209
|
+
expect(fmt_date_time(instant, "es")).toBe("15 ene 2026, 12:00:00");
|
|
210
|
+
process.env.TZ = "Asia/Tokyo";
|
|
211
|
+
expect(fmt_date_time(instant, "es")).toBe("15 ene 2026, 21:00:00");
|
|
212
|
+
process.env.TZ = "UTC";
|
|
213
|
+
expect(fmt_date_time(instant, "es")).toBe("15 ene 2026, 12:00:00");
|
|
214
|
+
} finally {
|
|
215
|
+
if(tz === undefined) {
|
|
216
|
+
delete process.env.TZ;
|
|
217
|
+
} else {
|
|
218
|
+
process.env.TZ = tz;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|