@yuneta/gobj-ui 7.26.41 → 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.
@@ -18,13 +18,50 @@
18
18
  * All Rights Reserved.
19
19
  ***********************************************************************/
20
20
 
21
+ /************************************************************
22
+ * The label of a row is the name of its CONTROL: one rule names
23
+ * an item everywhere.
24
+ *
25
+ * - A menu entry, as the nav names it (c_yui_nav.js item_li):
26
+ * its `name`, else its `aria_label`, else its id.
27
+ * - A toolbar item and a row of its dropdown, as the toolbar
28
+ * names them (c_yui_shell.js build_toolbar_*): its
29
+ * `aria_label` first -- the visible `name` of a toolbar
30
+ * button is often a symbol ("ES/EN") --, then its `name`,
31
+ * then, for an avatar or a connection dot, the library's own
32
+ * key, else its id.
33
+ *
34
+ * A route is no key: it has its own column, and an item with
35
+ * none of these has no label. Up to 7.26.41 a row was labelled
36
+ * `name || wordmark || id || route` -- an entry that declares
37
+ * only an `aria_label` had its id here, the language button read
38
+ * "ES/EN" where its control says "toggle language", and a route
39
+ * was asked of the locales as a key.
40
+ ************************************************************/
41
+ function menu_item_label(it)
42
+ {
43
+ return it.name || it.aria_label || it.id || "";
44
+ }
45
+
46
+ function toolbar_item_label(it)
47
+ {
48
+ let fallback = it.id || "";
49
+ if(it.type === "avatar") {
50
+ fallback = "user menu";
51
+ } else if(it.type === "connection") {
52
+ fallback = "backend connection";
53
+ }
54
+ return it.aria_label || it.name || fallback;
55
+ }
56
+
21
57
  /************************************************************
22
58
  * One node of the nav map from a declared config item, in
23
59
  * DECLARATION ORDER (never sorted). Recurses into static submenus
24
60
  * and toolbar dropdowns, and merges the LIVE dynamic submenu tabs
25
61
  * (added at runtime via yui_shell_set_submenu) by parent id.
62
+ * `label_of` names it: menu_item_label() or toolbar_item_label().
26
63
  ************************************************************/
