@yuneta/gobj-ui 7.32.10 → 7.32.11
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 +75 -0
- package/dist/gobj-ui.cjs.js +943 -358
- package/dist/gobj-ui.es.js +932 -359
- package/index.js +18 -0
- package/package.json +1 -1
- package/src/c_yui_node.js +47 -9
- package/src/c_yui_preferences.js +282 -0
- package/src/c_yui_shell.js +57 -1
- package/src/i18n_key_functions.js +6 -0
- package/src/preferences.wiring.test.js +159 -0
- package/src/yui_preferences.js +331 -0
package/index.js
CHANGED
|
@@ -63,8 +63,26 @@ export {
|
|
|
63
63
|
yui_shell_register_overlay,
|
|
64
64
|
yui_shell_overlay_dismissed,
|
|
65
65
|
yui_shell_unpark_route,
|
|
66
|
+
yui_shell_nav_mode,
|
|
67
|
+
yui_shell_set_nav_mode,
|
|
66
68
|
} from "./src/c_yui_shell.js";
|
|
67
69
|
export { register_c_yui_nav } from "./src/c_yui_nav.js";
|
|
70
|
+
/*
|
|
71
|
+
* Preferences: the page every app shows at /preferences (theme,
|
|
72
|
+
* language, navigation), whole or in parts.
|
|
73
|
+
*/
|
|
74
|
+
export { register_c_yui_preferences } from "./src/c_yui_preferences.js";
|
|
75
|
+
export {
|
|
76
|
+
YUI_PREFERENCES_I18N_KEYS,
|
|
77
|
+
yui_preferences_setup,
|
|
78
|
+
yui_pref_header,
|
|
79
|
+
yui_pref_box,
|
|
80
|
+
yui_pref_field,
|
|
81
|
+
yui_pref_segment,
|
|
82
|
+
yui_pref_appearance_fields,
|
|
83
|
+
yui_pref_sections,
|
|
84
|
+
yui_pref_apply,
|
|
85
|
+
} from "./src/yui_preferences.js";
|
|
68
86
|
/*
|
|
69
87
|
* Site map: the whole navigation surface (toolbar + account menu +
|
|
70
88
|
* nav + dynamic tabs + view-contributed sub-routes) as a clickable,
|
package/package.json
CHANGED
package/src/c_yui_node.js
CHANGED
|
@@ -144,6 +144,7 @@ import {
|
|
|
144
144
|
yui_shell_navigate,
|
|
145
145
|
yui_shell_set_sub_routes,
|
|
146
146
|
yui_shell_translate,
|
|
147
|
+
yui_shell_nav_mode,
|
|
147
148
|
} from "./c_yui_shell.js";
|
|
148
149
|
|
|
149
150
|
import "./c_yui_node.css";
|
|
@@ -180,7 +181,7 @@ SDATA(data_type_t.DTP_JSON, "children", 0, null, "Declared child spec
|
|
|
180
181
|
|
|
181
182
|
SDATA(data_type_t.DTP_STRING, "base_route", 0, "", "ROOT only: the declared route the whole tree hangs from"),
|
|
182
183
|
SDATA(data_type_t.DTP_STRING, "tree_version", 0, "", "ROOT only: version of the tree CONTRACT (its paths are public urls)"),
|
|
183
|
-
SDATA(data_type_t.DTP_STRING, "nav_mode", 0, "
|
|
184
|
+
SDATA(data_type_t.DTP_STRING, "nav_mode", 0, "", "ROOT only: how the way in is shown — stack|back|path. Empty: the reader's choice for the app, the shell's navigation preference (yui_shell_nav_mode), followed when it changes"),
|
|
184
185
|
SDATA(data_type_t.DTP_BOOLEAN, "remember_position", 0, false, "A nav item points at WHERE THE OPERATOR LEFT that child, not at its bare route: the tail last active under each child is remembered and appended. For a tree whose children are workspaces with a position inside them (a treedb and its open topic); off for one whose children are pages, where the item IS the destination"),
|
|
185
186
|
|
|
186
187
|
SDATA(data_type_t.DTP_POINTER, "$container", 0, null, "Root HTMLElement (shell view contract)"),
|
|
@@ -297,6 +298,9 @@ function mt_start(gobj)
|
|
|
297
298
|
return -1;
|
|
298
299
|
}
|
|
299
300
|
gobj_subscribe_event(shell, "EV_ROUTE_CHANGED", {}, gobj);
|
|
301
|
+
/* The reader's navigation preference: followed while the tree has
|
|
302
|
+
* no `nav_mode` of its own (ac_nav_mode_changed). */
|
|
303
|
+
gobj_subscribe_event(shell, "EV_NAV_MODE_CHANGED", {}, gobj);
|
|
300
304
|
publish_sub_routes(gobj);
|
|
301
305
|
}
|
|
302
306
|
|
|
@@ -311,6 +315,7 @@ function mt_stop(gobj)
|
|
|
311
315
|
let shell = yui_shell_of(gobj);
|
|
312
316
|
if(shell) {
|
|
313
317
|
gobj_unsubscribe_event(shell, "EV_ROUTE_CHANGED", {}, gobj);
|
|
318
|
+
gobj_unsubscribe_event(shell, "EV_NAV_MODE_CHANGED", {}, gobj);
|
|
314
319
|
yui_shell_set_sub_routes(shell, gobj_read_attr(gobj, "base_route"), null);
|
|
315
320
|
}
|
|
316
321
|
}
|
|
@@ -420,7 +425,13 @@ function tree_root_of(gobj)
|
|
|
420
425
|
************************************************************/
|
|
421
426
|
function nav_mode_of(gobj)
|
|
422
427
|
{
|
|
423
|
-
let
|
|
428
|
+
let root = tree_root_of(gobj);
|
|
429
|
+
let mode = gobj_read_attr(root, "nav_mode");
|
|
430
|
+
if(!mode) {
|
|
431
|
+
/* No mode of its own: the reader's, for the whole app (7.32.11). */
|
|
432
|
+
let shell = yui_shell_of(root);
|
|
433
|
+
mode = shell ? yui_shell_nav_mode(shell) : "stack";
|
|
434
|
+
}
|
|
424
435
|
|
|
425
436
|
if(!is_nav_mode(mode)) {
|
|
426
437
|
log_error(
|
|
@@ -1624,7 +1635,8 @@ function ac_set_nav_mode(gobj, event, kw, src)
|
|
|
1624
1635
|
let priv = gobj.priv;
|
|
1625
1636
|
let mode = kw.nav_mode || "";
|
|
1626
1637
|
|
|
1627
|
-
|
|
1638
|
+
/* "" is no mode of its own: follow the reader's (yui_shell_nav_mode). */
|
|
1639
|
+
if(mode !== "" && !is_nav_mode(mode)) {
|
|
1628
1640
|
log_error(
|
|
1629
1641
|
`${GCLASS_NAME} '${node_path_str(gobj)}': unknown nav_mode ` +
|
|
1630
1642
|
`'${mode}' — expected one of ${NAV_MODES.join("|")}`
|
|
@@ -1639,17 +1651,38 @@ function ac_set_nav_mode(gobj, event, kw, src)
|
|
|
1639
1651
|
return -1;
|
|
1640
1652
|
}
|
|
1641
1653
|
gobj_write_attr(gobj, "nav_mode", mode);
|
|
1654
|
+
reapply_route(gobj);
|
|
1655
|
+
return 0;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
/************************************************************
|
|
1659
|
+
* The reader chose another way in for the whole app (the shell's
|
|
1660
|
+
* EV_NAV_MODE_CHANGED, from Preferences). A root with a
|
|
1661
|
+
* `nav_mode` of its own keeps it: the host pinned it.
|
|
1662
|
+
************************************************************/
|
|
1663
|
+
function ac_nav_mode_changed(gobj, event, kw, src)
|
|
1664
|
+
{
|
|
1665
|
+
let priv = gobj.priv;
|
|
1666
|
+
if(!priv.is_root || gobj_read_attr(gobj, "nav_mode")) {
|
|
1667
|
+
return 0;
|
|
1668
|
+
}
|
|
1669
|
+
reapply_route(gobj);
|
|
1670
|
+
return 0;
|
|
1671
|
+
}
|
|
1642
1672
|
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1673
|
+
/************************************************************
|
|
1674
|
+
* Same reason as EV_SET_CHROME_DEPTH: what changes with the
|
|
1675
|
+
* mode is the shape of the ACTIVE PATH, whose strips are
|
|
1676
|
+
* painted by the ancestors, so the tree is asked to re-apply
|
|
1677
|
+
* the current route instead of repainting one node.
|
|
1678
|
+
************************************************************/
|
|
1679
|
+
function reapply_route(gobj)
|
|
1680
|
+
{
|
|
1647
1681
|
let shell = yui_shell_of(gobj);
|
|
1648
1682
|
if(shell) {
|
|
1649
1683
|
yui_shell_navigate(shell, gobj_read_attr(shell, "current_route") ||
|
|
1650
1684
|
route_of(gobj), {replace: true});
|
|
1651
1685
|
}
|
|
1652
|
-
return 0;
|
|
1653
1686
|
}
|
|
1654
1687
|
|
|
1655
1688
|
/************************************************************
|
|
@@ -1746,7 +1779,8 @@ function yui_node_set_nav_mode(node, mode)
|
|
|
1746
1779
|
|
|
1747
1780
|
function yui_node_nav_mode(node)
|
|
1748
1781
|
{
|
|
1749
|
-
|
|
1782
|
+
/* The mode the tree draws in: its own, else the reader's. */
|
|
1783
|
+
return nav_mode_of(node);
|
|
1750
1784
|
}
|
|
1751
1785
|
|
|
1752
1786
|
/************************************************************
|
|
@@ -1838,6 +1872,7 @@ function create_gclass(gclass_name)
|
|
|
1838
1872
|
["EV_SET_PROJECTION", ac_set_projection, null],
|
|
1839
1873
|
["EV_SET_CHROME_DEPTH", ac_set_chrome_depth, null],
|
|
1840
1874
|
["EV_SET_NAV_MODE", ac_set_nav_mode, null],
|
|
1875
|
+
["EV_NAV_MODE_CHANGED", ac_nav_mode_changed, null],
|
|
1841
1876
|
["EV_SET_CONTENT", ac_set_content, null],
|
|
1842
1877
|
["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
|
|
1843
1878
|
["EV_DESTROY_NAVS", ac_destroy_navs, null]
|
|
@@ -1854,6 +1889,7 @@ function create_gclass(gclass_name)
|
|
|
1854
1889
|
["EV_SET_PROJECTION", ac_set_projection, null],
|
|
1855
1890
|
["EV_SET_CHROME_DEPTH", ac_set_chrome_depth, null],
|
|
1856
1891
|
["EV_SET_NAV_MODE", ac_set_nav_mode, null],
|
|
1892
|
+
["EV_NAV_MODE_CHANGED", ac_nav_mode_changed, null],
|
|
1857
1893
|
["EV_SET_CONTENT", ac_set_content, null],
|
|
1858
1894
|
["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
|
|
1859
1895
|
["EV_DESTROY_NAVS", ac_destroy_navs, null]
|
|
@@ -1870,6 +1906,7 @@ function create_gclass(gclass_name)
|
|
|
1870
1906
|
["EV_SET_PROJECTION", ac_set_projection, null],
|
|
1871
1907
|
["EV_SET_CHROME_DEPTH", ac_set_chrome_depth, null],
|
|
1872
1908
|
["EV_SET_NAV_MODE", ac_set_nav_mode, null],
|
|
1909
|
+
["EV_NAV_MODE_CHANGED", ac_nav_mode_changed, null],
|
|
1873
1910
|
["EV_SET_CONTENT", ac_set_content, null],
|
|
1874
1911
|
["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
|
|
1875
1912
|
["EV_DESTROY_NAVS", ac_destroy_navs, null]
|
|
@@ -1891,6 +1928,7 @@ function create_gclass(gclass_name)
|
|
|
1891
1928
|
["EV_SET_PROJECTION", 0],
|
|
1892
1929
|
["EV_SET_CHROME_DEPTH", 0],
|
|
1893
1930
|
["EV_SET_NAV_MODE", 0],
|
|
1931
|
+
["EV_NAV_MODE_CHANGED", 0],
|
|
1894
1932
|
["EV_SET_CONTENT", 0],
|
|
1895
1933
|
["EV_NODE_TREE_CHANGED", 0],
|
|
1896
1934
|
/* internal: posted to itself, the navs a render left */
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* c_yui_preferences.js
|
|
3
|
+
* C_YUI_PREFERENCES GClass.
|
|
4
|
+
*
|
|
5
|
+
* The Preferences page of an app, whole: a view the shell
|
|
6
|
+
* mounts at /preferences (a route target of the app config).
|
|
7
|
+
*
|
|
8
|
+
* "/preferences": {"target": {"gclass": "C_YUI_PREFERENCES"}}
|
|
9
|
+
*
|
|
10
|
+
* It draws the three rows every app shows -- theme, language,
|
|
11
|
+
* navigation (yui_preferences.js) -- and then the boxes the
|
|
12
|
+
* app adds in its yui_preferences_setup(). A press applies at
|
|
13
|
+
* once and is kept in this browser; the page is drawn again
|
|
14
|
+
* to mark the new choice, and when the language changes from
|
|
15
|
+
* elsewhere (the toolbar), because which option is marked is
|
|
16
|
+
* markup.
|
|
17
|
+
*
|
|
18
|
+
* An app whose page has fields with actions of its own keeps
|
|
19
|
+
* its own view and draws the same rows with the parts of
|
|
20
|
+
* yui_preferences.js.
|
|
21
|
+
*
|
|
22
|
+
* Copyright (c) 2026, ArtGins.
|
|
23
|
+
* All Rights Reserved.
|
|
24
|
+
***********************************************************************/
|
|
25
|
+
import {
|
|
26
|
+
SDATA,
|
|
27
|
+
SDATA_END,
|
|
28
|
+
data_type_t,
|
|
29
|
+
gclass_create,
|
|
30
|
+
log_error,
|
|
31
|
+
gobj_parent,
|
|
32
|
+
gobj_read_attr,
|
|
33
|
+
gobj_write_attr,
|
|
34
|
+
gobj_read_pointer_attr,
|
|
35
|
+
gobj_subscribe_event,
|
|
36
|
+
gobj_unsubscribe_event,
|
|
37
|
+
createElement2,
|
|
38
|
+
refresh_language,
|
|
39
|
+
} from "@yuneta/gobj-js";
|
|
40
|
+
|
|
41
|
+
import {t} from "i18next";
|
|
42
|
+
|
|
43
|
+
import {yui_shell_of} from "./c_yui_shell.js";
|
|
44
|
+
import {
|
|
45
|
+
yui_pref_header,
|
|
46
|
+
yui_pref_box,
|
|
47
|
+
yui_pref_appearance_fields,
|
|
48
|
+
yui_pref_sections,
|
|
49
|
+
yui_pref_apply,
|
|
50
|
+
} from "./yui_preferences.js";
|
|
51
|
+
|
|
52
|
+
/***************************************************************
|
|
53
|
+
* Constants
|
|
54
|
+
***************************************************************/
|
|
55
|
+
const GCLASS_NAME = "C_YUI_PREFERENCES";
|
|
56
|
+
|
|
57
|
+
/***************************************************************
|
|
58
|
+
* Data
|
|
59
|
+
***************************************************************/
|
|
60
|
+
const attrs_table = [
|
|
61
|
+
SDATA(data_type_t.DTP_POINTER, "subscriber", 0, null, "Subscriber of output events"),
|
|
62
|
+
SDATA(data_type_t.DTP_POINTER, "$container", 0, null, "Root HTMLElement (shell view contract)"),
|
|
63
|
+
SDATA_END()
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* A field named like an attribute is written by the framework on every
|
|
68
|
+
* write of that attribute.
|
|
69
|
+
*/
|
|
70
|
+
let PRIVATE_DATA = {
|
|
71
|
+
shell: null,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
let __gclass__ = null;
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/******************************
|
|
80
|
+
* Framework Methods
|
|
81
|
+
******************************/
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
/***************************************************************
|
|
87
|
+
* Framework Method: Create
|
|
88
|
+
***************************************************************/
|
|
89
|
+
function mt_create(gobj)
|
|
90
|
+
{
|
|
91
|
+
let $container = createElement2(
|
|
92
|
+
["div", {class: "C_YUI_PREFERENCES PREF_PAGE p-4"}, []]
|
|
93
|
+
);
|
|
94
|
+
gobj_write_attr(gobj, "$container", $container);
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
* CHILD subscription model
|
|
98
|
+
*/
|
|
99
|
+
let subscriber = gobj_read_pointer_attr(gobj, "subscriber");
|
|
100
|
+
if(!subscriber) {
|
|
101
|
+
subscriber = gobj_parent(gobj);
|
|
102
|
+
}
|
|
103
|
+
gobj_subscribe_event(gobj, null, {}, subscriber);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/***************************************************************
|
|
107
|
+
* Framework Method: Start
|
|
108
|
+
***************************************************************/
|
|
109
|
+
function mt_start(gobj)
|
|
110
|
+
{
|
|
111
|
+
let priv = gobj.priv;
|
|
112
|
+
|
|
113
|
+
/* The language can change from the toolbar while the page is
|
|
114
|
+
* open: which option is marked is markup, drawn again. */
|
|
115
|
+
priv.shell = yui_shell_of(gobj);
|
|
116
|
+
if(priv.shell) {
|
|
117
|
+
gobj_subscribe_event(priv.shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
118
|
+
}
|
|
119
|
+
render(gobj);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/***************************************************************
|
|
123
|
+
* Framework Method: Stop
|
|
124
|
+
***************************************************************/
|
|
125
|
+
function mt_stop(gobj)
|
|
126
|
+
{
|
|
127
|
+
let priv = gobj.priv;
|
|
128
|
+
|
|
129
|
+
if(priv.shell) {
|
|
130
|
+
gobj_unsubscribe_event(priv.shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
131
|
+
priv.shell = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/***************************************************************
|
|
136
|
+
* Framework Method: Destroy
|
|
137
|
+
***************************************************************/
|
|
138
|
+
function mt_destroy(gobj)
|
|
139
|
+
{
|
|
140
|
+
let $container = gobj_read_attr(gobj, "$container");
|
|
141
|
+
if($container && $container.parentNode) {
|
|
142
|
+
$container.parentNode.removeChild($container);
|
|
143
|
+
}
|
|
144
|
+
gobj_write_attr(gobj, "$container", null);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
/***************************
|
|
151
|
+
* Local Methods
|
|
152
|
+
***************************/
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
/***************************************************************
|
|
158
|
+
* Draw the page: the header, the box of the three rows, the
|
|
159
|
+
* boxes of the app.
|
|
160
|
+
***************************************************************/
|
|
161
|
+
function render(gobj)
|
|
162
|
+
{
|
|
163
|
+
let $container = gobj_read_attr(gobj, "$container");
|
|
164
|
+
if(!$container) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
$container.replaceChildren();
|
|
168
|
+
$container.appendChild(createElement2(yui_pref_header()));
|
|
169
|
+
$container.appendChild(createElement2(
|
|
170
|
+
yui_pref_box(yui_pref_appearance_fields(gobj), "PREF_APPEARANCE")
|
|
171
|
+
));
|
|
172
|
+
for(let box of yui_pref_sections(gobj)) {
|
|
173
|
+
$container.appendChild((box && box.nodeType) ? box : createElement2(box));
|
|
174
|
+
}
|
|
175
|
+
refresh_language($container, t);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
/***************************
|
|
182
|
+
* Actions
|
|
183
|
+
***************************/
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
/***************************************************************
|
|
189
|
+
* EV_SET_THEME / EV_SET_LANGUAGE / EV_SET_NAV_MODE {value}:
|
|
190
|
+
* a press on one of the three rows.
|
|
191
|
+
***************************************************************/
|
|
192
|
+
function ac_set_preference(gobj, event, kw, src)
|
|
193
|
+
{
|
|
194
|
+
let ret = yui_pref_apply(gobj, event, kw);
|
|
195
|
+
render(gobj);
|
|
196
|
+
return ret;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/***************************************************************
|
|
200
|
+
* The language changed somewhere else (the toolbar).
|
|
201
|
+
***************************************************************/
|
|
202
|
+
function ac_language_changed(gobj, event, kw, src)
|
|
203
|
+
{
|
|
204
|
+
render(gobj);
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/***************************************************************
|
|
209
|
+
* FSM
|
|
210
|
+
***************************************************************/
|
|
211
|
+
/*---------------------------------------------*
|
|
212
|
+
* Global methods table
|
|
213
|
+
*---------------------------------------------*/
|
|
214
|
+
const gmt = {
|
|
215
|
+
mt_create: mt_create,
|
|
216
|
+
mt_start: mt_start,
|
|
217
|
+
mt_stop: mt_stop,
|
|
218
|
+
mt_destroy: mt_destroy
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/***************************************************************
|
|
222
|
+
* Create the GClass
|
|
223
|
+
***************************************************************/
|
|
224
|
+
function create_gclass(gclass_name)
|
|
225
|
+
{
|
|
226
|
+
if(__gclass__) {
|
|
227
|
+
log_error(`GClass ALREADY created: ${gclass_name}`);
|
|
228
|
+
return -1;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/*---------------------------------------------*
|
|
232
|
+
* States
|
|
233
|
+
*---------------------------------------------*/
|
|
234
|
+
const states = [
|
|
235
|
+
["ST_IDLE", [
|
|
236
|
+
["EV_SET_THEME", ac_set_preference, null],
|
|
237
|
+
["EV_SET_LANGUAGE", ac_set_preference, null],
|
|
238
|
+
["EV_SET_NAV_MODE", ac_set_preference, null],
|
|
239
|
+
["EV_LANGUAGE_CHANGED", ac_language_changed, null]
|
|
240
|
+
]]
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
/*---------------------------------------------*
|
|
244
|
+
* Events
|
|
245
|
+
*---------------------------------------------*/
|
|
246
|
+
const event_types = [
|
|
247
|
+
["EV_SET_THEME", 0],
|
|
248
|
+
["EV_SET_LANGUAGE", 0],
|
|
249
|
+
["EV_SET_NAV_MODE", 0],
|
|
250
|
+
["EV_LANGUAGE_CHANGED", 0]
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
__gclass__ = gclass_create(
|
|
254
|
+
gclass_name,
|
|
255
|
+
event_types,
|
|
256
|
+
states,
|
|
257
|
+
gmt,
|
|
258
|
+
0, // lmt,
|
|
259
|
+
attrs_table,
|
|
260
|
+
PRIVATE_DATA,
|
|
261
|
+
0, // authz_table,
|
|
262
|
+
0, // command_table,
|
|
263
|
+
0, // s_user_trace_level
|
|
264
|
+
0 // gclass_flag
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
if(!__gclass__) {
|
|
268
|
+
return -1;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/***************************************************************
|
|
275
|
+
* Register GClass
|
|
276
|
+
***************************************************************/
|
|
277
|
+
function register_c_yui_preferences()
|
|
278
|
+
{
|
|
279
|
+
return create_gclass(GCLASS_NAME);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export { register_c_yui_preferences };
|
package/src/c_yui_shell.js
CHANGED
|
@@ -49,8 +49,12 @@ import {
|
|
|
49
49
|
gobj_short_name,
|
|
50
50
|
gobj_is_destroying,
|
|
51
51
|
gobj_post_event,
|
|
52
|
+
kw_get_local_storage_value,
|
|
53
|
+
kw_set_local_storage_value,
|
|
52
54
|
} from "@yuneta/gobj-js";
|
|
53
55
|
|
|
56
|
+
import {NAV_MODES, is_nav_mode} from "./node_tree_model.js";
|
|
57
|
+
|
|
54
58
|
import {
|
|
55
59
|
BULMA_BP_ORDER,
|
|
56
60
|
breakpoints_from_expr,
|
|
@@ -4359,7 +4363,7 @@ function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
|
|
|
4359
4363
|
* EV_ICONS_CHANGED). So they reach only the subscribers that
|
|
4360
4364
|
* declare them. Every other event of the shell goes out as before.
|
|
4361
4365
|
***************************************************************/
|
|
4362
|
-
const OPTIONAL_EVENTS = new Set(["EV_CONNECTION_STATE", "EV_ICONS_CHANGED"]);
|
|
4366
|
+
const OPTIONAL_EVENTS = new Set(["EV_CONNECTION_STATE", "EV_ICONS_CHANGED", "EV_NAV_MODE_CHANGED"]);
|
|
4363
4367
|
|
|
4364
4368
|
function mt_publication_pre_filter(gobj, subs, event, kw)
|
|
4365
4369
|
{
|
|
@@ -4446,6 +4450,15 @@ function create_gclass(gclass_name)
|
|
|
4446
4450
|
* icon cell of a table -- has to decide again. Delivered only to
|
|
4447
4451
|
* the subscribers that declare it: see
|
|
4448
4452
|
* mt_publication_pre_filter(). */
|
|
4453
|
+
/* The reader chose another way in for the trees of nodes
|
|
4454
|
+
* (yui_shell_set_nav_mode, the Navigation row of Preferences).
|
|
4455
|
+
* Every C_YUI_NODE root that has no mode of its own follows it.
|
|
4456
|
+
* Delivered only to the subscribers that declare it: see
|
|
4457
|
+
* mt_publication_pre_filter(). */
|
|
4458
|
+
["EV_NAV_MODE_CHANGED", event_flag_t.EVF_OUTPUT_EVENT
|
|
4459
|
+
|event_flag_t.EVF_PUBLIC_EVENT
|
|
4460
|
+
|event_flag_t.EVF_NO_WARN_SUBS],
|
|
4461
|
+
|
|
4449
4462
|
["EV_ICONS_CHANGED", event_flag_t.EVF_OUTPUT_EVENT
|
|
4450
4463
|
|event_flag_t.EVF_PUBLIC_EVENT
|
|
4451
4464
|
|event_flag_t.EVF_NO_WARN_SUBS],
|
|
@@ -5159,6 +5172,47 @@ function yui_shell_language_changed(shell_gobj)
|
|
|
5159
5172
|
gobj_publish_event(shell_gobj, "EV_LANGUAGE_CHANGED", {});
|
|
5160
5173
|
}
|
|
5161
5174
|
|
|
5175
|
+
/************************************************************
|
|
5176
|
+
* How the trees of nodes show the way in: the reader's choice
|
|
5177
|
+
* for the whole app, one of NAV_MODES (C_YUI_NODE):
|
|
5178
|
+
*
|
|
5179
|
+
* "stack" a strip of tabs per level, stacked (the default)
|
|
5180
|
+
* "back" one "back to parent" link
|
|
5181
|
+
* "path" a breadcrumb
|
|
5182
|
+
*
|
|
5183
|
+
* Kept in this browser (localStorage), like the theme and the
|
|
5184
|
+
* language. Every C_YUI_NODE root that has no `nav_mode` of its
|
|
5185
|
+
* own reads it, and follows a change: yui_shell_set_nav_mode()
|
|
5186
|
+
* publishes EV_NAV_MODE_CHANGED. Up to gobj-ui 7.32.10 each app
|
|
5187
|
+
* kept its own (gui_agent one for the app, yunovatios one per
|
|
5188
|
+
* tree) and handed it to its trees.
|
|
5189
|
+
************************************************************/
|
|
5190
|
+
const NAV_MODE_KEY = "yui_nav_mode";
|
|
5191
|
+
|
|
5192
|
+
function yui_shell_nav_mode(shell_gobj)
|
|
5193
|
+
{
|
|
5194
|
+
let mode = kw_get_local_storage_value(NAV_MODE_KEY, NAV_MODES[0], false);
|
|
5195
|
+
return is_nav_mode(mode) ? mode : NAV_MODES[0];
|
|
5196
|
+
}
|
|
5197
|
+
|
|
5198
|
+
function yui_shell_set_nav_mode(shell_gobj, mode)
|
|
5199
|
+
{
|
|
5200
|
+
if(!shell_gobj || !is_gobj(shell_gobj)) {
|
|
5201
|
+
log_error(`yui_shell_set_nav_mode(): no shell`);
|
|
5202
|
+
return -1;
|
|
5203
|
+
}
|
|
5204
|
+
if(!is_nav_mode(mode)) {
|
|
5205
|
+
log_error(`yui_shell_set_nav_mode(): unknown nav_mode '${mode}' — ` +
|
|
5206
|
+
`expected one of ${NAV_MODES.join("|")}`);
|
|
5207
|
+
return -1;
|
|
5208
|
+
}
|
|
5209
|
+
if(kw_set_local_storage_value(NAV_MODE_KEY, mode) < 0) {
|
|
5210
|
+
return -1; // Error already logged
|
|
5211
|
+
}
|
|
5212
|
+
gobj_publish_event(shell_gobj, "EV_NAV_MODE_CHANGED", {nav_mode: mode});
|
|
5213
|
+
return 0;
|
|
5214
|
+
}
|
|
5215
|
+
|
|
5162
5216
|
/************************************************************
|
|
5163
5217
|
* The user icons changed (lib_icons.js: yui_icons_set_user,
|
|
5164
5218
|
* yui_icons_put_user, yui_icons_remove_user): PUBLISH it, so
|
|
@@ -5415,6 +5469,8 @@ export {
|
|
|
5415
5469
|
yui_shell_set_translator,
|
|
5416
5470
|
yui_shell_translate,
|
|
5417
5471
|
yui_shell_language_changed,
|
|
5472
|
+
yui_shell_nav_mode,
|
|
5473
|
+
yui_shell_set_nav_mode,
|
|
5418
5474
|
yui_shell_icons_changed,
|
|
5419
5475
|
yui_shell_set_connection_state,
|
|
5420
5476
|
yui_shell_set_toolbar_item_icon,
|
|
@@ -313,4 +313,10 @@ export const I18N_KEY_FUNCTIONS = Object.freeze([
|
|
|
313
313
|
{module: "c_yui_shell.js", name: "announce_badge", exported: false, keys: ["1"]},
|
|
314
314
|
/* shell_route_map.js -- a node of the route map */
|
|
315
315
|
{module: "shell_route_map.js", name: "render_node", exported: false, keys: ["0.label"]},
|
|
316
|
+
/* yui_preferences.js -- the parts of a Preferences page an app
|
|
317
|
+
* uses for its own fields: the label of a field, the options of a
|
|
318
|
+
* segment (an option with a `text` and no `key` is data: a
|
|
319
|
+
* language named in its own words) */
|
|
320
|
+
{module: "yui_preferences.js", name: "yui_pref_field", exported: true, keys: ["0"]},
|
|
321
|
+
{module: "yui_preferences.js", name: "yui_pref_segment", exported: true, keys: ["2[].key"]},
|
|
316
322
|
]);
|