@yuneta/gobj-ui 7.26.40 → 7.26.42
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 +325 -65
- package/dist/gobj-ui.cjs.js +418 -176
- package/dist/gobj-ui.es.js +418 -176
- package/package.json +1 -1
- package/scripts/validate-locales.mjs +644 -142
- package/src/c_g6_nodes_tree.js +3 -2
- package/src/c_yui_form.js +80 -68
- package/src/c_yui_fsm_graph.js +3 -2
- package/src/c_yui_gobj_tree_js.js +3 -2
- package/src/c_yui_json_graph.js +3 -2
- package/src/c_yui_nav.js +43 -28
- package/src/c_yui_schema_editor.css +16 -0
- package/src/c_yui_schema_editor.js +61 -17
- package/src/c_yui_shell.js +199 -59
- package/src/c_yui_treedb_schema.js +3 -2
- package/src/c_yui_window_manager.js +6 -6
- package/src/form_table_edits_ask.wiring.test.js +398 -0
- package/src/form_table_rearm.wiring.test.js +9 -7
- package/src/g6_canvas_tab_order.css +29 -0
- package/src/g6_canvas_tab_order.js +41 -9
- package/src/g6_canvas_tab_order.wiring.test.js +107 -1
- package/src/i18n_key_functions.js +41 -25
- package/src/i18n_key_functions.test.js +178 -2
- package/src/modal_guard_back.wiring.test.js +135 -0
- package/src/named_controls.wiring.test.js +270 -6
- package/src/nav_cards_helpers.js +9 -4
- package/src/nav_item_badge.wiring.test.js +163 -15
- package/src/route_map_model.js +59 -10
- package/src/route_map_model.test.js +90 -0
- package/src/schema_editor_openers.wiring.test.js +283 -0
- package/src/shell_modals.js +24 -4
- package/src/shell_route_map.js +15 -3
- package/src/shell_section_index.js +3 -1
- package/src/window_layer.wiring.test.js +114 -0
- package/src/yui_gclass_view.js +16 -1
- package/src/yui_tabulator_i18n.js +21 -1
- package/src/yui_tabulator_i18n.test.js +39 -0
- package/src/yui_text.js +10 -0
- package/src/yui_text.test.js +13 -0
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -1243,8 +1243,9 @@ function build_graph(gobj)
|
|
|
1243
1243
|
graph.setTheme(priv.theme);
|
|
1244
1244
|
|
|
1245
1245
|
/* Tab goes from the graph to its own buttons: the main canvas in
|
|
1246
|
-
* the Tab order, the other layers out
|
|
1247
|
-
|
|
1246
|
+
* the Tab order, named for what it draws, the other layers out
|
|
1247
|
+
* (g6_canvas_tab_order.js). */
|
|
1248
|
+
keep_canvas_tab_order(gobj, graph, "treedb graph");
|
|
1248
1249
|
|
|
1249
1250
|
/* A card is an HTML node, and G6's HTML nodes do not pass the wheel
|
|
1250
1251
|
* on: over a card the graph neither scrolled nor zoomed. Only a wheel
|
package/src/c_yui_form.js
CHANGED
|
@@ -55,7 +55,11 @@ import {
|
|
|
55
55
|
|
|
56
56
|
import {t} from "i18next";
|
|
57
57
|
|
|
58
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
yui_tabulator_name_row_selects,
|
|
60
|
+
yui_tabulator_name_editor,
|
|
61
|
+
yui_tabulator_relocalize
|
|
62
|
+
} from "./yui_tabulator_i18n.js";
|
|
59
63
|
import "tom-select/dist/css/tom-select.css"; // Import Tom-Select CSS
|
|
60
64
|
import TomSelect from "tom-select"; // Import Tom-Select JS
|
|
61
65
|
|
|
@@ -172,9 +176,10 @@ SDATA_END()
|
|
|
172
176
|
];
|
|
173
177
|
|
|
174
178
|
let PRIVATE_DATA = {
|
|
175
|
-
/*
|
|
176
|
-
*
|
|
177
|
-
|
|
179
|
+
/* > 0 while the FORM adds rows (a record loaded, a nested table
|
|
180
|
+
* filled): what a table says then is no change of the reader's
|
|
181
|
+
* (see create_tabulator's dataChanged). */
|
|
182
|
+
loading_rows: 0,
|
|
178
183
|
/* table_id -> WeakRef of its element: EV_ADD_TABLE_ROW names a
|
|
179
184
|
* table by id (a kw is plain json), see table_identity(). */
|
|
180
185
|
tables: null,
|
|
@@ -281,17 +286,8 @@ function mt_stop(gobj)
|
|
|
281
286
|
|
|
282
287
|
|
|
283
288
|
/************************************************************
|
|
284
|
-
*
|
|
285
|
-
|
|
286
|
-
function isEventSet(table, event)
|
|
287
|
-
{
|
|
288
|
-
// Access the event listeners directly from the Tabulator instance
|
|
289
|
-
let eventListeners = table.externalEvents.events;
|
|
290
|
-
return eventListeners && eventListeners[event] && eventListeners[event].length > 0;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/************************************************************
|
|
294
|
-
*
|
|
289
|
+
* `changes` and the save/undo buttons. What the tables say is
|
|
290
|
+
* not switched here: they always say it (create_tabulator).
|
|
295
291
|
************************************************************/
|
|
296
292
|
function set_changed_stated(gobj, changed)
|
|
297
293
|
{
|
|
@@ -333,18 +329,6 @@ function set_changed_stated(gobj, changed)
|
|
|
333
329
|
enable($button_save, true, "MediumSeaGreen");
|
|
334
330
|
enable($button_undo, true, "Magenta");
|
|
335
331
|
|
|
336
|
-
$form.querySelectorAll('.yui-tabulator-table').forEach($table => {
|
|
337
|
-
if($table.tabulator && isEventSet($table.tabulator, "dataChanged")) {
|
|
338
|
-
$table.tabulator.off("dataChanged");
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
$table.querySelectorAll('.yui-tabulator-table-nested').forEach($table_nested => {
|
|
342
|
-
if($table_nested.tabulator && isEventSet($table_nested.tabulator, "dataChanged")) {
|
|
343
|
-
$table_nested.tabulator.off("dataChanged");
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
|
|
348
332
|
} else {
|
|
349
333
|
/*
|
|
350
334
|
* Data not changed, disable buttons to save/undo
|
|
@@ -354,41 +338,6 @@ function set_changed_stated(gobj, changed)
|
|
|
354
338
|
|
|
355
339
|
enable($button_save, false, OFF_COLOR);
|
|
356
340
|
enable($button_undo, false, OFF_COLOR);
|
|
357
|
-
|
|
358
|
-
/*
|
|
359
|
-
* TODO improve. The tables are re-wired a moment later, once the
|
|
360
|
-
* data just loaded has settled. The timer is kept so that
|
|
361
|
-
* destroy_ui() cancels it: a form closed right after a save (what
|
|
362
|
-
* a dialog does) destroyed its widgets first, and the timer then
|
|
363
|
-
* called .on() on a null tabulator -- an uncaught TypeError.
|
|
364
|
-
*/
|
|
365
|
-
if(gobj.priv.rearm_timer) {
|
|
366
|
-
clearTimeout(gobj.priv.rearm_timer);
|
|
367
|
-
}
|
|
368
|
-
gobj.priv.rearm_timer = setTimeout(function() {
|
|
369
|
-
gobj.priv.rearm_timer = null;
|
|
370
|
-
if(gobj_is_destroying(gobj)) {
|
|
371
|
-
return; // destroy_ui() cancels it; this is the belt
|
|
372
|
-
}
|
|
373
|
-
const rearm = (tabulator) => {
|
|
374
|
-
if(!tabulator) {
|
|
375
|
-
return; // destroyed with its form
|
|
376
|
-
}
|
|
377
|
-
if(isEventSet(tabulator, "dataChanged")) {
|
|
378
|
-
tabulator.off("dataChanged");
|
|
379
|
-
}
|
|
380
|
-
tabulator.on("dataChanged", function(data) {
|
|
381
|
-
//data - the updated table data
|
|
382
|
-
gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
383
|
-
});
|
|
384
|
-
};
|
|
385
|
-
$form.querySelectorAll('.yui-tabulator-table').forEach($table => {
|
|
386
|
-
rearm($table.tabulator);
|
|
387
|
-
$table.querySelectorAll('.yui-tabulator-table-nested').forEach($table_nested => {
|
|
388
|
-
rearm($table_nested.tabulator);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
}, 200);
|
|
392
341
|
}
|
|
393
342
|
}
|
|
394
343
|
|
|
@@ -562,10 +511,6 @@ function build_ui(gobj)
|
|
|
562
511
|
************************************************************/
|
|
563
512
|
function destroy_ui(gobj)
|
|
564
513
|
{
|
|
565
|
-
if(gobj.priv && gobj.priv.rearm_timer) {
|
|
566
|
-
clearTimeout(gobj.priv.rearm_timer);
|
|
567
|
-
gobj.priv.rearm_timer = null;
|
|
568
|
-
}
|
|
569
514
|
let $container = gobj_read_attr(gobj, "$container");
|
|
570
515
|
if($container) {
|
|
571
516
|
destroy_widgets(gobj, $container);
|
|
@@ -2332,6 +2277,22 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
2332
2277
|
$extend,
|
|
2333
2278
|
tabulator_settings
|
|
2334
2279
|
);
|
|
2280
|
+
/* What the READER does to a table -- edits a cell, adds or deletes a
|
|
2281
|
+
* row -- reaches the form only through `dataChanged`. Wired here, on
|
|
2282
|
+
* every table, nested ones included (a row's formatter builds them
|
|
2283
|
+
* whenever the row is drawn), and never switched off: until 7.26.40
|
|
2284
|
+
* it was unwired whenever the form was CHANGED and re-wired only by a
|
|
2285
|
+
* save, an undo or a load of what is stored, so a form that opened
|
|
2286
|
+
* changed (a field its record lacks, filled with its default) never
|
|
2287
|
+
* heard its tables -- an edit there was not `edited`, and closing lost
|
|
2288
|
+
* it without a question. The rows the form adds itself say nothing
|
|
2289
|
+
* (`loading_rows`, ac_add_table_row). */
|
|
2290
|
+
tabulator.on("dataChanged", function() {
|
|
2291
|
+
if(gobj.priv.loading_rows > 0) {
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
2295
|
+
});
|
|
2335
2296
|
/* Tabulator hard-codes `aria-label="Select Row"` on the box its
|
|
2336
2297
|
* rowSelection formatter draws, and it draws a fresh one on EVERY
|
|
2337
2298
|
* render -- so this hangs off `renderComplete`, not `tableBuilt`:
|
|
@@ -2369,6 +2330,28 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
2369
2330
|
return tabulator;
|
|
2370
2331
|
}
|
|
2371
2332
|
|
|
2333
|
+
/******************************************************************
|
|
2334
|
+
* The title of a table's column: the schema's header, or the
|
|
2335
|
+
* field's name, translated.
|
|
2336
|
+
******************************************************************/
|
|
2337
|
+
function column_title(field_desc)
|
|
2338
|
+
{
|
|
2339
|
+
return t(/* i18n: data */ field_desc.header || field_desc.name); // the host's schema
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
/******************************************************************
|
|
2343
|
+
* {field: title} of a table's template, in the current language.
|
|
2344
|
+
******************************************************************/
|
|
2345
|
+
function table_column_titles(template)
|
|
2346
|
+
{
|
|
2347
|
+
let titles = {};
|
|
2348
|
+
Object.entries(template || {}).forEach(([key, value]) => {
|
|
2349
|
+
const field_desc = template_get_field_desc(key, value);
|
|
2350
|
+
titles[field_desc.name] = column_title(field_desc);
|
|
2351
|
+
});
|
|
2352
|
+
return titles;
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2372
2355
|
/******************************************************************
|
|
2373
2356
|
* Convert a template's items in tabulator columns
|
|
2374
2357
|
******************************************************************/
|
|
@@ -2388,7 +2371,7 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2388
2371
|
let validator = [];
|
|
2389
2372
|
let column = {
|
|
2390
2373
|
field: field_desc.name,
|
|
2391
|
-
title:
|
|
2374
|
+
title: column_title(field_desc),
|
|
2392
2375
|
titleFormatter: text_title_formatter,
|
|
2393
2376
|
editable: get_editable_state,
|
|
2394
2377
|
editor: false,
|
|
@@ -3793,7 +3776,23 @@ function ac_add_table_row(gobj, event, kw, src)
|
|
|
3793
3776
|
let record = kw.record;
|
|
3794
3777
|
let loading = kw.loading;
|
|
3795
3778
|
|
|
3796
|
-
|
|
3779
|
+
/* Tabulator says `dataChanged` INSIDE addRow(), synchronously: a row
|
|
3780
|
+
* loaded from the record is muted there, whenever it lands -- also
|
|
3781
|
+
* from a `tableBuilt` that comes after the load returned, which is
|
|
3782
|
+
* why no timer can tell the two apart. */
|
|
3783
|
+
let added;
|
|
3784
|
+
if(loading) {
|
|
3785
|
+
gobj.priv.loading_rows++;
|
|
3786
|
+
}
|
|
3787
|
+
try {
|
|
3788
|
+
added = tabulator.addRow(record);
|
|
3789
|
+
} finally {
|
|
3790
|
+
if(loading) {
|
|
3791
|
+
gobj.priv.loading_rows--;
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
|
|
3795
|
+
added
|
|
3797
3796
|
.then(function(row) {
|
|
3798
3797
|
if(loading) {
|
|
3799
3798
|
/*
|
|
@@ -3955,6 +3954,19 @@ function ac_language_changed(gobj, event, kw, src)
|
|
|
3955
3954
|
editor.updateProps({onRenderMenu: json_editor_render_menu(gobj)});
|
|
3956
3955
|
}
|
|
3957
3956
|
}
|
|
3957
|
+
|
|
3958
|
+
/* The titles of the columns of every table, nested ones included:
|
|
3959
|
+
* Tabulator draws them at build, so they stayed in the language the
|
|
3960
|
+
* form was built in. Through the table's LOCALE, never by
|
|
3961
|
+
* updateDefinition(): rebuilding a column re-renders every row, and
|
|
3962
|
+
* a row's formatter builds its nested tables anew -- empty. A table
|
|
3963
|
+
* not built yet is drawn in the current language when it is. */
|
|
3964
|
+
for(let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) {
|
|
3965
|
+
let tabulator = $table.tabulator;
|
|
3966
|
+
if(tabulator && tabulator.initialized && $table.template) {
|
|
3967
|
+
yui_tabulator_relocalize(tabulator, t, table_column_titles($table.template));
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3958
3970
|
return 0;
|
|
3959
3971
|
}
|
|
3960
3972
|
|
package/src/c_yui_fsm_graph.js
CHANGED
|
@@ -430,8 +430,9 @@ function build_graph(gobj)
|
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
/* Tab goes from the graph to its own buttons: the main canvas in
|
|
433
|
-
* the Tab order, the other layers out
|
|
434
|
-
|
|
433
|
+
* the Tab order, named for what it draws, the other layers out
|
|
434
|
+
* (g6_canvas_tab_order.js). */
|
|
435
|
+
keep_canvas_tab_order(gobj, priv.graph, "fsm graph");
|
|
435
436
|
|
|
436
437
|
priv.graph.on('aftertransform', () => {
|
|
437
438
|
yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
|
|
@@ -1166,8 +1166,9 @@ function build_graph(gobj)
|
|
|
1166
1166
|
}
|
|
1167
1167
|
|
|
1168
1168
|
/* Tab goes from the graph to its own buttons: the main canvas in
|
|
1169
|
-
* the Tab order, the other layers out
|
|
1170
|
-
|
|
1169
|
+
* the Tab order, named for what it draws, the other layers out
|
|
1170
|
+
* (g6_canvas_tab_order.js). */
|
|
1171
|
+
keep_canvas_tab_order(gobj, graph, "gobj tree graph");
|
|
1171
1172
|
|
|
1172
1173
|
/* The readout follows ANY camera change, the wheel included — a
|
|
1173
1174
|
* wheel notch passes through no action of ours. */
|
package/src/c_yui_json_graph.js
CHANGED
|
@@ -758,8 +758,9 @@ function build_graph(gobj)
|
|
|
758
758
|
}
|
|
759
759
|
|
|
760
760
|
/* Tab goes from the graph to its own buttons: the main canvas in
|
|
761
|
-
* the Tab order, the other layers out
|
|
762
|
-
|
|
761
|
+
* the Tab order, named for what it draws, the other layers out
|
|
762
|
+
* (g6_canvas_tab_order.js). */
|
|
763
|
+
keep_canvas_tab_order(gobj, graph, "json graph");
|
|
763
764
|
|
|
764
765
|
graph.on(NodeEvent.CLICK, (evt) => {
|
|
765
766
|
/* An identity, never the G6 event: a kw is plain json, and the
|
package/src/c_yui_nav.js
CHANGED
|
@@ -463,17 +463,17 @@ function render_tabs(gobj, items)
|
|
|
463
463
|
}
|
|
464
464
|
/* A tab with show_label:false is a bare icon: the label is
|
|
465
465
|
* its only name (same contract as item_li). */
|
|
466
|
-
let
|
|
466
|
+
let name_key = it.name || it.aria_label || it.id || "";
|
|
467
467
|
let a_attrs = {
|
|
468
468
|
href: it.route ? "#" + it.route : "#",
|
|
469
469
|
"data-item-id": it.id,
|
|
470
470
|
"data-route": it.route || "",
|
|
471
|
-
"aria-label":
|
|
471
|
+
"aria-label": name_key
|
|
472
472
|
};
|
|
473
|
-
if(
|
|
474
|
-
a_attrs["data-i18n-aria-label"] =
|
|
473
|
+
if(name_key) {
|
|
474
|
+
a_attrs["data-i18n-aria-label"] = name_key;
|
|
475
475
|
}
|
|
476
|
-
let tip = it.tooltip || it.aria_label ||
|
|
476
|
+
let tip = it.tooltip || it.aria_label || name_key;
|
|
477
477
|
if(tip) {
|
|
478
478
|
a_attrs.title = tip;
|
|
479
479
|
a_attrs["data-i18n-title"] = tip;
|
|
@@ -543,19 +543,22 @@ function render_breadcrumb(gobj, items)
|
|
|
543
543
|
}
|
|
544
544
|
/* Named and titled like every other item of the nav: up to
|
|
545
545
|
* 7.26.34 a crumb had no title, and no name when it had no
|
|
546
|
-
* `name` (an icon crumb read as nothing).
|
|
546
|
+
* `name` (an icon crumb read as nothing), and from 7.26.35 to
|
|
547
|
+
* 7.26.41 it was named by its raw id, with no key: the id is
|
|
548
|
+
* its key, as in item_li. */
|
|
549
|
+
let name_key = it.name || it.aria_label || it.id || "";
|
|
547
550
|
let a_attrs = {
|
|
548
551
|
class: "yui-nav-item yui-nav-crumb",
|
|
549
552
|
href: it.route ? "#" + it.route : "#",
|
|
550
553
|
"data-item-id": it.id,
|
|
551
554
|
"data-route": it.route || "",
|
|
552
555
|
"data-disabled": it.disabled ? "1" : "0",
|
|
553
|
-
"aria-label":
|
|
556
|
+
"aria-label": name_key
|
|
554
557
|
};
|
|
555
|
-
if(
|
|
556
|
-
a_attrs["data-i18n-aria-label"] =
|
|
558
|
+
if(name_key) {
|
|
559
|
+
a_attrs["data-i18n-aria-label"] = name_key;
|
|
557
560
|
}
|
|
558
|
-
let tip = it.tooltip || it.aria_label ||
|
|
561
|
+
let tip = it.tooltip || it.aria_label || name_key;
|
|
559
562
|
if(tip) {
|
|
560
563
|
a_attrs.title = tip;
|
|
561
564
|
a_attrs["data-i18n-title"] = tip;
|
|
@@ -690,10 +693,17 @@ function render_accordion(gobj, items)
|
|
|
690
693
|
let head_badge = item_badge_node(gobj, it, false);
|
|
691
694
|
if(!empty_string(head_text)) {
|
|
692
695
|
head_attrs.i18n = head_text;
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
696
|
+
}
|
|
697
|
+
/* Named as every item (item_li): its `name`, else its
|
|
698
|
+
* `aria_label`, else its id, a KEY in every case. Up to 7.26.41
|
|
699
|
+
* a head without a `name` was a button with no name at all. */
|
|
700
|
+
let name_key = it.name || it.aria_label || it.id || "";
|
|
701
|
+
if(!empty_string(name_key)) {
|
|
702
|
+
let tip = it.tooltip || it.aria_label || name_key;
|
|
703
|
+
head_attrs.title = tip;
|
|
704
|
+
head_attrs["data-i18n-title"] = tip;
|
|
705
|
+
head_attrs["aria-label"] = name_key;
|
|
706
|
+
head_attrs["data-i18n-aria-label"] = name_key;
|
|
697
707
|
/* The count is part of its name: inside a <button> the
|
|
698
708
|
* badge is no node of its own for a reader (yui_badge.js) */
|
|
699
709
|
name_control_with_badge(head_attrs, head_badge);
|
|
@@ -791,28 +801,32 @@ function item_li(gobj, it, opts)
|
|
|
791
801
|
}
|
|
792
802
|
}
|
|
793
803
|
|
|
794
|
-
|
|
804
|
+
/* The name of an item: its `name`, else its `aria_label`, else its
|
|
805
|
+
* id -- a KEY in every case, translated by the pass that translates
|
|
806
|
+
* the labels and reached by a language switch. Up to 7.26.41 an
|
|
807
|
+
* item without a `name` was named by its raw id, with no key and no
|
|
808
|
+
* title, and the `aria_label` it declared went only to the tooltip. */
|
|
809
|
+
let name_key = it.name || it.aria_label || it.id || "";
|
|
795
810
|
let a_attrs = {
|
|
796
811
|
class: a_class,
|
|
797
812
|
href: it.route ? "#" + it.route : "#",
|
|
798
813
|
"data-item-id": it.id,
|
|
799
814
|
"data-route": it.route || "",
|
|
800
815
|
"data-disabled": it.disabled ? "1" : "0",
|
|
801
|
-
"aria-label":
|
|
816
|
+
"aria-label": name_key
|
|
802
817
|
};
|
|
803
818
|
/* Mirror the aria-label key in `data-i18n-aria-label` so
|
|
804
|
-
* refresh_language() can re-translate it on language switch.
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
if(label) {
|
|
808
|
-
a_attrs["data-i18n-aria-label"] = label;
|
|
819
|
+
* refresh_language() can re-translate it on language switch. */
|
|
820
|
+
if(name_key) {
|
|
821
|
+
a_attrs["data-i18n-aria-label"] = name_key;
|
|
809
822
|
}
|
|
810
823
|
/* Hover tooltip: prefer explicit `tooltip`, fall back to
|
|
811
|
-
* `aria_label` (typically equivalent, e.g. "Search (Ctrl+F)")
|
|
812
|
-
* Skip when
|
|
824
|
+
* `aria_label` (typically equivalent, e.g. "Search (Ctrl+F)"),
|
|
825
|
+
* then the name. Skip when all are empty so we don't emit
|
|
826
|
+
* `title=""` noise.
|
|
813
827
|
* Mirror the value in `data-i18n-title` so refresh_language()
|
|
814
828
|
* can re-translate the tooltip on language switch. */
|
|
815
|
-
let tip = it.tooltip || it.aria_label ||
|
|
829
|
+
let tip = it.tooltip || it.aria_label || name_key;
|
|
816
830
|
if(tip) {
|
|
817
831
|
a_attrs.title = tip;
|
|
818
832
|
a_attrs["data-i18n-title"] = tip;
|
|
@@ -864,17 +878,18 @@ function item_iconbar(gobj, it, opts)
|
|
|
864
878
|
children.push(badge_el);
|
|
865
879
|
}
|
|
866
880
|
|
|
881
|
+
let name_key = it.name || it.aria_label || it.id || "";
|
|
867
882
|
let a_attrs = {
|
|
868
883
|
class: "yui-nav-item yui-nav-stacked",
|
|
869
884
|
href: it.route ? "#" + it.route : "#",
|
|
870
885
|
"data-item-id": it.id,
|
|
871
886
|
"data-route": it.route || "",
|
|
872
|
-
"aria-label":
|
|
887
|
+
"aria-label": name_key
|
|
873
888
|
};
|
|
874
|
-
if(
|
|
875
|
-
a_attrs["data-i18n-aria-label"] =
|
|
889
|
+
if(name_key) {
|
|
890
|
+
a_attrs["data-i18n-aria-label"] = name_key;
|
|
876
891
|
}
|
|
877
|
-
let tip = it.tooltip || it.aria_label ||
|
|
892
|
+
let tip = it.tooltip || it.aria_label || name_key;
|
|
878
893
|
if(tip) {
|
|
879
894
|
a_attrs.title = tip;
|
|
880
895
|
a_attrs["data-i18n-title"] = tip;
|
|
@@ -58,6 +58,22 @@
|
|
|
58
58
|
cursor: pointer;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/* The opener of a topic row: a real button -- a key presses it, a
|
|
62
|
+
* reader announces it -- that looks like the name it is. Not
|
|
63
|
+
* `font: inherit`: it would undo the weight of the name. */
|
|
64
|
+
.C_YUI_SCHEMA_EDITOR .SCHEMA_TOPIC_OPEN {
|
|
65
|
+
background: none;
|
|
66
|
+
border: 0;
|
|
67
|
+
margin: 0;
|
|
68
|
+
padding: 0;
|
|
69
|
+
color: inherit;
|
|
70
|
+
font-family: inherit;
|
|
71
|
+
font-size: inherit;
|
|
72
|
+
line-height: inherit;
|
|
73
|
+
text-align: inherit;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
.C_YUI_SCHEMA_EDITOR .SCHEMA_COL_FLAGS .tags {
|
|
62
78
|
margin-bottom: 0;
|
|
63
79
|
}
|
|
@@ -291,6 +291,10 @@ let PRIVATE_DATA = {
|
|
|
291
291
|
|
|
292
292
|
let __gclass__ = null;
|
|
293
293
|
|
|
294
|
+
/* The ids that tie an opener to what describes it (aria-describedby):
|
|
295
|
+
* the counts of a card, the id of a topic row whose name is not unique. */
|
|
296
|
+
let __described_seq__ = 0;
|
|
297
|
+
|
|
294
298
|
|
|
295
299
|
|
|
296
300
|
|
|
@@ -1295,6 +1299,15 @@ function render(gobj)
|
|
|
1295
1299
|
* A card that opens something, with its own logical name. The
|
|
1296
1300
|
* cards grid is the shell's, so a schema card and a nav card
|
|
1297
1301
|
* look alike on purpose.
|
|
1302
|
+
*
|
|
1303
|
+
* `title` is the card's name: `{i18n: key}`, or `{text: data}` for
|
|
1304
|
+
* a name no locale holds (a treedb's id). The card is a control --
|
|
1305
|
+
* a role=button that Enter and Space press -- and a control is
|
|
1306
|
+
* NAMED: a title and an aria-label, with their keys when the name
|
|
1307
|
+
* is one, and its tags (the counts) as its description, which an
|
|
1308
|
+
* aria-label alone would hide from a reader. Up to 7.26.41 it had
|
|
1309
|
+
* neither, and the orphans card was handed its name translated,
|
|
1310
|
+
* in the language it was drawn in for good.
|
|
1298
1311
|
***************************************************************/
|
|
1299
1312
|
function open_card(gobj, logical, title, icon, tags, event, kw)
|
|
1300
1313
|
{
|
|
@@ -1323,14 +1336,29 @@ function open_card(gobj, logical, title, icon, tags, event, kw)
|
|
|
1323
1336
|
: `${tag.text}`];
|
|
1324
1337
|
});
|
|
1325
1338
|
|
|
1326
|
-
|
|
1339
|
+
let tags_id = `yui-schema-described-${++__described_seq__}`;
|
|
1340
|
+
let card_attrs = {class: `${logical} yui-nav-card card`, role: "button", tabindex: "0",
|
|
1341
|
+
"aria-describedby": tags_id};
|
|
1342
|
+
let $name;
|
|
1343
|
+
if(title.i18n) {
|
|
1344
|
+
Object.assign(card_attrs, name_attrs(title.i18n, {}));
|
|
1345
|
+
$name = ["span", {class: `${logical}_NAME has-text-weight-semibold`, i18n: title.i18n},
|
|
1346
|
+
t(title.i18n)];
|
|
1347
|
+
} else {
|
|
1348
|
+
card_attrs.title = String(title.text);
|
|
1349
|
+
card_attrs["aria-label"] = String(title.text);
|
|
1350
|
+
$name = ["span", {class: `${logical}_NAME has-text-weight-semibold`},
|
|
1351
|
+
text_node(title.text)];
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
return ["div", card_attrs, [
|
|
1327
1355
|
["div", {class: `${logical}_BODY card-content p-3`}, [
|
|
1328
1356
|
["p", {class: `${logical}_TITLE is-flex is-align-items-center`,
|
|
1329
1357
|
style: "gap:.4rem;"}, [
|
|
1330
|
-
["span", {class: "icon"}, [["i", {class: icon}]]],
|
|
1331
|
-
|
|
1358
|
+
["span", {class: "icon"}, [["i", {class: icon, "aria-hidden": "true"}]]],
|
|
1359
|
+
$name
|
|
1332
1360
|
]],
|
|
1333
|
-
["div", {class: `${logical}_TAGS tags mt-2`, style: "gap:.25rem;"}, $tags]
|
|
1361
|
+
["div", {class: `${logical}_TAGS tags mt-2`, id: tags_id, style: "gap:.25rem;"}, $tags]
|
|
1334
1362
|
]]
|
|
1335
1363
|
], {
|
|
1336
1364
|
click: (evt) => {
|
|
@@ -1372,7 +1400,7 @@ function render_treedbs(gobj, $body)
|
|
|
1372
1400
|
? [{i18n: "from c", text: treedb.c_schema_version, style: "is-warning is-light"}]
|
|
1373
1401
|
: [])
|
|
1374
1402
|
];
|
|
1375
|
-
$cards.push(open_card(gobj, "SCHEMA_TREEDB_CARD", treedb.id, "yi-database",
|
|
1403
|
+
$cards.push(open_card(gobj, "SCHEMA_TREEDB_CARD", {text: treedb.id}, "yi-database",
|
|
1376
1404
|
tags, "EV_SELECT_TREEDB", {treedb: treedb.id}));
|
|
1377
1405
|
}
|
|
1378
1406
|
|
|
@@ -1380,7 +1408,7 @@ function render_treedbs(gobj, $body)
|
|
|
1380
1408
|
/* A leftover of a deletion belongs to no treedb and would be
|
|
1381
1409
|
* invisible in a screen that only draws the tree. Saying it
|
|
1382
1410
|
* here is the only place it can be said. */
|
|
1383
|
-
$cards.push(open_card(gobj, "SCHEMA_ORPHAN_CARD",
|
|
1411
|
+
$cards.push(open_card(gobj, "SCHEMA_ORPHAN_CARD", {i18n: "orphans"}, "yi-triangle-exclamation",
|
|
1384
1412
|
[{i18n: "topics", text: priv.model.orphan_topics.length},
|
|
1385
1413
|
{i18n: "columns", text: priv.model.orphan_cols.length}],
|
|
1386
1414
|
"EV_SHOW_ORPHANS", {}));
|
|
@@ -1429,9 +1457,30 @@ function render_topics(gobj, $body)
|
|
|
1429
1457
|
"EV_DELETE_TOPIC", {topic: address}));
|
|
1430
1458
|
}
|
|
1431
1459
|
|
|
1432
|
-
|
|
1460
|
+
/* The row stays a ROW: a `<tr role=button>` -- what it was up to
|
|
1461
|
+
* 7.26.41 -- is a button to a reader, with no cells, and it had
|
|
1462
|
+
* no name. The opener is a real button in the name cell, named
|
|
1463
|
+
* by the topic: a key presses it with no handler of ours, and a
|
|
1464
|
+
* reader reads the rest of the row as cells of a table. Two
|
|
1465
|
+
* topics of one name are told apart by the id under the name,
|
|
1466
|
+
* which describes the opener. The pointer opens the topic from
|
|
1467
|
+
* anywhere in the row, as before. */
|
|
1468
|
+
let open_attrs = {class: "SCHEMA_TOPIC_OPEN has-text-weight-semibold", type: "button",
|
|
1469
|
+
title: topic.name, "aria-label": topic.name};
|
|
1470
|
+
let id_attrs = {class: "SCHEMA_TOPIC_ID is-size-7 yui-text-quiet"};
|
|
1471
|
+
if(ambiguous) {
|
|
1472
|
+
id_attrs.id = `yui-schema-described-${++__described_seq__}`;
|
|
1473
|
+
open_attrs["aria-describedby"] = id_attrs.id;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
$rows.push(["tr", {class: "SCHEMA_TOPIC_ROW"}, [
|
|
1433
1477
|
["td", {class: "SCHEMA_TOPIC_NAME"}, [
|
|
1434
|
-
["
|
|
1478
|
+
["button", open_attrs, text_node(topic.name), {
|
|
1479
|
+
click: (evt) => {
|
|
1480
|
+
evt.stopPropagation();
|
|
1481
|
+
gobj_send_event(gobj, "EV_SELECT_TOPIC", {topic: address}, gobj);
|
|
1482
|
+
}
|
|
1483
|
+
}],
|
|
1435
1484
|
topic.system_topic
|
|
1436
1485
|
? ["span", {class: "SCHEMA_TOPIC_SYSTEM tag ml-2",
|
|
1437
1486
|
i18n: "system"}, t("system")]
|
|
@@ -1444,8 +1493,7 @@ function render_topics(gobj, $body)
|
|
|
1444
1493
|
title: t("main topic"), "data-i18n-title": "main topic"}, "★"]
|
|
1445
1494
|
: ["span", {}, ""],
|
|
1446
1495
|
ambiguous
|
|
1447
|
-
? ["div",
|
|
1448
|
-
[["code", {}, text_node(topic.id)]]]
|
|
1496
|
+
? ["div", id_attrs, [["code", {}, text_node(topic.id)]]]
|
|
1449
1497
|
: ["span", {}, ""]
|
|
1450
1498
|
]],
|
|
1451
1499
|
["td", {class: "SCHEMA_TOPIC_PKEY"}, [["code", {}, text_node(topic.pkey || "id")]]],
|
|
@@ -1456,18 +1504,14 @@ function render_topics(gobj, $body)
|
|
|
1456
1504
|
]],
|
|
1457
1505
|
["td", {class: "SCHEMA_TOPIC_ACTIONS has-text-right"}, $actions]
|
|
1458
1506
|
], {
|
|
1507
|
+
/* The pointer's way in. The keyboard's is the opener: the
|
|
1508
|
+
* row's own keydown also took an Enter meant for a row
|
|
1509
|
+
* action, which then opened the topic instead. */
|
|
1459
1510
|
click: (evt) => {
|
|
1460
1511
|
if(evt.target.closest(".SCHEMA_TOPIC_ACTIONS")) {
|
|
1461
1512
|
return; /* a row action, not the row */
|
|
1462
1513
|
}
|
|
1463
1514
|
gobj_send_event(gobj, "EV_SELECT_TOPIC", {topic: address}, gobj);
|
|
1464
|
-
},
|
|
1465
|
-
keydown: (evt) => {
|
|
1466
|
-
if(evt.key !== "Enter" && evt.key !== " ") {
|
|
1467
|
-
return;
|
|
1468
|
-
}
|
|
1469
|
-
evt.preventDefault();
|
|
1470
|
-
gobj_send_event(gobj, "EV_SELECT_TOPIC", {topic: address}, gobj);
|
|
1471
1515
|
}
|
|
1472
1516
|
}]);
|
|
1473
1517
|
}
|