27
- function nav_node_from_item(it, index)
64
+ function nav_node_from_item(it, index, label_of)
28
65
  {
29
66
  if(!it || it.type === "divider" || it.type === "header") {
30
67
  return null;
@@ -45,7 +82,7 @@ function nav_node_from_item(it, index)
45
82
  }
46
83
  let node = {
47
84
  id: it.id || "",
48
- label: it.name || it.wordmark || it.id || route || "",
85
+ label: label_of(it),
49
86
  icon: it.icon || "",
50
87
  route: route,
51
88
  event: event,
@@ -62,7 +99,7 @@ function nav_node_from_item(it, index)
62
99
  action.items : null);
63
100
  if(sub_items) {
64
101
  for(let s of sub_items) {
65
- let n = nav_node_from_item(s, index);
102
+ let n = nav_node_from_item(s, index, label_of);
66
103
  if(n) {
67
104
  node.children.push(n);
68
105
  }
@@ -79,7 +116,8 @@ function nav_node_from_item(it, index)
79
116
  !node.children.some((c) => c.route === r)) {
80
117
  node.children.push({
81
118
  id: (e.item && e.item.id) || "",
82
- label: (e.item && e.item.name) || r,
119
+ /* A runtime tab is an entry of a nav */
120
+ label: e.item ? menu_item_label(e.item) : "",
83
121
  icon: (e.item && e.item.icon) || "",
84
122
  route: r,
85
123
  event: "",
@@ -231,7 +269,10 @@ function mark_current(groups, current_route)
231
269
  *
232
270
  * - `nav` walks EVERY declared menu in declaration order: the
233
271
  * `primary` menu contributes its items flat (the common case);
234
- * any other menu contributes a group node labelled by its key.
272
+ * any other menu contributes a group node labelled by its key,
273
+ * as data (`data_label: true`).
274
+ * - a node is labelled as its control is named (menu_item_label(),
275
+ * toolbar_item_label()); a node no item names has label "".
235
276
  * - `other` lists the routes declared only in the route table
236
277
  * (config.shell.routes) that no rendered node covers — root "/",
237
278
  * URL-only action routes, toolbar-less forms. Brand-covered
@@ -260,13 +301,16 @@ function build_nav_map(input)
260
301
  for(let it of tb) {
261
302
  if(it && it.type === "brand") {
262
303
  let a = it.action || {};
304
+ /* The ROOT of the map is the app, and the wordmark is its
305
+ * name -- not the brand BUTTON's `aria_label`, which says
306
+ * what pressing it does ("go to home"). */
263
307
  brand = {
264
308
  label: it.wordmark || it.alt || it.id || "",
265
309
  route: it.route || (a.type === "navigate" ? a.route : "") || ""
266
310
  };
267
311
  continue;
268
312
  }
269
- let n = nav_node_from_item(it, index);
313
+ let n = nav_node_from_item(it, index, toolbar_item_label);
270
314
  if(n) {
271
315
  toolbar.push(n);
272
316
  }
@@ -284,7 +328,7 @@ function build_nav_map(input)
284
328
  }
285
329
  let nodes = [];
286
330
  for(let it of m.items) {
287
- let n = nav_node_from_item(it, index);
331
+ let n = nav_node_from_item(it, index, menu_item_label);
288
332
  if(n) {
289
333
  nodes.push(n);
290
334
  }
@@ -292,9 +336,12 @@ function build_nav_map(input)
292
336
  if(menu_id === "primary") {
293
337
  nav = nav.concat(nodes);
294
338
  } else if(nodes.length) {
339
+ /* A menu declares no name: its id is what the map can show,
340
+ * and an id is DATA (`data_label`), drawn as it is and never
341
+ * asked of the locales -- as a route is not. */
295
342
  nav.push({
296
- id: menu_id, label: menu_id, icon: "", route: "", event: "",
297
- gclass: "", kind: "group", children: nodes
343
+ id: menu_id, label: menu_id, data_label: true, icon: "", route: "",
344
+ event: "", gclass: "", kind: "group", children: nodes
298
345
  });
299
346
  }
300
347
  }
@@ -336,7 +383,9 @@ function build_nav_map(input)
336
383
  let tgt = (e && e.target) || null;
337
384
  other.push({
338
385
  id: (e && e.item && e.item.id) || "",
339
- label: (e && e.item && (e.item.name || e.item.id)) || r,
386
+ /* A route is no key: one no item names has no label, and
387
+ * its route is in its own column. */
388
+ label: (e && e.item) ? menu_item_label(e.item) : "",
340
389
  icon: (e && e.item && e.item.icon) || "",
341
390
  route: r,
342
391
  event: (tgt && tgt.kind === "action" && tgt.event) || "",
@@ -277,3 +277,93 @@ test("'you are here' lands on the owner, never on a reference", () => {
277
277
  expect(map.nav.find((n) => n.route === "/cards").current).toBe(true);
278
278
  expect(map.toolbar[0].children[0].current).toBeUndefined();
279
279
  });
280
+
281
+
282
+ /***************************************************************
283
+ * one rule names an item everywhere (REV-CLOUD V24.5.4)
284
+ *
285
+ * A row of the map is labelled as its CONTROL is named: a menu
286
+ * entry as the nav names it (c_yui_nav.js: `name`, else
287
+ * `aria_label`, else id), a toolbar item and a row of its menu as
288
+ * the toolbar does (c_yui_shell.js: `aria_label` first). Up to
289
+ * 7.26.41 it was `name || wordmark || id || route`: an entry that
290
+ * declares only an `aria_label` had its id in the map, the lang
291
+ * button read "ES/EN" where its control says "toggle language",
292
+ * and a route -- which is no key -- was a label asked of the
293
+ * locales.
294
+ ***************************************************************/
295
+ describe("a row of the map is labelled as its control is named", () => {
296
+ function map_of(config, index)
297
+ {
298
+ return build_nav_map({config: config, item_index: index || {}});
299
+ }
300
+ const by_id = (nodes, id) => nodes.find((n) => n.id === id);
301
+
302
+ test("a menu entry: its `name`, else its `aria_label`, else its id -- never its route", () => {
303
+ const m = map_of({menu: {primary: {items: [
304
+ {id: "home", name: "home", aria_label: "go home", route: "/home"},
305
+ {id: "x9", aria_label: "active alarms", route: "/x9"},
306
+ {id: "events", route: "/events"},
307
+ {route: "/anonymous"},
308
+ ]}}});
309
+ expect(m.nav.map((n) => n.label)).toEqual(["home", "active alarms", "events", ""]);
310
+ expect(m.nav[3].route).toBe("/anonymous"); // the route has its own column
311
+ });
312
+
313
+ test("a submenu entry and a runtime tab: the same rule", () => {
314
+ const parent = {id: "devices", name: "devices", route: "/devices", submenu: {items: [
315
+ {id: "list", aria_label: "device list", route: "/devices/list"}
316
+ ]}};
317
+ const m = map_of({menu: {primary: {items: [parent]}}}, {
318
+ "/devices/tab1": {item: {id: "tab1", aria_label: "first device"},
319
+ parent_item: parent, target: {gclass: "C_DEV"}},
320
+ "/devices/tab2": {item: {id: "tab2"}, parent_item: parent, target: {gclass: "C_DEV"}}
321
+ });
322
+ expect(m.nav[0].children.map((n) => n.label))
323
+ .toEqual(["device list", "first device", "tab2"]);
324
+ });
325
+
326
+ test("a toolbar item and a row of its menu: as the toolbar names them, `aria_label` first", () => {
327
+ const m = map_of({toolbar: {items: [
328
+ {id: "lang", name: "ES/EN", aria_label: "toggle language",
329
+ action: {type: "event", event: "EV_LANG"}},
330
+ {id: "help", icon: "yi-circle-question", action: {type: "event", event: "EV_HELP"}},
331
+ {id: "user", type: "avatar", action: {type: "dropdown", items: [
332
+ {id: "logout", action: {type: "event", event: "EV_LOGOUT"}},
333
+ {id: "prefs", name: "preferences", action: {type: "event", event: "EV_PREFS"}}
334
+ ]}},
335
+ {id: "conn", type: "connection"}
336
+ ]}});
337
+ expect(m.toolbar.map((n) => n.label))
338
+ .toEqual(["toggle language", "help", "user menu", "backend connection"]);
339
+ expect(by_id(m.toolbar, "user").children.map((n) => n.label)).toEqual(["logout", "preferences"]);
340
+ });
341
+
342
+ test("a route of the route table no item points at: no label, its route in its column", () => {
343
+ const m = map_of({menu: {primary: {items: []}}}, {
344
+ "/hidden": {item: null, target: {gclass: "C_HIDDEN"}},
345
+ "/kept": {item: {id: "kept", aria_label: "kept route"}, target: {gclass: "C_KEPT"}}
346
+ });
347
+ expect(m.other.map((n) => [n.route, n.label]))
348
+ .toEqual([["/hidden", ""], ["/kept", "kept route"]]);
349
+ });
350
+
351
+ test("the brand, the ROOT of the map, keeps its wordmark: it names the app", () => {
352
+ const m = map_of({toolbar: {items: [
353
+ {type: "brand", id: "brand", wordmark: "demo", aria_label: "go to home",
354
+ action: {type: "navigate", route: "/"}}
355
+ ]}});
356
+ expect(m.brand.label).toBe("demo");
357
+ });
358
+
359
+ test("another menu is a group labelled by its id, as DATA: a menu declares no name", () => {
360
+ const m = map_of({menu: {
361
+ primary: {items: [{id: "a", name: "a", route: "/a"}]},
362
+ quick: {items: [{id: "b", name: "b", route: "/b"}]}
363
+ }});
364
+ const quick = by_id(m.nav, "quick");
365
+ expect(quick.kind).toBe("group");
366
+ expect(quick.label).toBe("quick");
367
+ expect(quick.data_label).toBe(true);
368
+ });
369
+ });
@@ -0,0 +1,283 @@
1
+ /***********************************************************************
2
+ * schema_editor_openers.wiring.test.js
3
+ *
4
+ * What opens something in C_YUI_SCHEMA_EDITOR is a NAMED control
5
+ * (REV-CLOUD V24.5.4):
6
+ *
7
+ * - a card of the treedbs screen (a treedb, the leftovers of a
8
+ * deletion) is a role=button with a title and an aria-label,
9
+ * its counts its description; up to 7.26.40 it had neither;
10
+ * - a row of the topics screen keeps the table's semantics: it was
11
+ * a `<tr role=button>`, which unmakes the row for a reader (a
12
+ * button has no cells) and had no name either. Its opener is a
13
+ * real button in the name cell, named by the topic; the pointer
14
+ * still opens the topic from anywhere in the row.
15
+ *
16
+ * A real C_YUI_SCHEMA_EDITOR on a document double, driven through
17
+ * its FSM.
18
+ *
19
+ * Copyright (c) 2026, ArtGins.
20
+ * All Rights Reserved.
21
+ ***********************************************************************/
22
+ import {describe, test, expect, beforeAll, beforeEach} from "vitest";
23
+ import {install_dom_double, fake_event} from "../test/dom_double.js";
24
+
25
+ install_dom_double();
26
+
27
+ const {
28
+ SDATA_END,
29
+ gclass_create,
30
+ gobj_start_up, gobj_create_yuno, gobj_create, gobj_create_service,
31
+ gobj_start, gobj_send_event, gobj_read_attr, gobj_current_state,
32
+ gobj_change_state, refresh_language,
33
+ set_log_callback,
34
+ } = await import("@yuneta/gobj-js");
35
+ const {register_c_yui_schema_editor} = await import("./c_yui_schema_editor.js");
36
+
37
+ const logged = [];
38
+ const commands = [];
39
+
40
+ /* One treedb with two topics, and a topic whose treedb is gone (the
41
+ * leftover of a deletion: the orphans card). */
42
+ const RECORDS = {
43
+ treedbs: [{id: "db", schema_version: 4}],
44
+ topics: [
45
+ {id: "db.users", value: "users", order: 1, pkey: "id", topic_version: 2,
46
+ treedbs: ["treedbs^db^topics"]},
47
+ {id: "db.roles", value: "roles", order: 2, pkey: "id", topic_version: 1,
48
+ treedbs: ["treedbs^db^topics"]},
49
+ {id: "gone.left", value: "left", order: 1, pkey: "id", topic_version: 1,
50
+ treedbs: ["treedbs^gone^topics"]},
51
+ ],
52
+ cols: [
53
+ {id: "db.users.id", value: "id", order: 1, type: "string",
54
+ flag: ["persistent", "required"], topics: ["topics^db.users^cols"]},
55
+ {id: "db.roles.id", value: "id", order: 1, type: "string",
56
+ flag: ["persistent", "required"], topics: ["topics^db.roles^cols"]},
57
+ ],
58
+ };
59
+
60
+ function remote_command_parser(gobj, command, kw, src)
61
+ {
62
+ commands.push({command, kw, src});
63
+ return null;
64
+ }
65
+
66
+ let yuno = null;
67
+ let seq = 0;
68
+
69
+ beforeAll(async () => {
70
+ const i18next = (await import("i18next")).default;
71
+ await i18next.init({lng: "en", resources: {}});
72
+ gobj_start_up(null, null, null, null, null, null, null);
73
+ set_log_callback((level, msg) => {
74
+ logged.push({level: String(level), msg: String(msg)});
75
+ });
76
+ gclass_create("C_TEST_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
77
+ gclass_create(
78
+ "C_TEST_EDITOR_HOST",
79
+ [["EV_POSITION_CHANGED", 0], ["EV_RECORD_WRITTEN", 0], ["EV_SCHEMA_CHECKED", 0]],
80
+ [["ST_IDLE", [
81
+ ["EV_POSITION_CHANGED", () => 0, null],
82
+ ["EV_RECORD_WRITTEN", () => 0, null],
83
+ ["EV_SCHEMA_CHECKED", () => 0, null]
84
+ ]]],
85
+ {}, 0, [SDATA_END()], {}, 0, 0, 0, 0
86
+ );
87
+ gclass_create(
88
+ "C_TEST_REMOTE",
89
+ [],
90
+ [["ST_SESSION", []]],
91
+ {mt_command_parser: remote_command_parser},
92
+ 0, [SDATA_END()], {}, 0, 0, 0, 0
93
+ );
94
+ register_c_yui_schema_editor();
95
+ yuno = gobj_create_yuno("openers_yuno", "C_TEST_HOST", {});
96
+ gobj_start(yuno);
97
+ });
98
+
99
+ beforeEach(() => {
100
+ logged.length = 0;
101
+ commands.length = 0;
102
+ });
103
+
104
+ function errors()
105
+ {
106
+ return logged.filter((l) => l.level === "error").map((l) => l.msg);
107
+ }
108
+
109
+ /* Answer every `nodes` the editor asked, as a transport does. */
110
+ function answer_the_load(editor, remote, records)
111
+ {
112
+ const asked = commands.filter((c) => c.command === "nodes");
113
+ commands.length = 0;
114
+ for(const c of asked) {
115
+ gobj_send_event(editor, "EV_MT_COMMAND_ANSWER", {
116
+ result: 0,
117
+ data: (records || RECORDS)[c.kw.topic_name],
118
+ __md_iev__: {command_stack: [{command: "nodes", kw: c.kw}]}
119
+ }, remote);
120
+ }
121
+ return asked.length;
122
+ }
123
+
124
+ /* An editor with its schemas loaded, on the screen of `subpath`. */
125
+ function build(subpath, records)
126
+ {
127
+ const name = `openers_${++seq}`;
128
+ const remote = gobj_create_service(`${name}_remote`, "C_TEST_REMOTE", {}, yuno);
129
+ gobj_change_state(remote, "ST_SESSION");
130
+ const host = gobj_create(`${name}_host`, "C_TEST_EDITOR_HOST", {}, yuno);
131
+ const editor = gobj_create(`${name}_editor`, "C_YUI_SCHEMA_EDITOR", {
132
+ gobj_remote_yuno: remote,
133
+ treedb_name: "treedb_system_schema",
134
+ base_route: "/schemas"
135
+ }, host);
136
+ gobj_start(editor);
137
+ expect(answer_the_load(editor, remote, records)).toBe(3);
138
+ gobj_send_event(editor, "EV_SHOW", {subpath: subpath}, host);
139
+ return editor;
140
+ }
141
+
142
+ function root(editor)
143
+ {
144
+ return gobj_read_attr(editor, "$container");
145
+ }
146
+
147
+ /* The text of the element an IDREF of `$el` points at, in its tree. */
148
+ function referenced_text($el, attr)
149
+ {
150
+ let $top = $el;
151
+ while($top.parentNode) {
152
+ $top = $top.parentNode;
153
+ }
154
+ return ($el.getAttribute(attr) || "").split(/\s+/).filter(Boolean).map((id) => {
155
+ const $ref = $top.querySelector(`#${id}`);
156
+ expect(!!$ref, `${attr} points at '${id}', which is not in its tree`).toBe(true);
157
+ return $ref.textContent;
158
+ }).join(" ");
159
+ }
160
+
161
+ describe("a card of the treedbs screen", () => {
162
+ test("is a named control: a title, an aria-label, and its counts as its description", () => {
163
+ const editor = build("");
164
+ expect(gobj_current_state(editor)).toBe("ST_TREEDBS");
165
+
166
+ const $card = root(editor).querySelector(".SCHEMA_TREEDB_CARD");
167
+ expect(!!$card).toBe(true);
168
+ expect($card.getAttribute("role")).toBe("button");
169
+ expect($card.getAttribute("tabindex")).toBe("0");
170
+ /* The treedb's name is DATA: it is not translated. */
171
+ expect($card.getAttribute("title")).toBe("db");
172
+ expect($card.getAttribute("aria-label")).toBe("db");
173
+ expect($card.getAttribute("data-i18n-aria-label")).toBe(null);
174
+ expect(referenced_text($card, "aria-describedby")).toBe("topics2version4");
175
+ expect(errors()).toEqual([]);
176
+ });
177
+
178
+ test("the orphans card is named by its key, and changes language with the page", async () => {
179
+ const i18next = (await import("i18next")).default;
180
+ i18next.addResourceBundle("es", "translation", {"orphans": "Huérfanos"}, true, true);
181
+ const editor = build("");
182
+
183
+ const $card = root(editor).querySelector(".SCHEMA_ORPHAN_CARD");
184
+ expect(!!$card).toBe(true);
185
+ expect($card.getAttribute("role")).toBe("button");
186
+ expect($card.getAttribute("title")).toBe("orphans");
187
+ expect($card.getAttribute("aria-label")).toBe("orphans");
188
+ expect($card.getAttribute("data-i18n-title")).toBe("orphans");
189
+ expect($card.getAttribute("data-i18n-aria-label")).toBe("orphans");
190
+ expect($card.querySelector(".SCHEMA_ORPHAN_CARD_NAME").getAttribute("data-i18n")).toBe("orphans");
191
+
192
+ /* The text of its name carries the key too (data-i18n): the
193
+ * double does not translate text nodes, a browser does. */
194
+ refresh_language(root(editor), i18next.getFixedT("es"));
195
+ expect($card.getAttribute("title")).toBe("Huérfanos");
196
+ expect($card.getAttribute("aria-label")).toBe("Huérfanos");
197
+ });
198
+
199
+ test("Enter and Space open it, through the machine", () => {
200
+ for(const key of ["Enter", " "]) {
201
+ const editor = build("");
202
+ const $card = root(editor).querySelector(".SCHEMA_TREEDB_CARD");
203
+ const ev = fake_event("keydown", {key: key});
204
+ $card.dispatchEvent(ev);
205
+ expect(ev.defaultPrevented).toBe(true); // Space would scroll the page
206
+ expect(gobj_current_state(editor)).toBe("ST_TOPICS");
207
+ }
208
+ expect(errors()).toEqual([]);
209
+ });
210
+ });
211
+
212
+ describe("a row of the topics screen", () => {
213
+ test("is a row of the table, not a button; its opener is a real button in the name cell, named by the topic", () => {
214
+ const editor = build("db");
215
+ expect(gobj_current_state(editor)).toBe("ST_TOPICS");
216
+
217
+ const $rows = root(editor).querySelectorAll(".SCHEMA_TOPIC_ROW");
218
+ expect($rows.length).toBe(2);
219
+ for(const $row of $rows) {
220
+ expect($row.tagName).toBe("TR");
221
+ expect($row.getAttribute("role")).toBe(null);
222
+ expect($row.getAttribute("tabindex")).toBe(null);
223
+ }
224
+
225
+ const $open = $rows[0].querySelector(".SCHEMA_TOPIC_NAME .SCHEMA_TOPIC_OPEN");
226
+ expect(!!$open).toBe(true);
227
+ expect($open.tagName).toBe("BUTTON");
228
+ expect($open.getAttribute("type")).toBe("button");
229
+ /* The topic's name is DATA: it is not translated. */
230
+ expect($open.getAttribute("title")).toBe("users");
231
+ expect($open.getAttribute("aria-label")).toBe("users");
232
+ expect($open.textContent).toBe("users");
233
+ expect(errors()).toEqual([]);
234
+ });
235
+
236
+ test("its opener opens the topic -- a key presses a <button> with no handler of ours", () => {
237
+ const editor = build("db");
238
+ root(editor).querySelector(".SCHEMA_TOPIC_ROW .SCHEMA_TOPIC_OPEN").click();
239
+ expect(gobj_current_state(editor)).toBe("ST_COLUMNS");
240
+ expect(errors()).toEqual([]);
241
+ });
242
+
243
+ test("the pointer still opens it from anywhere in the row, and not from a row action", () => {
244
+ const editor = build("db");
245
+ const $row = root(editor).querySelector(".SCHEMA_TOPIC_ROW");
246
+
247
+ /* A press on a row action is the action's, not the row's. */
248
+ const $edit = $row.querySelector(".SCHEMA_TOPIC_EDIT");
249
+ expect(!!$edit).toBe(true);
250
+ $row.dispatchEvent(fake_event("click", {target: $edit}));
251
+ expect(gobj_current_state(editor)).toBe("ST_TOPICS");
252
+
253
+ $row.dispatchEvent(fake_event("click", {target: $row.querySelector(".SCHEMA_TOPIC_PKEY")}));
254
+ expect(gobj_current_state(editor)).toBe("ST_COLUMNS");
255
+ expect(errors()).toEqual([]);
256
+ });
257
+
258
+ /* Two generations of one schema in a store: two topics named
259
+ * "users", told apart only by their ids. */
260
+ test("two topics of one name: each opener says the id that tells them apart", () => {
261
+ const records = {
262
+ treedbs: RECORDS.treedbs,
263
+ topics: [
264
+ {id: "db.users", value: "users", order: 1, pkey: "id", topic_version: 2,
265
+ treedbs: ["treedbs^db^topics"]},
266
+ {id: "17", value: "users", order: 2, pkey: "id", topic_version: 1,
267
+ treedbs: ["treedbs^db^topics"]},
268
+ ],
269
+ cols: [],
270
+ };
271
+ const editor = build("db", records);
272
+ const $opens = root(editor).querySelectorAll(".SCHEMA_TOPIC_OPEN");
273
+ expect($opens.length).toBe(2);
274
+ expect($opens.map(($o) => $o.getAttribute("aria-label"))).toEqual(["users", "users"]);
275
+ expect($opens.map(($o) => referenced_text($o, "aria-describedby"))).toEqual(["db.users", "17"]);
276
+
277
+ /* And each opens its own: by id, the name would open the first. */
278
+ $opens[1].click();
279
+ expect(gobj_current_state(editor)).toBe("ST_COLUMNS");
280
+ expect(editor.priv.topic_name).toBe("17");
281
+ expect(errors()).toEqual([]);
282
+ });
283
+ });
@@ -396,7 +396,15 @@ export function yui_shell_show_modal(shell, content, opts)
396
396
  * once, over the question's own, and the next Back -- the one meant
397
397
  * for the question -- reached the modal, which asked again: every
398
398
  * Back stacked one more question. Same contract as the `asking`
399
- * close of C_YUI_WINDOW. */
399
+ * close of C_YUI_WINDOW.
400
+ *
401
+ * What the promise SETTLES with is the answer: `true` closes the
402
+ * modal, as a `true` returned at once does; anything else -- what a
403
+ * question that closed the modal itself on "yes" settles with, a
404
+ * `false`, a rejection (said) -- is the veto, and a Back that asked
405
+ * gets its entry back then. Up to 7.26.41 any promise was a veto,
406
+ * so an `async () => true` left a modal nobody could close. A
407
+ * `true` that comes after the modal closed closes nothing twice. */
400
408
  let guarded_close = function(on_veto) {
401
409
  if(closed) {
402
410
  return;
@@ -411,9 +419,21 @@ export function yui_shell_show_modal(shell, content, opts)
411
419
  }
412
420
  }
413
421
  if(allow && typeof allow.then === "function") {
414
- if(typeof on_veto === "function") {
415
- allow.then(on_veto, on_veto);
416
- }
422
+ let vetoed = function() {
423
+ if(typeof on_veto === "function") {
424
+ on_veto();
425
+ }
426
+ };
427
+ allow.then(function(answer) {
428
+ if(answer === true) {
429
+ do_close();
430
+ return;
431
+ }
432
+ vetoed();
433
+ }, function(e) {
434
+ log_warning(`yui_shell_show_modal: before_close rejected: ${e}`);
435
+ vetoed();
436
+ });
417
437
  return;
418
438
  }
419
439
  if(allow === false) {
@@ -88,8 +88,16 @@ function render_node(node)
88
88
  row.push(["span", {class: "icon ROUTEMAP_ICON"},
89
89
  [["i", {class: node.icon, "aria-hidden": "true"}]]]);
90
90
  }
91
- row.push(["span", {class: "ROUTEMAP_NAME", i18n: node.label},
92
- text_node(node.label)]);
91
+ /* The name is a KEY -- an item's, as its control is named
92
+ * (route_map_model.js) -- except a label the model marks as DATA:
93
+ * the id of a menu, which declares no name. A node no item names
94
+ * has no name of its own; its route is in its column. */
95
+ if(node.label && node.data_label) {
96
+ row.push(["span", {class: "ROUTEMAP_NAME"}, text_node(node.label)]);
97
+ } else if(node.label) {
98
+ row.push(["span", {class: "ROUTEMAP_NAME", i18n: node.label},
99
+ text_node(node.label)]);
100
+ }
93
101
  /* Documentation columns: route + implementing gclass + action event. */
94
102
  if(node.route) {
95
103
  row.push(["code", {class: "ROUTEMAP_ROUTE"}, text_node(node.route)]);
@@ -131,9 +139,13 @@ function render_node(node)
131
139
  let a_attrs = {class: "ROUTEMAP_LINK ROUTEMAP_ROW" + row_class,
132
140
  href: "#" + node.route,
133
141
  title: node.route};
134
- if(node.label) {
142
+ if(node.label && !node.data_label) {
135
143
  a_attrs["aria-label"] = node.label;
136
144
  a_attrs["data-i18n-aria-label"] = node.label;
145
+ } else {
146
+ /* Data, as it is: a menu's id, or the route of a row that no
147
+ * item names -- no key, so nothing to re-translate. */
148
+ a_attrs["aria-label"] = node.label || node.route;
137
149
  }
138
150
  if(node.current) {
139
151
  a_attrs["aria-current"] = "page";
@@ -55,7 +55,9 @@ export function section_index_target(menu_id, item)
55
55
  gclass: "C_YUI_NAV",
56
56
  kw: {
57
57
  menu_id: `index.${menu_id}.${item.id}`,
58
- nav_label: item.name || item.id || "",
58
+ /* The landing is named by its entry, as the nav names the
59
+ * entry: `name`, else `aria_label`, else id. */
60
+ nav_label: item.name || item.aria_label || item.id || "",
59
61
  menu_items: sub.items,
60
62
  layout: "cards",
61
63
  level: "secondary"