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 @@
data-gadget-scope="router"
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-sandbox="public"></div>
<div data-gadget-url="${translation_gadget}"
<div data-gadget-async-url="${translation_gadget}"
data-gadget-scope="translation_gadget"
data-gadget-sandbox="public"></div>
<div data-gadget-url="${header_gadget}"
<div data-gadget-async-url="${header_gadget}"
data-gadget-scope="header"
data-gadget-sandbox="public"></div>
......@@ -58,11 +58,11 @@
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-sandbox="public"></div>
<div data-gadget-url="${panel_gadget}"
<div data-gadget-async-url="${panel_gadget}"
data-gadget-scope="panel"
data-gadget-sandbox="public"></div>
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.11650.9551.35020</string> </value>
<value> <string>971.11932.10080.12339</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1540459204.07</float>
<float>1540475647.75</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -37,6 +37,24 @@
function route(my_root_gadget, my_scope, my_method, argument_list) {
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) {
if (argument_list) {
return my_gadget[my_method].apply(my_gadget, argument_list);
......@@ -58,19 +76,13 @@
}
function updatePanel(gadget) {
return gadget.getDeclaredGadget("panel")
.push(function (panel_gadget) {
return panel_gadget.render(gadget.props.panel_argument_list);
});
return route(gadget, 'panel', 'render', [gadget.props.panel_argument_list]);
}
function increaseLoadingCounter(gadget) {
gadget.props.loading_counter += 1;
if (gadget.props.loading_counter === 1) {
return gadget.getDeclaredGadget("header")
.push(function (header_gadget) {
return header_gadget.notifyLoading();
});
return route(gadget, 'header', 'notifyLoading');
}
return new RSVP.Queue();
}
......@@ -82,10 +94,7 @@
// throw new Error("Unexpected negative loading counter");
}
if (gadget.props.loading_counter === 0) {
return gadget.getDeclaredGadget("header")
.push(function (header_gadget) {
return header_gadget.notifyLoaded();
});
return route(gadget, 'header', 'notifyLoaded');
}
return new RSVP.Queue();
}
......@@ -278,16 +287,10 @@
return jio_gadget.createJio(setting.jio_storage_description);
})
.push(function () {
return gadget.getDeclaredGadget('panel');
})
.push(function (panel_gadget) {
return panel_gadget.render({});
return route(gadget, 'panel', 'render', [{}]);
})
.push(function () {
return gadget.getDeclaredGadget('router');
})
.push(function (router_gadget) {
return router_gadget.start();
return route(gadget, 'router', 'start');
});
})
......@@ -428,28 +431,22 @@
})
.allowPublicAcquisition("updateHeader", function updateHeader(param_list) {
var gadget = this;
initHeaderOptions(gadget);
return this.getDeclaredGadget("translation_gadget")
.push(function (translation_gadget) {
var promise_list = [],
key;
for (key in param_list[0]) {
if (param_list[0].hasOwnProperty(key)) {
gadget.props.header_argument_list[key] = param_list[0][key];
}
}
initHeaderOptions(this);
var text_list = [],
key,
gadget = this;
for (key in param_list[0]) {
if (param_list[0].hasOwnProperty(key)) {
gadget.props.header_argument_list[key] = param_list[0][key];
}
}
promise_list.push(translation_gadget.translate(
gadget.props.header_argument_list.title
));
if (gadget.props.header_argument_list.hasOwnProperty('right_title')) {
promise_list.push(translation_gadget.translate(
gadget.props.header_argument_list.right_title
));
}
return RSVP.all(promise_list);
})
text_list.push(gadget.props.header_argument_list.title);
if (gadget.props.header_argument_list.hasOwnProperty('right_title')) {
text_list.push(gadget.props.header_argument_list.right_title);
}
return route(gadget, 'translation_gadget', 'getTranslationList',
text_list)
.push(function (result_list) {
gadget.props.header_argument_list.title = result_list[0];
if (result_list.length === 2) {
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.11671.54203.21998</string> </value>
<value> <string>971.11959.34044.35447</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1540459696.8</float>
<float>1540477038.59</float>
<string>UTC</string>
</tuple>
</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