@yuneta/gobj-ui 7.27.19 → 7.27.21
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 +14 -0
- package/dist/gobj-ui.cjs.js +51 -2
- package/dist/gobj-ui.es.js +51 -2
- package/package.json +1 -1
- package/src/c_yui_node.js +66 -2
- package/src/c_yui_service_view.js +35 -2
- package/src/c_yui_shell.js +25 -2
- package/src/c_yui_treedb_topic_with_form.js +22 -1
- package/src/shell_view_shown.wiring.test.js +192 -0
package/README.md
CHANGED
|
@@ -598,6 +598,20 @@ Back out of a deep data position land on it. Below a link there are no nodes:
|
|
|
598
598
|
`link` + `children` (or `link` + `content`) is a config error, because a silent
|
|
599
599
|
winner in "who owns the subpath" would be the worst outcome.
|
|
600
600
|
|
|
601
|
+
**A child already on screen stays in the document** (7.27.20+). Every change of
|
|
602
|
+
url below a node re-activates it, and the node used to hang its active child
|
|
603
|
+
again each time -- out of the document and back in, which a browser answers by
|
|
604
|
+
dropping the scroll of every element inside it. A topic table under a treedb
|
|
605
|
+
view came back at the top of a page whose rows were drawn for the bottom, and
|
|
606
|
+
showed nothing. Now only the node's chrome (navs, path) is rebuilt when the
|
|
607
|
+
active child is the one already hanging in its body.
|
|
608
|
+
|
|
609
|
+
**A content shown again is told so** (7.27.21+). A node keeps the content it
|
|
610
|
+
built, as the shell keeps a `keep_alive` view, so a content that reads its data
|
|
611
|
+
only when it is created declares `EV_VIEW_SHOWN` and reads it again there: the
|
|
612
|
+
node sends it when it comes back to that content, and forwards the shell's down
|
|
613
|
+
its path when the whole tree is shown again (SHELL.md §4).
|
|
614
|
+
|
|
601
615
|
**The tree is a contract, not runtime state.** Once published, a node's path
|
|
602
616
|
is a url a client may have bookmarked, scripted, or been sold as another door
|
|
603
617
|
into the system. So there is deliberately **no reparent/move API**: the shape
|
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -1691,6 +1691,7 @@ function build_ui$19(gobj) {
|
|
|
1691
1691
|
priv.stages[stage_name] = {
|
|
1692
1692
|
el: priv.zones[zone],
|
|
1693
1693
|
items: {},
|
|
1694
|
+
shown: {},
|
|
1694
1695
|
active_route: null
|
|
1695
1696
|
};
|
|
1696
1697
|
if (priv.zones[zone]) priv.zones[zone].classList.add("yui-stage", `yui-stage-${stage_name}`);
|
|
@@ -1704,6 +1705,7 @@ function build_ui$19(gobj) {
|
|
|
1704
1705
|
priv.stages[name] = {
|
|
1705
1706
|
el: priv.zones[id],
|
|
1706
1707
|
items: {},
|
|
1708
|
+
shown: {},
|
|
1707
1709
|
active_route: null
|
|
1708
1710
|
};
|
|
1709
1711
|
if (priv.zones[id]) priv.zones[id].classList.add("yui-stage", `yui-stage-${name}`);
|
|
@@ -1714,6 +1716,7 @@ function build_ui$19(gobj) {
|
|
|
1714
1716
|
priv.stages.main = {
|
|
1715
1717
|
el: priv.zones.center,
|
|
1716
1718
|
items: {},
|
|
1719
|
+
shown: {},
|
|
1717
1720
|
active_route: null
|
|
1718
1721
|
};
|
|
1719
1722
|
priv.zones.center.classList.add("yui-stage", "yui-stage-main");
|
|
@@ -2102,9 +2105,11 @@ function navigate_to(gobj, route, depth, no_drain) {
|
|
|
2102
2105
|
}
|
|
2103
2106
|
if ($prev && $prev.parentNode) $prev.parentNode.removeChild($prev);
|
|
2104
2107
|
delete stage.items[prev_route];
|
|
2108
|
+
delete stage.shown[prev_route];
|
|
2105
2109
|
}
|
|
2106
2110
|
}
|
|
2107
2111
|
let cur = stage.items[matched_route];
|
|
2112
|
+
let reshown = !!cur && !!stage.shown[matched_route] && prev_route !== matched_route;
|
|
2108
2113
|
if (!cur) {
|
|
2109
2114
|
cur = build_view_gobj(gobj, entry, matched_route, stage);
|
|
2110
2115
|
if (!cur) return;
|
|
@@ -2113,6 +2118,7 @@ function navigate_to(gobj, route, depth, no_drain) {
|
|
|
2113
2118
|
let $c = (0, _yuneta_gobj_js.gobj_read_attr)(cur, "$container");
|
|
2114
2119
|
if ($c) $c.classList.remove("is-hidden");
|
|
2115
2120
|
stage.active_route = matched_route;
|
|
2121
|
+
stage.shown[matched_route] = true;
|
|
2116
2122
|
(0, _yuneta_gobj_js.gobj_write_attr)(gobj, "current_route", route);
|
|
2117
2123
|
remember_position(gobj, route);
|
|
2118
2124
|
remember_route(gobj, route);
|
|
@@ -2138,6 +2144,11 @@ function navigate_to(gobj, route, depth, no_drain) {
|
|
|
2138
2144
|
stage: stage_name,
|
|
2139
2145
|
menu_id: entry.menu_id || ""
|
|
2140
2146
|
});
|
|
2147
|
+
if (reshown && (0, _yuneta_gobj_js.gobj_has_event)(cur, "EV_VIEW_SHOWN")) (0, _yuneta_gobj_js.gobj_send_event)(cur, "EV_VIEW_SHOWN", {
|
|
2148
|
+
route,
|
|
2149
|
+
base: matched_route,
|
|
2150
|
+
subpath
|
|
2151
|
+
}, gobj);
|
|
2141
2152
|
}
|
|
2142
2153
|
function build_view_gobj(gobj, entry, route, stage) {
|
|
2143
2154
|
let priv = gobj.priv;
|
|
@@ -26388,6 +26399,10 @@ function register_c_yui_gobj_tree_js() {
|
|
|
26388
26399
|
* - flags EVF_PUBLIC_EVENT on what arrives from the backend
|
|
26389
26400
|
* (EV_MT_COMMAND_ANSWER and anything the remote publishes): the
|
|
26390
26401
|
* ievent drops events that are not public.
|
|
26402
|
+
* - MAY declare EV_VIEW_SHOWN: the shell (or a C_YUI_NODE) sends
|
|
26403
|
+
* it here when it shows a hidden view again, and this host
|
|
26404
|
+
* hands it on -- the place to read again the data the view
|
|
26405
|
+
* read only when it was created.
|
|
26391
26406
|
*
|
|
26392
26407
|
* NAMES: the service name must be UNIQUE per mount. A duplicate is
|
|
26393
26408
|
* not fatal and that is the danger — gobj-js logs "service ALREADY
|
|
@@ -26553,6 +26568,18 @@ function mt_destroy$8(gobj) {
|
|
|
26553
26568
|
(0, _yuneta_gobj_js.gobj_write_attr)(gobj, "$container", null);
|
|
26554
26569
|
}
|
|
26555
26570
|
/***************************
|
|
26571
|
+
* Actions
|
|
26572
|
+
***************************/
|
|
26573
|
+
/************************************************************
|
|
26574
|
+
* The shell shows me again after hiding me (`keep_alive`):
|
|
26575
|
+
* the hosted view is the one that may want to know.
|
|
26576
|
+
************************************************************/
|
|
26577
|
+
function ac_view_shown(gobj, event, kw, src) {
|
|
26578
|
+
const view = gobj.priv.view;
|
|
26579
|
+
if (view && (0, _yuneta_gobj_js.gobj_has_event)(view, event)) (0, _yuneta_gobj_js.gobj_send_event)(view, event, kw, gobj);
|
|
26580
|
+
return 0;
|
|
26581
|
+
}
|
|
26582
|
+
/***************************
|
|
26556
26583
|
* FSM
|
|
26557
26584
|
***************************/
|
|
26558
26585
|
var gmt$8 = {
|
|
@@ -26566,7 +26593,11 @@ function create_gclass$8(gclass_name) {
|
|
|
26566
26593
|
(0, _yuneta_gobj_js.log_error)(`GClass ALREADY created: ${gclass_name}`);
|
|
26567
26594
|
return -1;
|
|
26568
26595
|
}
|
|
26569
|
-
__gclass__$8 = (0, _yuneta_gobj_js.gclass_create)(gclass_name, [], [["ST_IDLE", [
|
|
26596
|
+
__gclass__$8 = (0, _yuneta_gobj_js.gclass_create)(gclass_name, [["EV_VIEW_SHOWN", 0]], [["ST_IDLE", [[
|
|
26597
|
+
"EV_VIEW_SHOWN",
|
|
26598
|
+
ac_view_shown,
|
|
26599
|
+
null
|
|
26600
|
+
]]]], gmt$8, 0, attrs_table$8, PRIVATE_DATA$8, 0, 0, 0, 0);
|
|
26570
26601
|
return __gclass__$8 ? 0 : -1;
|
|
26571
26602
|
}
|
|
26572
26603
|
function register_c_yui_service_view() {
|
|
@@ -33319,6 +33350,16 @@ function watch_table_size(gobj, tabulator) {
|
|
|
33319
33350
|
});
|
|
33320
33351
|
ro.observe(tabulator.element);
|
|
33321
33352
|
priv.table_resize_observer = ro;
|
|
33353
|
+
priv.table_scroll = {
|
|
33354
|
+
top: 0,
|
|
33355
|
+
left: 0
|
|
33356
|
+
};
|
|
33357
|
+
tabulator.on("scrollVertical", (top) => {
|
|
33358
|
+
priv.table_scroll.top = top;
|
|
33359
|
+
});
|
|
33360
|
+
tabulator.on("scrollHorizontal", (left) => {
|
|
33361
|
+
priv.table_scroll.left = left;
|
|
33362
|
+
});
|
|
33322
33363
|
}
|
|
33323
33364
|
function unwatch_table_size(gobj) {
|
|
33324
33365
|
let priv = gobj.priv;
|
|
@@ -35798,7 +35839,8 @@ function close_table_json_dialog(gobj) {
|
|
|
35798
35839
|
* another tab.
|
|
35799
35840
|
*
|
|
35800
35841
|
* The redraw is done when the table is SEEN again, where the
|
|
35801
|
-
* rows have their real offsets
|
|
35842
|
+
* rows have their real offsets, after giving back the scroll the
|
|
35843
|
+
* browser dropped with the `display:none` (watch_table_size). It is
|
|
35802
35844
|
* needed there even at the same size: Tabulator does not draw
|
|
35803
35845
|
* the data that arrives while it is hidden (a node event, a
|
|
35804
35846
|
* refresh), it leaves that to its next sight.
|
|
@@ -35826,6 +35868,13 @@ function ac_table_resized(gobj, event, kw, src) {
|
|
|
35826
35868
|
tabulator.redraw(true);
|
|
35827
35869
|
return 0;
|
|
35828
35870
|
}
|
|
35871
|
+
if (was_hidden) {
|
|
35872
|
+
let $holder = tabulator.element.querySelector(".tabulator-tableholder");
|
|
35873
|
+
if ($holder) {
|
|
35874
|
+
$holder.scrollTop = priv.table_scroll.top;
|
|
35875
|
+
$holder.scrollLeft = priv.table_scroll.left;
|
|
35876
|
+
}
|
|
35877
|
+
}
|
|
35829
35878
|
if (was_hidden || last.width !== kw.width || last.height !== kw.height) tabulator.redraw();
|
|
35830
35879
|
return 0;
|
|
35831
35880
|
}
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -1686,6 +1686,7 @@ function build_ui$19(gobj) {
|
|
|
1686
1686
|
priv.stages[stage_name] = {
|
|
1687
1687
|
el: priv.zones[zone],
|
|
1688
1688
|
items: {},
|
|
1689
|
+
shown: {},
|
|
1689
1690
|
active_route: null
|
|
1690
1691
|
};
|
|
1691
1692
|
if (priv.zones[zone]) priv.zones[zone].classList.add("yui-stage", `yui-stage-${stage_name}`);
|
|
@@ -1699,6 +1700,7 @@ function build_ui$19(gobj) {
|
|
|
1699
1700
|
priv.stages[name] = {
|
|
1700
1701
|
el: priv.zones[id],
|
|
1701
1702
|
items: {},
|
|
1703
|
+
shown: {},
|
|
1702
1704
|
active_route: null
|
|
1703
1705
|
};
|
|
1704
1706
|
if (priv.zones[id]) priv.zones[id].classList.add("yui-stage", `yui-stage-${name}`);
|
|
@@ -1709,6 +1711,7 @@ function build_ui$19(gobj) {
|
|
|
1709
1711
|
priv.stages.main = {
|
|
1710
1712
|
el: priv.zones.center,
|
|
1711
1713
|
items: {},
|
|
1714
|
+
shown: {},
|
|
1712
1715
|
active_route: null
|
|
1713
1716
|
};
|
|
1714
1717
|
priv.zones.center.classList.add("yui-stage", "yui-stage-main");
|
|
@@ -2097,9 +2100,11 @@ function navigate_to(gobj, route, depth, no_drain) {
|
|
|
2097
2100
|
}
|
|
2098
2101
|
if ($prev && $prev.parentNode) $prev.parentNode.removeChild($prev);
|
|
2099
2102
|
delete stage.items[prev_route];
|
|
2103
|
+
delete stage.shown[prev_route];
|
|
2100
2104
|
}
|
|
2101
2105
|
}
|
|
2102
2106
|
let cur = stage.items[matched_route];
|
|
2107
|
+
let reshown = !!cur && !!stage.shown[matched_route] && prev_route !== matched_route;
|
|
2103
2108
|
if (!cur) {
|
|
2104
2109
|
cur = build_view_gobj(gobj, entry, matched_route, stage);
|
|
2105
2110
|
if (!cur) return;
|
|
@@ -2108,6 +2113,7 @@ function navigate_to(gobj, route, depth, no_drain) {
|
|
|
2108
2113
|
let $c = gobj_read_attr(cur, "$container");
|
|
2109
2114
|
if ($c) $c.classList.remove("is-hidden");
|
|
2110
2115
|
stage.active_route = matched_route;
|
|
2116
|
+
stage.shown[matched_route] = true;
|
|
2111
2117
|
gobj_write_attr(gobj, "current_route", route);
|
|
2112
2118
|
remember_position(gobj, route);
|
|
2113
2119
|
remember_route(gobj, route);
|
|
@@ -2133,6 +2139,11 @@ function navigate_to(gobj, route, depth, no_drain) {
|
|
|
2133
2139
|
stage: stage_name,
|
|
2134
2140
|
menu_id: entry.menu_id || ""
|
|
2135
2141
|
});
|
|
2142
|
+
if (reshown && gobj_has_event(cur, "EV_VIEW_SHOWN")) gobj_send_event(cur, "EV_VIEW_SHOWN", {
|
|
2143
|
+
route,
|
|
2144
|
+
base: matched_route,
|
|
2145
|
+
subpath
|
|
2146
|
+
}, gobj);
|
|
2136
2147
|
}
|
|
2137
2148
|
function build_view_gobj(gobj, entry, route, stage) {
|
|
2138
2149
|
let priv = gobj.priv;
|
|
@@ -26383,6 +26394,10 @@ function register_c_yui_gobj_tree_js() {
|
|
|
26383
26394
|
* - flags EVF_PUBLIC_EVENT on what arrives from the backend
|
|
26384
26395
|
* (EV_MT_COMMAND_ANSWER and anything the remote publishes): the
|
|
26385
26396
|
* ievent drops events that are not public.
|
|
26397
|
+
* - MAY declare EV_VIEW_SHOWN: the shell (or a C_YUI_NODE) sends
|
|
26398
|
+
* it here when it shows a hidden view again, and this host
|
|
26399
|
+
* hands it on -- the place to read again the data the view
|
|
26400
|
+
* read only when it was created.
|
|
26386
26401
|
*
|
|
26387
26402
|
* NAMES: the service name must be UNIQUE per mount. A duplicate is
|
|
26388
26403
|
* not fatal and that is the danger — gobj-js logs "service ALREADY
|
|
@@ -26548,6 +26563,18 @@ function mt_destroy$8(gobj) {
|
|
|
26548
26563
|
gobj_write_attr(gobj, "$container", null);
|
|
26549
26564
|
}
|
|
26550
26565
|
/***************************
|
|
26566
|
+
* Actions
|
|
26567
|
+
***************************/
|
|
26568
|
+
/************************************************************
|
|
26569
|
+
* The shell shows me again after hiding me (`keep_alive`):
|
|
26570
|
+
* the hosted view is the one that may want to know.
|
|
26571
|
+
************************************************************/
|
|
26572
|
+
function ac_view_shown(gobj, event, kw, src) {
|
|
26573
|
+
const view = gobj.priv.view;
|
|
26574
|
+
if (view && gobj_has_event(view, event)) gobj_send_event(view, event, kw, gobj);
|
|
26575
|
+
return 0;
|
|
26576
|
+
}
|
|
26577
|
+
/***************************
|
|
26551
26578
|
* FSM
|
|
26552
26579
|
***************************/
|
|
26553
26580
|
var gmt$8 = {
|
|
@@ -26561,7 +26588,11 @@ function create_gclass$8(gclass_name) {
|
|
|
26561
26588
|
log_error(`GClass ALREADY created: ${gclass_name}`);
|
|
26562
26589
|
return -1;
|
|
26563
26590
|
}
|
|
26564
|
-
__gclass__$8 = gclass_create(gclass_name, [], [["ST_IDLE", [
|
|
26591
|
+
__gclass__$8 = gclass_create(gclass_name, [["EV_VIEW_SHOWN", 0]], [["ST_IDLE", [[
|
|
26592
|
+
"EV_VIEW_SHOWN",
|
|
26593
|
+
ac_view_shown,
|
|
26594
|
+
null
|
|
26595
|
+
]]]], gmt$8, 0, attrs_table$8, PRIVATE_DATA$8, 0, 0, 0, 0);
|
|
26565
26596
|
return __gclass__$8 ? 0 : -1;
|
|
26566
26597
|
}
|
|
26567
26598
|
function register_c_yui_service_view() {
|
|
@@ -33314,6 +33345,16 @@ function watch_table_size(gobj, tabulator) {
|
|
|
33314
33345
|
});
|
|
33315
33346
|
ro.observe(tabulator.element);
|
|
33316
33347
|
priv.table_resize_observer = ro;
|
|
33348
|
+
priv.table_scroll = {
|
|
33349
|
+
top: 0,
|
|
33350
|
+
left: 0
|
|
33351
|
+
};
|
|
33352
|
+
tabulator.on("scrollVertical", (top) => {
|
|
33353
|
+
priv.table_scroll.top = top;
|
|
33354
|
+
});
|
|
33355
|
+
tabulator.on("scrollHorizontal", (left) => {
|
|
33356
|
+
priv.table_scroll.left = left;
|
|
33357
|
+
});
|
|
33317
33358
|
}
|
|
33318
33359
|
function unwatch_table_size(gobj) {
|
|
33319
33360
|
let priv = gobj.priv;
|
|
@@ -35793,7 +35834,8 @@ function close_table_json_dialog(gobj) {
|
|
|
35793
35834
|
* another tab.
|
|
35794
35835
|
*
|
|
35795
35836
|
* The redraw is done when the table is SEEN again, where the
|
|
35796
|
-
* rows have their real offsets
|
|
35837
|
+
* rows have their real offsets, after giving back the scroll the
|
|
35838
|
+
* browser dropped with the `display:none` (watch_table_size). It is
|
|
35797
35839
|
* needed there even at the same size: Tabulator does not draw
|
|
35798
35840
|
* the data that arrives while it is hidden (a node event, a
|
|
35799
35841
|
* refresh), it leaves that to its next sight.
|
|
@@ -35821,6 +35863,13 @@ function ac_table_resized(gobj, event, kw, src) {
|
|
|
35821
35863
|
tabulator.redraw(true);
|
|
35822
35864
|
return 0;
|
|
35823
35865
|
}
|
|
35866
|
+
if (was_hidden) {
|
|
35867
|
+
let $holder = tabulator.element.querySelector(".tabulator-tableholder");
|
|
35868
|
+
if ($holder) {
|
|
35869
|
+
$holder.scrollTop = priv.table_scroll.top;
|
|
35870
|
+
$holder.scrollLeft = priv.table_scroll.left;
|
|
35871
|
+
}
|
|
35872
|
+
}
|
|
35824
35873
|
if (was_hidden || last.width !== kw.width || last.height !== kw.height) tabulator.redraw();
|
|
35825
35874
|
return 0;
|
|
35826
35875
|
}
|
package/package.json
CHANGED
package/src/c_yui_node.js
CHANGED
|
@@ -113,6 +113,7 @@ import {
|
|
|
113
113
|
gobj_unsubscribe_event,
|
|
114
114
|
gobj_send_event,
|
|
115
115
|
gobj_post_event,
|
|
116
|
+
gobj_has_event,
|
|
116
117
|
gobj_change_state,
|
|
117
118
|
gobj_current_state,
|
|
118
119
|
createElement2,
|
|
@@ -931,10 +932,25 @@ function render_self(gobj)
|
|
|
931
932
|
function render_child(gobj, child)
|
|
932
933
|
{
|
|
933
934
|
let priv = gobj.priv;
|
|
935
|
+
let $child = gobj_read_attr(child, "$container");
|
|
936
|
+
|
|
937
|
+
/* The child already hanging in my body is left where it is: only
|
|
938
|
+
* the chrome (the navs, the path) follows the route. Every change
|
|
939
|
+
* of url below me -- a tab of a treedb view is one -- re-activates
|
|
940
|
+
* this level, and re-hanging the child took its whole subtree out
|
|
941
|
+
* of the document and put it back, which drops the scroll of every
|
|
942
|
+
* element in it: a table came back at 0 with its rows still drawn
|
|
943
|
+
* for where the reader was, and showed only the padding above
|
|
944
|
+
* them. */
|
|
945
|
+
let in_place = !!$child && !!$child.parentNode &&
|
|
946
|
+
$child.parentNode.classList.contains("NODE_CHILD") &&
|
|
947
|
+
$child.parentNode.parentNode === priv.$body;
|
|
934
948
|
|
|
935
949
|
clear_navs(gobj);
|
|
936
950
|
priv.$chrome.replaceChildren();
|
|
937
|
-
|
|
951
|
+
if(!in_place) {
|
|
952
|
+
priv.$body.replaceChildren();
|
|
953
|
+
}
|
|
938
954
|
|
|
939
955
|
/* Every ancestor painting its own chrome stacks one strip per
|
|
940
956
|
* level. `chrome_depth` is how a node caps that for its corner
|
|
@@ -948,8 +964,10 @@ function render_child(gobj, child)
|
|
|
948
964
|
}
|
|
949
965
|
render_path(gobj, priv.$chrome);
|
|
950
966
|
|
|
967
|
+
if(in_place) {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
951
970
|
let $slot = createElement2(["div", {class: "NODE_CHILD"}]);
|
|
952
|
-
let $child = gobj_read_attr(child, "$container");
|
|
953
971
|
if($child) {
|
|
954
972
|
$slot.appendChild($child);
|
|
955
973
|
}
|
|
@@ -1053,6 +1071,9 @@ function activate(gobj, subpath, inherited_depth)
|
|
|
1053
1071
|
{
|
|
1054
1072
|
let priv = gobj.priv;
|
|
1055
1073
|
let {head, tail} = head_tail(subpath);
|
|
1074
|
+
/* Coming back to a content I already built: it is told (EV_VIEW_SHOWN) */
|
|
1075
|
+
let back_to_content = !!priv.content_gobj &&
|
|
1076
|
+
gobj_current_state(gobj) !== "ST_SELF";
|
|
1056
1077
|
|
|
1057
1078
|
let info = resolve_path_info(gobj, subpath, inherited_depth);
|
|
1058
1079
|
priv.distance = info.distance;
|
|
@@ -1083,6 +1104,9 @@ function activate(gobj, subpath, inherited_depth)
|
|
|
1083
1104
|
render_self(gobj);
|
|
1084
1105
|
}
|
|
1085
1106
|
forward_subpath(gobj, subpath);
|
|
1107
|
+
if(back_to_content) {
|
|
1108
|
+
tell_content_shown(gobj);
|
|
1109
|
+
}
|
|
1086
1110
|
return "ST_SELF";
|
|
1087
1111
|
}
|
|
1088
1112
|
|
|
@@ -1092,6 +1116,9 @@ function activate(gobj, subpath, inherited_depth)
|
|
|
1092
1116
|
priv.active_child = null;
|
|
1093
1117
|
}
|
|
1094
1118
|
render_self(gobj);
|
|
1119
|
+
if(back_to_content) {
|
|
1120
|
+
tell_content_shown(gobj);
|
|
1121
|
+
}
|
|
1095
1122
|
return "ST_SELF";
|
|
1096
1123
|
}
|
|
1097
1124
|
|
|
@@ -1144,6 +1171,21 @@ function activate(gobj, subpath, inherited_depth)
|
|
|
1144
1171
|
return "ST_CHILD";
|
|
1145
1172
|
}
|
|
1146
1173
|
|
|
1174
|
+
/************************************************************
|
|
1175
|
+
* My content is on screen again after being hidden: a node
|
|
1176
|
+
* keeps the content it built, as the shell keeps a
|
|
1177
|
+
* `keep_alive` view, so the content may want to read again
|
|
1178
|
+
* what it read when it was created. Only a content that
|
|
1179
|
+
* declares EV_VIEW_SHOWN is told.
|
|
1180
|
+
************************************************************/
|
|
1181
|
+
function tell_content_shown(gobj)
|
|
1182
|
+
{
|
|
1183
|
+
let content = gobj.priv.content_gobj;
|
|
1184
|
+
if(content && gobj_has_event(content, "EV_VIEW_SHOWN")) {
|
|
1185
|
+
gobj_send_event(content, "EV_VIEW_SHOWN", {route: route_of(gobj)}, gobj);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1147
1189
|
/************************************************************
|
|
1148
1190
|
* Hand the data tail to the viewer, in the SAME shape the shell
|
|
1149
1191
|
* gives a view (ROUTING.md §5): `base` is this node's canonical
|
|
@@ -1278,6 +1320,24 @@ function ac_activate(gobj, event, kw, src)
|
|
|
1278
1320
|
return 0;
|
|
1279
1321
|
}
|
|
1280
1322
|
|
|
1323
|
+
/************************************************************
|
|
1324
|
+
* The shell (or my parent) shows the tree again after hiding
|
|
1325
|
+
* it: down the path to the node on screen, which tells its
|
|
1326
|
+
* content.
|
|
1327
|
+
************************************************************/
|
|
1328
|
+
function ac_view_shown(gobj, event, kw, src)
|
|
1329
|
+
{
|
|
1330
|
+
let priv = gobj.priv;
|
|
1331
|
+
if(gobj_current_state(gobj) === "ST_CHILD") {
|
|
1332
|
+
if(priv.active_child) {
|
|
1333
|
+
gobj_send_event(priv.active_child, event, kw, gobj);
|
|
1334
|
+
}
|
|
1335
|
+
return 0;
|
|
1336
|
+
}
|
|
1337
|
+
tell_content_shown(gobj);
|
|
1338
|
+
return 0;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1281
1341
|
/************************************************************
|
|
1282
1342
|
* My parent took me off the path.
|
|
1283
1343
|
************************************************************/
|
|
@@ -1795,6 +1855,7 @@ function create_gclass(gclass_name)
|
|
|
1795
1855
|
["EV_SET_NAV_MODE", ac_set_nav_mode, null],
|
|
1796
1856
|
["EV_SET_CONTENT", ac_set_content, null],
|
|
1797
1857
|
["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
|
|
1858
|
+
["EV_VIEW_SHOWN", ac_view_shown, null],
|
|
1798
1859
|
["EV_DESTROY_NAVS", ac_destroy_navs, null]
|
|
1799
1860
|
]],
|
|
1800
1861
|
["ST_CHILD", [
|
|
@@ -1811,6 +1872,7 @@ function create_gclass(gclass_name)
|
|
|
1811
1872
|
["EV_SET_NAV_MODE", ac_set_nav_mode, null],
|
|
1812
1873
|
["EV_SET_CONTENT", ac_set_content, null],
|
|
1813
1874
|
["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
|
|
1875
|
+
["EV_VIEW_SHOWN", ac_view_shown, null],
|
|
1814
1876
|
["EV_DESTROY_NAVS", ac_destroy_navs, null]
|
|
1815
1877
|
]]
|
|
1816
1878
|
];
|
|
@@ -1832,6 +1894,8 @@ function create_gclass(gclass_name)
|
|
|
1832
1894
|
["EV_SET_NAV_MODE", 0],
|
|
1833
1895
|
["EV_SET_CONTENT", 0],
|
|
1834
1896
|
["EV_NODE_TREE_CHANGED", 0],
|
|
1897
|
+
/* the shell or the parent shows the tree again (keep_alive) */
|
|
1898
|
+
["EV_VIEW_SHOWN", 0],
|
|
1835
1899
|
/* internal: posted to itself, the navs a render left */
|
|
1836
1900
|
["EV_DESTROY_NAVS", 0]
|
|
1837
1901
|
];
|
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
* - flags EVF_PUBLIC_EVENT on what arrives from the backend
|
|
46
46
|
* (EV_MT_COMMAND_ANSWER and anything the remote publishes): the
|
|
47
47
|
* ievent drops events that are not public.
|
|
48
|
+
* - MAY declare EV_VIEW_SHOWN: the shell (or a C_YUI_NODE) sends
|
|
49
|
+
* it here when it shows a hidden view again, and this host
|
|
50
|
+
* hands it on -- the place to read again the data the view
|
|
51
|
+
* read only when it was created.
|
|
48
52
|
*
|
|
49
53
|
* NAMES: the service name must be UNIQUE per mount. A duplicate is
|
|
50
54
|
* not fatal and that is the danger — gobj-js logs "service ALREADY
|
|
@@ -75,6 +79,8 @@ import {
|
|
|
75
79
|
gobj_stop,
|
|
76
80
|
gobj_is_running,
|
|
77
81
|
gobj_short_name,
|
|
82
|
+
gobj_has_event,
|
|
83
|
+
gobj_send_event,
|
|
78
84
|
is_gobj,
|
|
79
85
|
is_string,
|
|
80
86
|
empty_string,
|
|
@@ -306,6 +312,29 @@ function mt_destroy(gobj)
|
|
|
306
312
|
|
|
307
313
|
|
|
308
314
|
|
|
315
|
+
/***************************
|
|
316
|
+
* Actions
|
|
317
|
+
***************************/
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
/************************************************************
|
|
323
|
+
* The shell shows me again after hiding me (`keep_alive`):
|
|
324
|
+
* the hosted view is the one that may want to know.
|
|
325
|
+
************************************************************/
|
|
326
|
+
function ac_view_shown(gobj, event, kw, src)
|
|
327
|
+
{
|
|
328
|
+
const view = gobj.priv.view;
|
|
329
|
+
if(view && gobj_has_event(view, event)) {
|
|
330
|
+
gobj_send_event(view, event, kw, gobj);
|
|
331
|
+
}
|
|
332
|
+
return 0;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
309
338
|
/***************************
|
|
310
339
|
* FSM
|
|
311
340
|
***************************/
|
|
@@ -328,10 +357,14 @@ function create_gclass(gclass_name)
|
|
|
328
357
|
}
|
|
329
358
|
|
|
330
359
|
const states = [
|
|
331
|
-
["ST_IDLE", [
|
|
360
|
+
["ST_IDLE", [
|
|
361
|
+
["EV_VIEW_SHOWN", ac_view_shown, null]
|
|
362
|
+
]]
|
|
332
363
|
];
|
|
333
364
|
|
|
334
|
-
const event_types = [
|
|
365
|
+
const event_types = [
|
|
366
|
+
["EV_VIEW_SHOWN", 0]
|
|
367
|
+
];
|
|
335
368
|
|
|
336
369
|
__gclass__ = gclass_create(
|
|
337
370
|
gclass_name,
|
package/src/c_yui_shell.js
CHANGED
|
@@ -1010,6 +1010,7 @@ function build_ui(gobj)
|
|
|
1010
1010
|
priv.stages[stage_name] = {
|
|
1011
1011
|
el: priv.zones[zone],
|
|
1012
1012
|
items: {},
|
|
1013
|
+
shown: {}, /* routes whose view has been on screen */
|
|
1013
1014
|
active_route: null
|
|
1014
1015
|
};
|
|
1015
1016
|
if(priv.zones[zone]) {
|
|
@@ -1023,7 +1024,7 @@ function build_ui(gobj)
|
|
|
1023
1024
|
if(m) {
|
|
1024
1025
|
let name = m[1];
|
|
1025
1026
|
if(!priv.stages[name]) {
|
|
1026
|
-
priv.stages[name] = { el: priv.zones[id], items: {}, active_route: null };
|
|
1027
|
+
priv.stages[name] = { el: priv.zones[id], items: {}, shown: {}, active_route: null };
|
|
1027
1028
|
if(priv.zones[id]) {
|
|
1028
1029
|
priv.zones[id].classList.add("yui-stage", `yui-stage-${name}`);
|
|
1029
1030
|
}
|
|
@@ -1031,7 +1032,7 @@ function build_ui(gobj)
|
|
|
1031
1032
|
}
|
|
1032
1033
|
}
|
|
1033
1034
|
if(!priv.stages.main && priv.zones.center) {
|
|
1034
|
-
priv.stages.main = { el: priv.zones.center, items: {}, active_route: null };
|
|
1035
|
+
priv.stages.main = { el: priv.zones.center, items: {}, shown: {}, active_route: null };
|
|
1035
1036
|
priv.zones.center.classList.add("yui-stage", "yui-stage-main");
|
|
1036
1037
|
}
|
|
1037
1038
|
|
|
@@ -1812,11 +1813,16 @@ function navigate_to(gobj, route, depth, no_drain)
|
|
|
1812
1813
|
$prev.parentNode.removeChild($prev);
|
|
1813
1814
|
}
|
|
1814
1815
|
delete stage.items[prev_route];
|
|
1816
|
+
delete stage.shown[prev_route];
|
|
1815
1817
|
}
|
|
1816
1818
|
}
|
|
1817
1819
|
|
|
1818
1820
|
/* Show or create current (keyed by base route) */
|
|
1819
1821
|
let cur = stage.items[matched_route];
|
|
1822
|
+
/* Shown before, hidden since, and on screen again: what EV_VIEW_SHOWN
|
|
1823
|
+
* tells it, below. A move inside the view (a subpath) is not one. */
|
|
1824
|
+
let reshown = !!cur && !!stage.shown[matched_route] &&
|
|
1825
|
+
prev_route !== matched_route;
|
|
1820
1826
|
if(!cur) {
|
|
1821
1827
|
cur = build_view_gobj(gobj, entry, matched_route, stage);
|
|
1822
1828
|
if(!cur) {
|
|
@@ -1830,6 +1836,7 @@ function navigate_to(gobj, route, depth, no_drain)
|
|
|
1830
1836
|
}
|
|
1831
1837
|
|
|
1832
1838
|
stage.active_route = matched_route;
|
|
1839
|
+
stage.shown[matched_route] = true;
|
|
1833
1840
|
gobj_write_attr(gobj, "current_route", route);
|
|
1834
1841
|
remember_position(gobj, route);
|
|
1835
1842
|
remember_route(gobj, route);
|
|
@@ -1883,6 +1890,21 @@ function navigate_to(gobj, route, depth, no_drain)
|
|
|
1883
1890
|
stage: stage_name,
|
|
1884
1891
|
menu_id: entry.menu_id || ""
|
|
1885
1892
|
});
|
|
1893
|
+
|
|
1894
|
+
/* A `keep_alive` (or `eager`) view is hidden on exit, not destroyed,
|
|
1895
|
+
* so it keeps what it had -- a camera, a scroll, a half-filled form --
|
|
1896
|
+
* and also the data it read when it was created. A view that reads
|
|
1897
|
+
* its data only then and gets no events from the backend declares
|
|
1898
|
+
* EV_VIEW_SHOWN and reads it again here, keeping the rest. Sent after
|
|
1899
|
+
* EV_ROUTE_CHANGED, so the view is already at its position. A view
|
|
1900
|
+
* that does not declare it is not told. */
|
|
1901
|
+
if(reshown && gobj_has_event(cur, "EV_VIEW_SHOWN")) {
|
|
1902
|
+
gobj_send_event(cur, "EV_VIEW_SHOWN", {
|
|
1903
|
+
route: route,
|
|
1904
|
+
base: matched_route,
|
|
1905
|
+
subpath: subpath
|
|
1906
|
+
}, gobj);
|
|
1907
|
+
}
|
|
1886
1908
|
}
|
|
1887
1909
|
|
|
1888
1910
|
function build_view_gobj(gobj, entry, route, stage)
|
|
@@ -4218,6 +4240,7 @@ function prune_route(shell_gobj, route)
|
|
|
4218
4240
|
log_warning(`C_YUI_SHELL: prune_route destroy '${route}' failed: ${e}`);
|
|
4219
4241
|
}
|
|
4220
4242
|
delete stage.items[route];
|
|
4243
|
+
delete stage.shown[route];
|
|
4221
4244
|
if(stage.active_route === route) {
|
|
4222
4245
|
stage.active_route = "";
|
|
4223
4246
|
}
|
|
@@ -2050,6 +2050,19 @@ function watch_table_size(gobj, tabulator)
|
|
|
2050
2050
|
});
|
|
2051
2051
|
ro.observe(tabulator.element);
|
|
2052
2052
|
priv.table_resize_observer = ro;
|
|
2053
|
+
|
|
2054
|
+
/* Where the reader is, kept for the next sight: a browser drops the
|
|
2055
|
+
* scroll of an element that goes `display:none`, and gives it back
|
|
2056
|
+
* at 0 -- the rows Tabulator drew for the old position are still
|
|
2057
|
+
* there, under 0, and the view shows only the padding above them.
|
|
2058
|
+
* Plumbing, not an action: one per scrolled pixel. */
|
|
2059
|
+
priv.table_scroll = {top: 0, left: 0};
|
|
2060
|
+
tabulator.on("scrollVertical", (top) => {
|
|
2061
|
+
priv.table_scroll.top = top;
|
|
2062
|
+
});
|
|
2063
|
+
tabulator.on("scrollHorizontal", (left) => {
|
|
2064
|
+
priv.table_scroll.left = left;
|
|
2065
|
+
});
|
|
2053
2066
|
}
|
|
2054
2067
|
|
|
2055
2068
|
function unwatch_table_size(gobj)
|
|
@@ -5463,7 +5476,8 @@ function close_table_json_dialog(gobj)
|
|
|
5463
5476
|
* another tab.
|
|
5464
5477
|
*
|
|
5465
5478
|
* The redraw is done when the table is SEEN again, where the
|
|
5466
|
-
* rows have their real offsets
|
|
5479
|
+
* rows have their real offsets, after giving back the scroll the
|
|
5480
|
+
* browser dropped with the `display:none` (watch_table_size). It is
|
|
5467
5481
|
* needed there even at the same size: Tabulator does not draw
|
|
5468
5482
|
* the data that arrives while it is hidden (a node event, a
|
|
5469
5483
|
* refresh), it leaves that to its next sight.
|
|
@@ -5494,6 +5508,13 @@ function ac_table_resized(gobj, event, kw, src)
|
|
|
5494
5508
|
tabulator.redraw(true); /* built hidden: never laid out */
|
|
5495
5509
|
return 0;
|
|
5496
5510
|
}
|
|
5511
|
+
if(was_hidden) {
|
|
5512
|
+
let $holder = tabulator.element.querySelector(".tabulator-tableholder");
|
|
5513
|
+
if($holder) {
|
|
5514
|
+
$holder.scrollTop = priv.table_scroll.top;
|
|
5515
|
+
$holder.scrollLeft = priv.table_scroll.left;
|
|
5516
|
+
}
|
|
5517
|
+
}
|
|
5497
5518
|
if(was_hidden ||
|
|
5498
5519
|
last.width !== kw.width || last.height !== kw.height) {
|
|
5499
5520
|
tabulator.redraw();
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* shell_view_shown.wiring.test.js
|
|
3
|
+
*
|
|
4
|
+
* EV_VIEW_SHOWN: a view the shell shows AGAIN after hiding it
|
|
5
|
+
* (`keep_alive`) is told so, if it declares the event, and
|
|
6
|
+
* C_YUI_SERVICE_VIEW hands it on to the view it hosts.
|
|
7
|
+
*
|
|
8
|
+
* Driven through the real C_YUI_SHELL on a document double.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026, ArtGins.
|
|
11
|
+
* All Rights Reserved.
|
|
12
|
+
***********************************************************************/
|
|
13
|
+
import {describe, test, expect, beforeAll, beforeEach, afterEach} from "vitest";
|
|
14
|
+
import {install_dom_double} from "../test/dom_double.js";
|
|
15
|
+
|
|
16
|
+
install_dom_double();
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
SDATA, SDATA_END, data_type_t, gclass_create, gobj_write_attr,
|
|
20
|
+
gobj_start_up, gobj_create_yuno, gobj_create, gobj_create_service,
|
|
21
|
+
gobj_start, gobj_stop, gobj_destroy, gobj_is_running, gobj_name,
|
|
22
|
+
set_log_callback,
|
|
23
|
+
} = await import("@yuneta/gobj-js");
|
|
24
|
+
const {register_c_yui_shell, yui_shell_navigate} = await import("./c_yui_shell.js");
|
|
25
|
+
const {register_c_yui_service_view} = await import("./c_yui_service_view.js");
|
|
26
|
+
const {register_c_yui_nav} = await import("./c_yui_nav.js");
|
|
27
|
+
|
|
28
|
+
const logged = [];
|
|
29
|
+
const alive = [];
|
|
30
|
+
const shown = []; /* {name, kw} per EV_VIEW_SHOWN received */
|
|
31
|
+
let yuno = null;
|
|
32
|
+
let seq = 0;
|
|
33
|
+
|
|
34
|
+
beforeAll(async () => {
|
|
35
|
+
const i18next = (await import("i18next")).default;
|
|
36
|
+
await i18next.init({lng: "en", resources: {}});
|
|
37
|
+
gobj_start_up(null, null, null, null, null, null, null);
|
|
38
|
+
set_log_callback((level, msg) => {
|
|
39
|
+
logged.push({level: String(level), msg: String(msg)});
|
|
40
|
+
});
|
|
41
|
+
gclass_create("C_TEST_SHOWN_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
42
|
+
|
|
43
|
+
const attrs = [
|
|
44
|
+
SDATA(data_type_t.DTP_POINTER, "$container", 0, null, "view root"),
|
|
45
|
+
SDATA(data_type_t.DTP_POINTER, "gobj_remote_yuno", 0, null, "transport"),
|
|
46
|
+
SDATA_END()
|
|
47
|
+
];
|
|
48
|
+
const gmt = {
|
|
49
|
+
mt_create: (gobj) => {
|
|
50
|
+
gobj_write_attr(gobj, "$container", document.createElement("div"));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/* A view that reads its data when created, and again when shown */
|
|
54
|
+
gclass_create(
|
|
55
|
+
"C_TEST_SHOWN_VIEW",
|
|
56
|
+
[["EV_VIEW_SHOWN", 0]],
|
|
57
|
+
[["ST_IDLE", [
|
|
58
|
+
["EV_VIEW_SHOWN", (gobj, event, kw) => {
|
|
59
|
+
shown.push({name: gobj_name(gobj), kw: kw});
|
|
60
|
+
return 0;
|
|
61
|
+
}, null]
|
|
62
|
+
]]],
|
|
63
|
+
gmt, 0, attrs, {}, 0, 0, 0, 0
|
|
64
|
+
);
|
|
65
|
+
/* A view that does not care */
|
|
66
|
+
gclass_create("C_TEST_PLAIN_VIEW", [], [["ST_IDLE", []]], gmt, 0, attrs, {}, 0, 0, 0, 0);
|
|
67
|
+
|
|
68
|
+
register_c_yui_shell();
|
|
69
|
+
register_c_yui_nav();
|
|
70
|
+
register_c_yui_service_view();
|
|
71
|
+
yuno = gobj_create_yuno("view_shown_yuno", "C_TEST_SHOWN_HOST", {});
|
|
72
|
+
gobj_start(yuno);
|
|
73
|
+
gobj_create_service("test_transport", "C_TEST_SHOWN_HOST", {}, yuno);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
logged.length = 0;
|
|
78
|
+
shown.length = 0;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
afterEach(() => {
|
|
82
|
+
for(const gobj of alive.splice(0)) {
|
|
83
|
+
if(gobj_is_running(gobj)) {
|
|
84
|
+
gobj_stop(gobj);
|
|
85
|
+
}
|
|
86
|
+
gobj_destroy(gobj);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
function target(gclass, lifecycle, name)
|
|
91
|
+
{
|
|
92
|
+
return {stage: "main", gclass: gclass, kw: {}, lifecycle: lifecycle, name: name};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function config()
|
|
96
|
+
{
|
|
97
|
+
return {
|
|
98
|
+
shell: {
|
|
99
|
+
zones: {
|
|
100
|
+
left: {host: "menu.primary"},
|
|
101
|
+
center: {host: "stage.main"}
|
|
102
|
+
},
|
|
103
|
+
stages: {main: {zone: "center", default_route: "/kept"}}
|
|
104
|
+
},
|
|
105
|
+
menu: {
|
|
106
|
+
primary: {
|
|
107
|
+
render: {left: {layout: "vertical", icon_pos: "left"}},
|
|
108
|
+
items: [
|
|
109
|
+
{id: "kept", name: "kept", route: "/kept",
|
|
110
|
+
target: target("C_TEST_SHOWN_VIEW", "keep_alive", "kept_view")},
|
|
111
|
+
{id: "plain", name: "plain", route: "/plain",
|
|
112
|
+
target: target("C_TEST_PLAIN_VIEW", "keep_alive", "plain_view")},
|
|
113
|
+
{id: "gone", name: "gone", route: "/gone",
|
|
114
|
+
target: target("C_TEST_SHOWN_VIEW", "lazy_destroy", "gone_view")},
|
|
115
|
+
{id: "hosted", name: "hosted", route: "/hosted",
|
|
116
|
+
target: {
|
|
117
|
+
stage: "main", gclass: "C_YUI_SERVICE_VIEW", lifecycle: "keep_alive",
|
|
118
|
+
name: "hosted_host",
|
|
119
|
+
kw: {
|
|
120
|
+
view_gclass: "C_TEST_SHOWN_VIEW",
|
|
121
|
+
service_name: "#hosted_view",
|
|
122
|
+
transport_service: "test_transport"
|
|
123
|
+
}
|
|
124
|
+
}}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function new_shell()
|
|
132
|
+
{
|
|
133
|
+
const shell = gobj_create(`shown_shell_${++seq}`, "C_YUI_SHELL",
|
|
134
|
+
{config: config(), use_hash: false}, yuno);
|
|
135
|
+
gobj_start(shell);
|
|
136
|
+
alive.push(shell);
|
|
137
|
+
return shell;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function errors()
|
|
141
|
+
{
|
|
142
|
+
return logged.filter((l) => l.level === "error" || l.level === "warning").map((l) => l.msg);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
describe("EV_VIEW_SHOWN", () => {
|
|
146
|
+
test("a keep_alive view is told when it is shown AGAIN, not the first time", () => {
|
|
147
|
+
const shell = new_shell();
|
|
148
|
+
yui_shell_navigate(shell, "/kept");
|
|
149
|
+
expect(shown).toEqual([]);
|
|
150
|
+
|
|
151
|
+
yui_shell_navigate(shell, "/plain");
|
|
152
|
+
yui_shell_navigate(shell, "/kept");
|
|
153
|
+
expect(shown.length).toBe(1);
|
|
154
|
+
expect(shown[0].name).toBe("kept_view");
|
|
155
|
+
expect(shown[0].kw.base).toBe("/kept");
|
|
156
|
+
expect(errors()).toEqual([]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("a move inside the view (a subpath) is not a new showing", () => {
|
|
160
|
+
const shell = new_shell();
|
|
161
|
+
yui_shell_navigate(shell, "/kept");
|
|
162
|
+
yui_shell_navigate(shell, "/kept/table");
|
|
163
|
+
yui_shell_navigate(shell, "/kept/cards");
|
|
164
|
+
expect(shown).toEqual([]);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("a view that does not declare it is not told, and nothing complains", () => {
|
|
168
|
+
const shell = new_shell();
|
|
169
|
+
yui_shell_navigate(shell, "/plain");
|
|
170
|
+
yui_shell_navigate(shell, "/kept");
|
|
171
|
+
yui_shell_navigate(shell, "/plain");
|
|
172
|
+
expect(shown.filter((s) => s.name === "plain_view")).toEqual([]);
|
|
173
|
+
expect(errors()).toEqual([]);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("a lazy_destroy view comes back NEW, and a new view is not told", () => {
|
|
177
|
+
const shell = new_shell();
|
|
178
|
+
yui_shell_navigate(shell, "/gone");
|
|
179
|
+
yui_shell_navigate(shell, "/kept");
|
|
180
|
+
yui_shell_navigate(shell, "/gone");
|
|
181
|
+
expect(shown.filter((s) => s.name === "gone_view")).toEqual([]);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("C_YUI_SERVICE_VIEW hands it on to the view it hosts", () => {
|
|
185
|
+
const shell = new_shell();
|
|
186
|
+
yui_shell_navigate(shell, "/hosted");
|
|
187
|
+
yui_shell_navigate(shell, "/kept");
|
|
188
|
+
yui_shell_navigate(shell, "/hosted");
|
|
189
|
+
expect(shown.filter((s) => s.name === "#hosted_view").length).toBe(1);
|
|
190
|
+
expect(errors()).toEqual([]);
|
|
191
|
+
});
|
|
192
|
+
});
|