@yuneta/gobj-ui 7.26.5 → 7.26.7
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 +141 -25
- package/dist/gobj-ui.cjs.js +1358 -429
- package/dist/gobj-ui.es.js +1349 -430
- package/index.js +18 -2
- package/package.json +2 -2
- package/src/c_g6_nodes_tree.js +41 -0
- package/src/c_yui_form.js +287 -91
- package/src/c_yui_gclass.js +6 -2
- package/src/c_yui_gobj_tree_js.js +15 -4
- package/src/c_yui_json_graph.js +40 -13
- package/src/c_yui_map.js +115 -75
- package/src/c_yui_nav.js +53 -14
- package/src/c_yui_pager.js +14 -9
- package/src/c_yui_period.js +16 -6
- package/src/c_yui_shell.js +116 -30
- package/src/c_yui_treedb_topic_with_form.js +111 -46
- package/src/c_yui_treedb_topics.js +77 -7
- package/src/c_yui_uplot.js +1 -1
- package/src/c_yui_window.js +70 -24
- package/src/c_yui_window_manager.js +7 -3
- package/src/c_yui_wizard.js +23 -8
- package/src/delete_impact.js +5 -3
- package/src/form_json_field.js +116 -0
- package/src/form_json_field.test.js +43 -0
- package/src/form_json_field.wiring.test.js +137 -0
- package/src/lib_icons.js +395 -0
- package/src/lib_icons.test.js +214 -0
- package/src/schema_to_c.js +17 -1
- package/src/schema_to_c.test.js +7 -0
- package/src/shell_route_map.js +6 -0
- package/src/treedb_topics_transport.wiring.test.js +9 -1
- package/src/window_veto_back.wiring.test.js +101 -0
- package/src/wizard_chrome.wiring.test.js +87 -0
- package/src/yui_dev.js +10 -3
- package/src/yui_icons.css +20 -0
- package/src/yui_table_filter_clear.js +44 -44
- package/vite-plugin-yuneta-html.js +28 -6
package/src/c_yui_shell.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
SDATA, SDATA_END, data_type_t, event_flag_t, gclass_flag_t,
|
|
34
34
|
gclass_create, log_error, log_warning,
|
|
35
35
|
gobj_create, gobj_destroy,
|
|
36
|
-
gobj_start, gobj_stop,
|
|
36
|
+
gobj_start, gobj_stop, gobj_stop_children,
|
|
37
37
|
gobj_parent,
|
|
38
38
|
gobj_gclass_name,
|
|
39
39
|
gobj_publish_event,
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
refresh_language,
|
|
45
45
|
is_gobj,
|
|
46
46
|
gobj_has_event,
|
|
47
|
+
gobj_short_name,
|
|
47
48
|
gobj_is_destroying,
|
|
48
49
|
} from "@yuneta/gobj-js";
|
|
49
50
|
|
|
@@ -419,6 +420,10 @@ function mt_stop(gobj)
|
|
|
419
420
|
st.items = {};
|
|
420
421
|
st.active_route = null;
|
|
421
422
|
}
|
|
423
|
+
|
|
424
|
+
/* Whatever else the shell hosts — the site map window — stops
|
|
425
|
+
* with it, or destroying the shell destroys a RUNNING gobj. */
|
|
426
|
+
gobj_stop_children(gobj);
|
|
422
427
|
}
|
|
423
428
|
|
|
424
429
|
/***************************************************************
|
|
@@ -1795,12 +1800,13 @@ function build_toolbar_action_item(gobj, it)
|
|
|
1795
1800
|
btn_attrs["aria-haspopup"] = "menu";
|
|
1796
1801
|
btn_attrs["aria-expanded"] = "false";
|
|
1797
1802
|
}
|
|
1798
|
-
/* Hover tooltip: prefer explicit `tooltip`,
|
|
1799
|
-
*
|
|
1800
|
-
*
|
|
1803
|
+
/* Hover tooltip: prefer explicit `tooltip`, then `aria_label`
|
|
1804
|
+
* (usually the same intent — e.g. "Search (Ctrl+F)"), then the
|
|
1805
|
+
* name: every control carries a title. Skip only when all are
|
|
1806
|
+
* empty, so we don't emit `title=""` noise.
|
|
1801
1807
|
* Mirror the value in `data-i18n-title` so refresh_language()
|
|
1802
1808
|
* can re-translate the tooltip on language switch. */
|
|
1803
|
-
let tip = it.tooltip ||
|
|
1809
|
+
let tip = it.tooltip || i18n_aria;
|
|
1804
1810
|
if(tip) {
|
|
1805
1811
|
btn_attrs.title = tip;
|
|
1806
1812
|
btn_attrs["data-i18n-title"] = tip;
|
|
@@ -1866,6 +1872,11 @@ function build_toolbar_brand_item(gobj, it)
|
|
|
1866
1872
|
} else {
|
|
1867
1873
|
attrs.type = "button";
|
|
1868
1874
|
}
|
|
1875
|
+
let tip = it.tooltip || i18n_aria;
|
|
1876
|
+
if(tag !== "div" && tip) {
|
|
1877
|
+
attrs.title = tip;
|
|
1878
|
+
attrs["data-i18n-title"] = tip;
|
|
1879
|
+
}
|
|
1869
1880
|
let $item = createElement2([tag, attrs, [
|
|
1870
1881
|
["img", {class: "yui-toolbar-brand-logo",
|
|
1871
1882
|
src: it.logo, alt: alt}],
|
|
@@ -1904,7 +1915,7 @@ function build_toolbar_avatar_item(gobj, it)
|
|
|
1904
1915
|
attrs["aria-haspopup"] = "menu";
|
|
1905
1916
|
attrs["aria-expanded"] = "false";
|
|
1906
1917
|
}
|
|
1907
|
-
let tip = it.tooltip ||
|
|
1918
|
+
let tip = it.tooltip || i18n_aria;
|
|
1908
1919
|
if(tip) {
|
|
1909
1920
|
attrs.title = tip;
|
|
1910
1921
|
attrs["data-i18n-title"] = tip;
|
|
@@ -1991,7 +2002,7 @@ function build_toolbar_connection_item(gobj, it)
|
|
|
1991
2002
|
"aria-label": aria_key,
|
|
1992
2003
|
"data-i18n-aria-label": i18n_aria
|
|
1993
2004
|
};
|
|
1994
|
-
let tip = it.tooltip ||
|
|
2005
|
+
let tip = it.tooltip || i18n_aria;
|
|
1995
2006
|
if(tip) {
|
|
1996
2007
|
attrs.title = tip;
|
|
1997
2008
|
attrs["data-i18n-title"] = tip;
|
|
@@ -2219,6 +2230,14 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
|
|
|
2219
2230
|
$panel.style.right = "auto";
|
|
2220
2231
|
$panel.style.left = `${Math.round(left)}px`;
|
|
2221
2232
|
}
|
|
2233
|
+
/* And inside it vertically: on a short phone screen a long menu
|
|
2234
|
+
* (one row per language) ran off the bottom, out of reach. It
|
|
2235
|
+
* scrolls inside itself instead (see `dismiss` below). */
|
|
2236
|
+
let max_h = window.innerHeight - Math.max(0, pos.top) - margin;
|
|
2237
|
+
if(max_h > 0) {
|
|
2238
|
+
$panel.style.maxHeight = `${Math.round(max_h)}px`;
|
|
2239
|
+
$panel.style.overflowY = "auto";
|
|
2240
|
+
}
|
|
2222
2241
|
|
|
2223
2242
|
/* Translate the lazily-built panel (see the note above). */
|
|
2224
2243
|
yui_shell_translate(gobj, $panel);
|
|
@@ -2242,7 +2261,15 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
|
|
|
2242
2261
|
* trigger. Match native <select> UX and dismiss on either.
|
|
2243
2262
|
* Capture-phase + passive scroll so we hear all scrollers (any
|
|
2244
2263
|
* ancestor, not just window) without blocking them. */
|
|
2245
|
-
let dismiss = () =>
|
|
2264
|
+
let dismiss = (ev) => {
|
|
2265
|
+
/* The panel's own scroll is the reader reaching its last rows,
|
|
2266
|
+
* not a layout shift. */
|
|
2267
|
+
if(ev && ev.type === "scroll" && ev.target && ev.target !== document &&
|
|
2268
|
+
$panel.contains(ev.target)) {
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
close_toolbar_dropdown(gobj);
|
|
2272
|
+
};
|
|
2246
2273
|
document.addEventListener("scroll", dismiss, {capture: true, passive: true});
|
|
2247
2274
|
window.addEventListener("resize", dismiss);
|
|
2248
2275
|
|
|
@@ -2359,6 +2386,8 @@ function build_dropdown_row(gobj, sub, idx)
|
|
|
2359
2386
|
};
|
|
2360
2387
|
if(i18n_aria) {
|
|
2361
2388
|
attrs["data-i18n-aria-label"] = i18n_aria;
|
|
2389
|
+
attrs.title = i18n_aria;
|
|
2390
|
+
attrs["data-i18n-title"] = i18n_aria;
|
|
2362
2391
|
}
|
|
2363
2392
|
let $btn = createElement2(["button", attrs, children]);
|
|
2364
2393
|
$btn.addEventListener("click", ev => {
|
|
@@ -2442,6 +2471,7 @@ function push_escape(gobj, layer, handler)
|
|
|
2442
2471
|
{
|
|
2443
2472
|
let priv = gobj.priv;
|
|
2444
2473
|
if(!priv || !priv.escape_stack) {
|
|
2474
|
+
log_warning(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
|
|
2445
2475
|
return;
|
|
2446
2476
|
}
|
|
2447
2477
|
priv.escape_stack.push({ layer: layer, handler: handler });
|
|
@@ -2451,7 +2481,7 @@ function pop_escape(gobj, handler)
|
|
|
2451
2481
|
{
|
|
2452
2482
|
let priv = gobj.priv;
|
|
2453
2483
|
if(!priv || !priv.escape_stack) {
|
|
2454
|
-
return;
|
|
2484
|
+
return; /* not an error: an overlay closing after its shell was torn down */
|
|
2455
2485
|
}
|
|
2456
2486
|
let idx = priv.escape_stack.findIndex(e => e.handler === handler);
|
|
2457
2487
|
if(idx >= 0) {
|
|
@@ -2513,9 +2543,15 @@ function drain_overlays(gobj)
|
|
|
2513
2543
|
/* Survivors keep their relative order: the stack is a LIFO and a
|
|
2514
2544
|
* panel that outlives the drain must stay where it was, or Escape
|
|
2515
2545
|
* would start closing overlays in an order the user never built. */
|
|
2546
|
+
/* The stack is taken whole BEFORE any close runs: an overlay that
|
|
2547
|
+
* vetoes its close registers again (C_YUI_WINDOW), and popping
|
|
2548
|
+
* the live stack would pop that new entry and close it again,
|
|
2549
|
+
* for ever. Such an entry is newer than every survivor, so it
|
|
2550
|
+
* goes above them. */
|
|
2551
|
+
let entries = priv.overlay_stack.splice(0);
|
|
2516
2552
|
let kept = [];
|
|
2517
|
-
while(
|
|
2518
|
-
let entry =
|
|
2553
|
+
while(entries.length > 0) {
|
|
2554
|
+
let entry = entries.pop();
|
|
2519
2555
|
if(entry.keep_on_navigate) {
|
|
2520
2556
|
kept.unshift(entry);
|
|
2521
2557
|
continue;
|
|
@@ -2526,9 +2562,7 @@ function drain_overlays(gobj)
|
|
|
2526
2562
|
log_warning(`C_YUI_SHELL: overlay close on navigation failed: ${e}`);
|
|
2527
2563
|
}
|
|
2528
2564
|
}
|
|
2529
|
-
|
|
2530
|
-
priv.overlay_stack.push(entry);
|
|
2531
|
-
}
|
|
2565
|
+
priv.overlay_stack.unshift(...kept);
|
|
2532
2566
|
}
|
|
2533
2567
|
|
|
2534
2568
|
/* A URL rewrite moved the entry `st` tags to `hash`. When `st` is a live
|
|
@@ -2817,7 +2851,10 @@ function ac_nav_clicked(gobj, event, kw, src)
|
|
|
2817
2851
|
{
|
|
2818
2852
|
let route = (kw && kw.route) || "";
|
|
2819
2853
|
if(empty_string(route)) {
|
|
2820
|
-
|
|
2854
|
+
/* C_YUI_NAV publishes no click for an item without a route:
|
|
2855
|
+
* whoever sent this one is broken. */
|
|
2856
|
+
log_warning(`C_YUI_SHELL: ${event} with no route, from ${gobj_short_name(src)}`);
|
|
2857
|
+
return -1;
|
|
2821
2858
|
}
|
|
2822
2859
|
|
|
2823
2860
|
/* A click on a section returns to where the user was inside it.
|
|
@@ -2947,8 +2984,9 @@ function prune_route(shell_gobj, route)
|
|
|
2947
2984
|
|
|
2948
2985
|
function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
|
|
2949
2986
|
{
|
|
2950
|
-
let priv = shell_gobj.priv;
|
|
2987
|
+
let priv = shell_gobj && shell_gobj.priv;
|
|
2951
2988
|
if(!priv) {
|
|
2989
|
+
log_error(`C_YUI_SHELL: yui_shell_set_submenu('${parent_item_id}') — no shell`);
|
|
2952
2990
|
return -1;
|
|
2953
2991
|
}
|
|
2954
2992
|
let nav = find_secondary_nav(priv, parent_item_id);
|
|
@@ -3005,8 +3043,12 @@ function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
|
|
|
3005
3043
|
}
|
|
3006
3044
|
priv.dynamic_routes[parent_item_id] = new_routes;
|
|
3007
3045
|
|
|
3008
|
-
/* Push the new items into the nav (rebuilds its DOM in place)
|
|
3046
|
+
/* Push the new items into the nav (rebuilds its DOM in place), and
|
|
3047
|
+
* re-apply the translator: the rebuilt labels carry their keys as
|
|
3048
|
+
* raw text until somebody translates them (the same policy as the
|
|
3049
|
+
* index view below, and as C_YUI_NODE's projections). */
|
|
3009
3050
|
gobj_send_event(nav, "EV_SET_ITEMS", {items: items}, shell_gobj);
|
|
3051
|
+
yui_shell_translate(shell_gobj, gobj_read_attr(nav, "$container"));
|
|
3010
3052
|
|
|
3011
3053
|
/* Section-index landing (submenu.index): keep the synthesized
|
|
3012
3054
|
* target and any mounted index view (a "cards" C_YUI_NAV in the
|
|
@@ -3040,18 +3082,21 @@ function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
|
|
|
3040
3082
|
* Global methods table
|
|
3041
3083
|
*---------------------------------------------*/
|
|
3042
3084
|
/***************************************************************
|
|
3043
|
-
* EV_CONNECTION_STATE
|
|
3044
|
-
*
|
|
3045
|
-
* to EVERY event of its shell with one attr
|
|
3046
|
-
* ask for
|
|
3047
|
-
*
|
|
3048
|
-
* and adding
|
|
3049
|
-
*
|
|
3050
|
-
*
|
|
3085
|
+
* EV_CONNECTION_STATE and EV_ICONS_CHANGED are OPTIONAL facts: a
|
|
3086
|
+
* view that needs one subscribes to it by name. An app that
|
|
3087
|
+
* subscribed to EVERY event of its shell with one attr
|
|
3088
|
+
* (`subscriber`) did not ask for them and does not declare them --
|
|
3089
|
+
* published to it anyway, each would be an FSM error in the app
|
|
3090
|
+
* every time it fires, and adding one to the shell a breaking
|
|
3091
|
+
* change for every such app (7.26.6 did exactly that with
|
|
3092
|
+
* EV_ICONS_CHANGED). So they reach only the subscribers that
|
|
3093
|
+
* declare them. Every other event of the shell goes out as before.
|
|
3051
3094
|
***************************************************************/
|
|
3095
|
+
const OPTIONAL_EVENTS = new Set(["EV_CONNECTION_STATE", "EV_ICONS_CHANGED"]);
|
|
3096
|
+
|
|
3052
3097
|
function mt_publication_pre_filter(gobj, subs, event, kw)
|
|
3053
3098
|
{
|
|
3054
|
-
if(event
|
|
3099
|
+
if(!OPTIONAL_EVENTS.has(event)) {
|
|
3055
3100
|
return 1;
|
|
3056
3101
|
}
|
|
3057
3102
|
let subscriber = subs && subs.subscriber;
|
|
@@ -3119,6 +3164,17 @@ function create_gclass(gclass_name)
|
|
|
3119
3164
|
|event_flag_t.EVF_PUBLIC_EVENT
|
|
3120
3165
|
|event_flag_t.EVF_NO_WARN_SUBS],
|
|
3121
3166
|
|
|
3167
|
+
/* The user icons changed (a view loaded `__icons__`, or a node of
|
|
3168
|
+
* it was written, and called yui_shell_icons_changed). A class name
|
|
3169
|
+
* picks its icon up by itself once the rule exists, but a view that
|
|
3170
|
+
* DECIDED, at render time, whether a name is an icon at all -- the
|
|
3171
|
+
* icon cell of a table -- has to decide again. Delivered only to
|
|
3172
|
+
* the subscribers that declare it: see
|
|
3173
|
+
* mt_publication_pre_filter(). */
|
|
3174
|
+
["EV_ICONS_CHANGED", event_flag_t.EVF_OUTPUT_EVENT
|
|
3175
|
+
|event_flag_t.EVF_PUBLIC_EVENT
|
|
3176
|
+
|event_flag_t.EVF_NO_WARN_SUBS],
|
|
3177
|
+
|
|
3122
3178
|
/* The app's backend connection went up or down
|
|
3123
3179
|
* (yui_shell_set_connection_state), {connected}. Delivered only
|
|
3124
3180
|
* to the subscribers that declare it: see
|
|
@@ -3475,9 +3531,20 @@ function yui_shell_register_event_handler(shell_gobj, event, gclass)
|
|
|
3475
3531
|
|
|
3476
3532
|
/* Drawer helpers — toggle the off-canvas nav from the outside
|
|
3477
3533
|
* (e.g. a hamburger button in the toolbar). menu_id is optional. */
|
|
3478
|
-
function yui_shell_open_drawer(shell_gobj, menu_id)
|
|
3479
|
-
|
|
3480
|
-
|
|
3534
|
+
function yui_shell_open_drawer(shell_gobj, menu_id)
|
|
3535
|
+
{
|
|
3536
|
+
open_drawer(shell_gobj, menu_id);
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
function yui_shell_close_drawer(shell_gobj, menu_id)
|
|
3540
|
+
{
|
|
3541
|
+
close_drawer(shell_gobj, menu_id);
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
function yui_shell_toggle_drawer(shell_gobj, menu_id)
|
|
3545
|
+
{
|
|
3546
|
+
toggle_drawer(shell_gobj, menu_id);
|
|
3547
|
+
}
|
|
3481
3548
|
|
|
3482
3549
|
/* Escape priority chain — public API used by overlays that the
|
|
3483
3550
|
* shell does not own (modals from #4, future popups, custom
|
|
@@ -3603,7 +3670,7 @@ function yui_shell_set_translator(shell_gobj, t)
|
|
|
3603
3670
|
*
|
|
3604
3671
|
* The division of labour, unchanged: LIBRARY-built DOM is
|
|
3605
3672
|
* translated through here; APP view gclasses translate their own
|
|
3606
|
-
* DOM (they own a `t` — see
|
|
3673
|
+
* DOM (they own a `t` — see build_view_gobj).
|
|
3607
3674
|
*
|
|
3608
3675
|
* Silent no-op with no shell or no translator: an app that never
|
|
3609
3676
|
* registered one keeps the previous behaviour instead of losing
|
|
@@ -3643,6 +3710,24 @@ function yui_shell_language_changed(shell_gobj)
|
|
|
3643
3710
|
gobj_publish_event(shell_gobj, "EV_LANGUAGE_CHANGED", {});
|
|
3644
3711
|
}
|
|
3645
3712
|
|
|
3713
|
+
/************************************************************
|
|
3714
|
+
* The user icons changed (lib_icons.js: yui_icons_set_user,
|
|
3715
|
+
* yui_icons_put_user, yui_icons_remove_user): PUBLISH it, so
|
|
3716
|
+
* the views that decided at render time whether a name is an
|
|
3717
|
+
* icon draw it again.
|
|
3718
|
+
*
|
|
3719
|
+
* The registry is a module and knows no shell; the view that
|
|
3720
|
+
* fed it calls this.
|
|
3721
|
+
************************************************************/
|
|
3722
|
+
function yui_shell_icons_changed(shell_gobj)
|
|
3723
|
+
{
|
|
3724
|
+
if(!shell_gobj || !is_gobj(shell_gobj)) {
|
|
3725
|
+
log_error("yui_shell_icons_changed(): no shell");
|
|
3726
|
+
return;
|
|
3727
|
+
}
|
|
3728
|
+
gobj_publish_event(shell_gobj, "EV_ICONS_CHANGED", {});
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3646
3731
|
/************************************************************
|
|
3647
3732
|
* Set the backend-connection state painted by every
|
|
3648
3733
|
* type:"connection" toolbar item. Host/event-driven: the
|
|
@@ -3798,6 +3883,7 @@ export {
|
|
|
3798
3883
|
yui_shell_set_translator,
|
|
3799
3884
|
yui_shell_translate,
|
|
3800
3885
|
yui_shell_language_changed,
|
|
3886
|
+
yui_shell_icons_changed,
|
|
3801
3887
|
yui_shell_set_connection_state,
|
|
3802
3888
|
yui_shell_set_toolbar_item_icon,
|
|
3803
3889
|
yui_shell_set_toolbar_item_badge,
|
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
yui_shell_of,
|
|
73
73
|
} from "./c_yui_shell.js";
|
|
74
74
|
|
|
75
|
-
import {register_c_yui_form} from "./c_yui_form.js";
|
|
75
|
+
import {register_c_yui_form, svg_error_text} from "./c_yui_form.js";
|
|
76
76
|
import {register_c_yui_json} from "./c_yui_json.js";
|
|
77
77
|
import {attach_clear} from "./yui_inputs.js";
|
|
78
78
|
|
|
@@ -91,7 +91,11 @@ import {
|
|
|
91
91
|
} from "./yui_table_select.js";
|
|
92
92
|
|
|
93
93
|
import {yui_table_filter_clear} from "./yui_table_filter_clear.js";
|
|
94
|
-
import {
|
|
94
|
+
import {
|
|
95
|
+
yui_icon_is_defined,
|
|
96
|
+
yui_icons_is_svg_field,
|
|
97
|
+
yui_svg_icon_element
|
|
98
|
+
} from "./lib_icons.js";
|
|
95
99
|
import {row_matches} from "./yui_row_search.js";
|
|
96
100
|
|
|
97
101
|
import {t} from "i18next";
|
|
@@ -109,6 +113,7 @@ import {
|
|
|
109
113
|
yui_asset_ids, yui_asset_element, yui_asset_open_link, yui_asset_release
|
|
110
114
|
} from "./yui_asset.js";
|
|
111
115
|
import {delete_impact} from "./delete_impact.js";
|
|
116
|
+
import {parse_json_field} from "./form_json_field.js";
|
|
112
117
|
|
|
113
118
|
import "./c_yui_treedb_topic_with_form.css";
|
|
114
119
|
import {yui_shell_show_error} from "./shell_modals.js";
|
|
@@ -467,6 +472,9 @@ function mt_start(gobj)
|
|
|
467
472
|
let shell = yui_shell_of(gobj);
|
|
468
473
|
if(shell) {
|
|
469
474
|
gobj_subscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
475
|
+
/* An `icon` cell decides when it is drawn whether its name is an
|
|
476
|
+
* icon (icon_formatter), and a user icon can arrive after that. */
|
|
477
|
+
gobj_subscribe_event(shell, "EV_ICONS_CHANGED", {}, gobj);
|
|
470
478
|
}
|
|
471
479
|
create_tabulator(gobj);
|
|
472
480
|
}
|
|
@@ -479,6 +487,7 @@ function mt_stop(gobj)
|
|
|
479
487
|
let shell = yui_shell_of(gobj);
|
|
480
488
|
if(shell) {
|
|
481
489
|
gobj_unsubscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
490
|
+
gobj_unsubscribe_event(shell, "EV_ICONS_CHANGED", {}, gobj);
|
|
482
491
|
}
|
|
483
492
|
close_form_dialog(gobj);
|
|
484
493
|
close_schema_dialog(gobj);
|
|
@@ -487,6 +496,7 @@ function mt_stop(gobj)
|
|
|
487
496
|
close_cell_file_dialog(gobj);
|
|
488
497
|
close_hook_choice(gobj);
|
|
489
498
|
drop_pending_assets(gobj);
|
|
499
|
+
drop_pending_pages(gobj);
|
|
490
500
|
table__destroy(gobj);
|
|
491
501
|
}
|
|
492
502
|
|
|
@@ -1377,7 +1387,18 @@ function create_tabulator(gobj)
|
|
|
1377
1387
|
if(field_desc.is_hidden) {
|
|
1378
1388
|
continue;
|
|
1379
1389
|
}
|
|
1390
|
+
/* The drawing of a user icon: the cell shows the icon, not its
|
|
1391
|
+
* source, and it is edited in the form (a text area with a
|
|
1392
|
+
* preview) -- never typed into a cell, nor filtered. */
|
|
1393
|
+
if(yui_icons_is_svg_field(gobj_read_str_attr(gobj, "topic_name"), col.id)) {
|
|
1394
|
+
field_desc.type = "svg";
|
|
1395
|
+
}
|
|
1380
1396
|
switch(field_desc.type) {
|
|
1397
|
+
case "svg":
|
|
1398
|
+
hozAlign = "center";
|
|
1399
|
+
vertAlign = "middle";
|
|
1400
|
+
colFormatter = svg_cell_formatter;
|
|
1401
|
+
break;
|
|
1381
1402
|
case "hook":
|
|
1382
1403
|
hozAlign = "center";
|
|
1383
1404
|
cellClick = function(e, cell) {
|
|
@@ -1766,6 +1787,7 @@ function create_tabulator(gobj)
|
|
|
1766
1787
|
try {
|
|
1767
1788
|
n = tabulator.getDataCount("active");
|
|
1768
1789
|
} catch(e) {
|
|
1790
|
+
log_warning(`${gobj_short_name(gobj)}: cannot count the table's rows: ${e}`);
|
|
1769
1791
|
n = 0;
|
|
1770
1792
|
}
|
|
1771
1793
|
}
|
|
@@ -2067,6 +2089,31 @@ function icon_formatter(cell)
|
|
|
2067
2089
|
]);
|
|
2068
2090
|
}
|
|
2069
2091
|
|
|
2092
|
+
/************************************************************
|
|
2093
|
+
* Cell of the drawing of a user icon (`svg` of __icons__): the
|
|
2094
|
+
* icon itself, as the app will draw it. A drawing that cannot
|
|
2095
|
+
* be drawn says why, in plain grey -- the same honest half as
|
|
2096
|
+
* an unknown icon name in icon_formatter.
|
|
2097
|
+
************************************************************/
|
|
2098
|
+
function svg_cell_formatter(cell)
|
|
2099
|
+
{
|
|
2100
|
+
let svg = cell.getValue();
|
|
2101
|
+
if(!is_string(svg) || empty_string(svg)) {
|
|
2102
|
+
return "";
|
|
2103
|
+
}
|
|
2104
|
+
let preview = yui_svg_icon_element(svg);
|
|
2105
|
+
if(preview.error) {
|
|
2106
|
+
let text = svg_error_text(preview.error);
|
|
2107
|
+
return createElement2([
|
|
2108
|
+
"span",
|
|
2109
|
+
{class: "ICON_CELL_UNKNOWN is-size-7 yui-text-quiet", title: text},
|
|
2110
|
+
text
|
|
2111
|
+
]);
|
|
2112
|
+
}
|
|
2113
|
+
preview.element.classList.add("ICON_CELL");
|
|
2114
|
+
return preview.element;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2070
2117
|
/************************************************************
|
|
2071
2118
|
* Cell of a col holding a JSON document (dict/list/blob/
|
|
2072
2119
|
* template/coordinates/…): a one-line truncated preview,
|
|
@@ -2094,7 +2141,9 @@ function build_json_cell_preview(value)
|
|
|
2094
2141
|
['a', {
|
|
2095
2142
|
class: 'JSON_CELL',
|
|
2096
2143
|
title: t('show json'),
|
|
2097
|
-
'data-i18n-title': 'show json'
|
|
2144
|
+
'data-i18n-title': 'show json',
|
|
2145
|
+
'aria-label': t('show json'),
|
|
2146
|
+
'data-i18n-aria-label': 'show json'
|
|
2098
2147
|
}, [
|
|
2099
2148
|
['span', {class: 'JSON_CELL_ICON icon yi-eye'}],
|
|
2100
2149
|
['span', {class: 'JSON_CELL_PREVIEW'}, text]
|
|
@@ -3436,54 +3485,19 @@ function transform__form_value_2_treedb_value(gobj, col, value, operation)
|
|
|
3436
3485
|
case "object":
|
|
3437
3486
|
case "dict":
|
|
3438
3487
|
case "template":
|
|
3439
|
-
if(is_string(value)) {
|
|
3440
|
-
// Come from the form
|
|
3441
|
-
try {
|
|
3442
|
-
value = JSON.parse(value);
|
|
3443
|
-
} catch (e) {
|
|
3444
|
-
value = {};
|
|
3445
|
-
}
|
|
3446
|
-
} else if(is_object(value)) {
|
|
3447
|
-
// Come from the table
|
|
3448
|
-
}
|
|
3449
|
-
if(!is_object(value)) {
|
|
3450
|
-
value = {};
|
|
3451
|
-
}
|
|
3452
|
-
break;
|
|
3453
3488
|
case "array":
|
|
3454
3489
|
case "list":
|
|
3455
|
-
if(is_string(value)) {
|
|
3456
|
-
// Come from the form
|
|
3457
|
-
try {
|
|
3458
|
-
value = JSON.parse(value);
|
|
3459
|
-
} catch (e) {
|
|
3460
|
-
value = [];
|
|
3461
|
-
}
|
|
3462
|
-
} else if(is_array(value)) {
|
|
3463
|
-
// Come from the table
|
|
3464
|
-
}
|
|
3465
|
-
if(!is_array(value)) {
|
|
3466
|
-
value = [];
|
|
3467
|
-
}
|
|
3468
|
-
break;
|
|
3469
3490
|
case "coordinates":
|
|
3470
|
-
case "blob":
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
}
|
|
3476
|
-
value = {};
|
|
3477
|
-
}
|
|
3478
|
-
|
|
3479
|
-
} else if(is_object(value)) {
|
|
3480
|
-
// Come from the table
|
|
3481
|
-
} else if(is_array(value)) {
|
|
3482
|
-
// Come from the table
|
|
3483
|
-
} else {
|
|
3484
|
-
value = {};
|
|
3491
|
+
case "blob": {
|
|
3492
|
+
/* A value that is no json of the column's shape becomes the
|
|
3493
|
+
* empty one -- said, not quiet. */
|
|
3494
|
+
let r = parse_json_field(value, field_desc.type);
|
|
3495
|
+
if(r.error) {
|
|
3496
|
+
log_warning(`${gobj_short_name(gobj)}: column '${col.id}' (${field_desc.type}) holds no valid json, taken as empty`);
|
|
3485
3497
|
}
|
|
3498
|
+
value = r.value;
|
|
3486
3499
|
break;
|
|
3500
|
+
}
|
|
3487
3501
|
|
|
3488
3502
|
case "enum":
|
|
3489
3503
|
switch(field_desc.real_type) {
|
|
@@ -3753,6 +3767,36 @@ function ac_language_changed(gobj, event, kw, src)
|
|
|
3753
3767
|
return 0;
|
|
3754
3768
|
}
|
|
3755
3769
|
|
|
3770
|
+
/************************************************************
|
|
3771
|
+
* The user icons changed (published by the shell): the cells
|
|
3772
|
+
* of an `icon` column decided when they were drawn whether
|
|
3773
|
+
* their name was an icon, so they are drawn again.
|
|
3774
|
+
************************************************************/
|
|
3775
|
+
function ac_icons_changed(gobj, event, kw, src)
|
|
3776
|
+
{
|
|
3777
|
+
let tabulator = gobj_read_attr(gobj, "tabulator");
|
|
3778
|
+
if(!tabulator) {
|
|
3779
|
+
return 0;
|
|
3780
|
+
}
|
|
3781
|
+
let desc = gobj_read_attr(gobj, "desc");
|
|
3782
|
+
let cols = (desc && Array.isArray(desc.cols))? desc.cols : [];
|
|
3783
|
+
let icon_cols = cols.filter(col =>
|
|
3784
|
+
col && col.id && treedb_get_field_desc(col).type === "icon"
|
|
3785
|
+
);
|
|
3786
|
+
if(icon_cols.length === 0) {
|
|
3787
|
+
return 0;
|
|
3788
|
+
}
|
|
3789
|
+
try {
|
|
3790
|
+
for(const row of tabulator.getRows()) {
|
|
3791
|
+
row.reformat();
|
|
3792
|
+
}
|
|
3793
|
+
} catch(e) {
|
|
3794
|
+
log_error(`${gobj_short_name(gobj)}: cannot redraw the icon cells: ${e}`);
|
|
3795
|
+
return -1;
|
|
3796
|
+
}
|
|
3797
|
+
return 0;
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3756
3800
|
function ac_load_nodes(gobj, event, kw, src)
|
|
3757
3801
|
{
|
|
3758
3802
|
let data = kw;
|
|
@@ -4858,6 +4902,25 @@ function request_page(gobj, page, size)
|
|
|
4858
4902
|
});
|
|
4859
4903
|
}
|
|
4860
4904
|
|
|
4905
|
+
/************************************************************
|
|
4906
|
+
* The view stops: no page request is waited for any more. Each
|
|
4907
|
+
* one's watchdog would otherwise fire EV_PAGE_TIMEOUT on a gobj
|
|
4908
|
+
* stopped -- or destroyed -- 20 s later.
|
|
4909
|
+
************************************************************/
|
|
4910
|
+
function drop_pending_pages(gobj)
|
|
4911
|
+
{
|
|
4912
|
+
let priv = gobj.priv;
|
|
4913
|
+
let pending = priv._pending_pages || {};
|
|
4914
|
+
priv._pending_pages = {};
|
|
4915
|
+
for(let req_id of Object.keys(pending)) {
|
|
4916
|
+
let pend = pending[req_id];
|
|
4917
|
+
if(pend.timer) {
|
|
4918
|
+
window.clearTimeout(pend.timer);
|
|
4919
|
+
}
|
|
4920
|
+
pend.reject(new Error("the view stopped"));
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
|
|
4861
4924
|
/************************************************************
|
|
4862
4925
|
* Settle a parked page request, however it ended.
|
|
4863
4926
|
************************************************************/
|
|
@@ -5333,6 +5396,7 @@ function create_gclass(gclass_name)
|
|
|
5333
5396
|
const states = [
|
|
5334
5397
|
["ST_IDLE", [
|
|
5335
5398
|
["EV_LANGUAGE_CHANGED", ac_language_changed, null],
|
|
5399
|
+
["EV_ICONS_CHANGED", ac_icons_changed, null],
|
|
5336
5400
|
["EV_LOAD_NODES", ac_load_nodes, null],
|
|
5337
5401
|
["EV_LOAD_NODE_CREATED", ac_load_node_created, null],
|
|
5338
5402
|
["EV_LOAD_NODE_UPDATED", ac_load_node_updated, null],
|
|
@@ -5390,6 +5454,7 @@ function create_gclass(gclass_name)
|
|
|
5390
5454
|
*---------------------------------------------*/
|
|
5391
5455
|
const event_types = [
|
|
5392
5456
|
["EV_LANGUAGE_CHANGED", 0],
|
|
5457
|
+
["EV_ICONS_CHANGED", 0],
|
|
5393
5458
|
["EV_LOAD_NODES", 0],
|
|
5394
5459
|
["EV_LOAD_NODE_CREATED", 0],
|
|
5395
5460
|
["EV_LOAD_NODE_UPDATED", 0],
|