Commit 376d2360 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Load launcher's subgadget on demand

This slow down the current rendering, but the goal is to delay their usage.
parent d1006d7b
...@@ -41,15 +41,15 @@ ...@@ -41,15 +41,15 @@
data-gadget-scope="router" data-gadget-scope="router"
data-gadget-sandbox="public"></div> data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_erp5_notification.html" <div data-gadget-async-url="gadget_erp5_notification.html"
data-gadget-scope="notification" data-gadget-scope="notification"
data-gadget-sandbox="public"></div> data-gadget-sandbox="public"></div>
<div data-gadget-url="${translation_gadget}" <div data-gadget-async-url="${translation_gadget}"
data-gadget-scope="translation_gadget" data-gadget-scope="translation_gadget"
data-gadget-sandbox="public"></div> data-gadget-sandbox="public"></div>
<div data-gadget-url="${header_gadget}" <div data-gadget-async-url="${header_gadget}"
data-gadget-scope="header" data-gadget-scope="header"
data-gadget-sandbox="public"></div> data-gadget-sandbox="public"></div>
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
data-gadget-sandbox="public"></div> data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_erp5_editor_panel.html" <div data-gadget-async-url="gadget_erp5_editor_panel.html"
data-gadget-scope="editor_panel" data-gadget-scope="editor_panel"
data-gadget-sandbox="public"></div> data-gadget-sandbox="public"></div>
<div data-gadget-url="${panel_gadget}" <div data-gadget-async-url="${panel_gadget}"
data-gadget-scope="panel" data-gadget-scope="panel"
data-gadget-sandbox="public"></div> data-gadget-sandbox="public"></div>
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.11650.9551.35020</string> </value> <value> <string>971.11932.10080.12339</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1540459204.07</float> <float>1540475647.75</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -37,6 +37,24 @@ ...@@ -37,6 +37,24 @@
function route(my_root_gadget, my_scope, my_method, argument_list) { function route(my_root_gadget, my_scope, my_method, argument_list) {
return my_root_gadget.getDeclaredGadget(my_scope) return my_root_gadget.getDeclaredGadget(my_scope)
.push(undefined, function (error) {
if (error instanceof rJS.ScopeError) {
var element = my_root_gadget
.element
.querySelector("[data-gadget-scope='" +
my_scope + "']");
if (element !== null) {
return my_root_gadget.declareGadget(
element.getAttribute('data-gadget-async-url'),
{
scope: my_scope,
element: element
}
);
}
}
throw error;
})
.push(function (my_gadget) { .push(function (my_gadget) {
if (argument_list) { if (argument_list) {
return my_gadget[my_method].apply(my_gadget, argument_list); return my_gadget[my_method].apply(my_gadget, argument_list);
...@@ -58,19 +76,13 @@ ...@@ -58,19 +76,13 @@
} }
function updatePanel(gadget) { function updatePanel(gadget) {
return gadget.getDeclaredGadget("panel") return route(gadget, 'panel', 'render', [gadget.props.panel_argument_list]);
.push(function (panel_gadget) {
return panel_gadget.render(gadget.props.panel_argument_list);
});
} }
function increaseLoadingCounter(gadget) { function increaseLoadingCounter(gadget) {
gadget.props.loading_counter += 1; gadget.props.loading_counter += 1;
if (gadget.props.loading_counter === 1) { if (gadget.props.loading_counter === 1) {
return gadget.getDeclaredGadget("header") return route(gadget, 'header', 'notifyLoading');
.push(function (header_gadget) {
return header_gadget.notifyLoading();
});
} }
return new RSVP.Queue(); return new RSVP.Queue();
} }
...@@ -82,10 +94,7 @@ ...@@ -82,10 +94,7 @@
// throw new Error("Unexpected negative loading counter"); // throw new Error("Unexpected negative loading counter");
} }
if (gadget.props.loading_counter === 0) { if (gadget.props.loading_counter === 0) {
return gadget.getDeclaredGadget("header") return route(gadget, 'header', 'notifyLoaded');
.push(function (header_gadget) {
return header_gadget.notifyLoaded();
});
} }
return new RSVP.Queue(); return new RSVP.Queue();
} }
...@@ -278,16 +287,10 @@ ...@@ -278,16 +287,10 @@
return jio_gadget.createJio(setting.jio_storage_description); return jio_gadget.createJio(setting.jio_storage_description);
}) })
.push(function () { .push(function () {
return gadget.getDeclaredGadget('panel'); return route(gadget, 'panel', 'render', [{}]);
})
.push(function (panel_gadget) {
return panel_gadget.render({});
}) })
.push(function () { .push(function () {
return gadget.getDeclaredGadget('router'); return route(gadget, 'router', 'start');
})
.push(function (router_gadget) {
return router_gadget.start();
}); });
}) })
...@@ -428,28 +431,22 @@ ...@@ -428,28 +431,22 @@
}) })
.allowPublicAcquisition("updateHeader", function updateHeader(param_list) { .allowPublicAcquisition("updateHeader", function updateHeader(param_list) {
var gadget = this; initHeaderOptions(this);
initHeaderOptions(gadget); var text_list = [],
return this.getDeclaredGadget("translation_gadget") key,
.push(function (translation_gadget) { gadget = this;
var promise_list = [],
key;
for (key in param_list[0]) { for (key in param_list[0]) {
if (param_list[0].hasOwnProperty(key)) { if (param_list[0].hasOwnProperty(key)) {
gadget.props.header_argument_list[key] = param_list[0][key]; gadget.props.header_argument_list[key] = param_list[0][key];
} }
} }
promise_list.push(translation_gadget.translate( text_list.push(gadget.props.header_argument_list.title);
gadget.props.header_argument_list.title
));
if (gadget.props.header_argument_list.hasOwnProperty('right_title')) { if (gadget.props.header_argument_list.hasOwnProperty('right_title')) {
promise_list.push(translation_gadget.translate( text_list.push(gadget.props.header_argument_list.right_title);
gadget.props.header_argument_list.right_title
));
} }
return RSVP.all(promise_list); return route(gadget, 'translation_gadget', 'getTranslationList',
}) text_list)
.push(function (result_list) { .push(function (result_list) {
gadget.props.header_argument_list.title = result_list[0]; gadget.props.header_argument_list.title = result_list[0];
if (result_list.length === 2) { if (result_list.length === 2) {
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.11671.54203.21998</string> </value> <value> <string>971.11959.34044.35447</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1540459696.8</float> <float>1540477038.59</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment