From 6aaaf7ed3e1b7d2fbe00fa6fe0e49f7bfd3010a8 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Mon, 7 Mar 2022 09:07:53 +0000 Subject: [PATCH] erp5_web_renderjs_ui: keep loader visible for a minimal amount of time --- .../rjs_gadget_erp5_launcher_js.js | 31 +++++++++---------- .../rjs_gadget_erp5_launcher_js.xml | 4 +-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js index cfad01f780..3090e21289 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js @@ -111,17 +111,17 @@ return route(gadget, 'panel', 'render', [gadget.props.panel_argument_list]); } - function refreshHeaderAndPanel(gadget, refresh) { - var promise; - if (refresh) { - promise = route(gadget, "header", 'render', - [gadget.props.header_argument_list]); - } else { - promise = updateHeader(gadget); - } + function refreshHeaderAndPanel(gadget, refresh, loading_delay_promise) { return RSVP.all([ - promise, - updatePanel(gadget) + updatePanel(gadget), + new RSVP.Queue(loading_delay_promise) + .push(function () { + if (refresh) { + return route(gadget, "header", 'render', + [gadget.props.header_argument_list]); + } + return updateHeader(gadget); + }) ]); } @@ -735,7 +735,8 @@ .onStateChange(function onStateChange(modification_dict) { var gadget = this, route_result = gadget.state, - promise_list; + promise_list, + slow_loading_promise; if (modification_dict.hasOwnProperty('error_text')) { return gadget.dropGadget(MAIN_SCOPE) @@ -813,6 +814,7 @@ initHeaderOptions(gadget); initPanelOptions(gadget); if (!modification_dict.hasOwnProperty('first_bootstrap')) { + slow_loading_promise = RSVP.delay(50); promise_list.push(route(gadget, 'header', 'notifyLoading')); } } @@ -837,11 +839,8 @@ } content_container.appendChild(main_gadget.element); element.appendChild(content_container); - - return refreshHeaderAndPanel(gadget); - // XXX Drop notification - // return header_gadget.notifyLoaded(); } + return refreshHeaderAndPanel(gadget, false, slow_loading_promise); })); } else if (modification_dict.hasOwnProperty('render_timestamp')) { // Same subgadget @@ -850,7 +849,7 @@ return page_gadget.render(gadget.state.options); }) .push(function () { - return refreshHeaderAndPanel(gadget); + return refreshHeaderAndPanel(gadget, false, slow_loading_promise); })); } diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml index e7a91d01b3..163c18c11b 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml @@ -234,7 +234,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>993.37256.4522.58726</string> </value> + <value> <string>999.1512.55448.47445</string> </value> </item> <item> <key> <string>state</string> </key> @@ -252,7 +252,7 @@ </tuple> <state> <tuple> - <float>1626860658.98</float> + <float>1647877106.56</float> <string>UTC</string> </tuple> </state> -- 2.30.9