Commit 25745080 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Launcher: merge all ready functions into only one

parent b09ac1af
...@@ -206,30 +206,28 @@ ...@@ -206,30 +206,28 @@
// Page rendering // Page rendering
////////////////////////////////////////// //////////////////////////////////////////
rJS(window) rJS(window)
.ready(function (g) { .ready(function () {
g.props = {}; var gadget = this;
return g.getElement() this.props = {
.push(function (element) { loading_counter: 0,
g.props.loading_counter = 0; content_element: this.element.querySelector('.gadget-content')
g.props.element = element; };
g.props.content_element = element.querySelector('.gadget-content');
});
})
// Configure setting storage // Configure setting storage
.ready(function (g) { return gadget.getDeclaredGadget("setting_gadget")
return g.getDeclaredGadget("setting_gadget")
.push(function (jio_gadget) { .push(function (jio_gadget) {
return jio_gadget.createJio({ return jio_gadget.createJio({
type: "indexeddb", type: "indexeddb",
database: "setting" database: "setting"
}); });
});
}) })
.ready(function (g) {
.push(function () {
// Extract configuration parameters stored in HTML // Extract configuration parameters stored in HTML
// XXX Will work only if top gadget... // XXX Will work only if top gadget...
var element_list = var element_list =
document.querySelectorAll("[data-renderjs-configuration]"), document.head
.querySelectorAll("script[data-renderjs-configuration]"),
len = element_list.length, len = element_list.length,
key, key,
value, value,
...@@ -238,45 +236,48 @@ ...@@ -238,45 +236,48 @@
function push(a, b) { function push(a, b) {
queue.push(function () { queue.push(function () {
return setSetting(g, a, b); return setSetting(gadget, a, b);
}); });
} }
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
key = element_list[i].getAttribute('data-renderjs-configuration'); key = element_list[i].getAttribute('data-renderjs-configuration');
value = element_list[i].textContent; value = element_list[i].textContent;
g.props[key] = value; gadget.props[key] = value;
push(key, value); push(key, value);
} }
return queue; return queue;
}) })
.ready(function (g) {
return setSetting(g, 'hateoas_url', .push(function () {
(new URI(g.props.hateoas_url)) return setSetting(gadget, 'hateoas_url',
(new URI(gadget.props.hateoas_url))
.absoluteTo(location.href) .absoluteTo(location.href)
.toString() .toString()
); );
}) })
.push(function () {
// Configure jIO storage // Configure jIO storage
.ready(function (g) { return RSVP.all([
var jio_gadget; gadget.getDeclaredGadget("jio_gadget"),
return g.getDeclaredGadget("jio_gadget") getSetting(gadget, 'jio_storage_description')
.push(function (result) { ]);
jio_gadget = result;
return getSetting(g, 'jio_storage_description');
}) })
.push(function (result) { .push(function (result_list) {
return jio_gadget.createJio(result); return result_list[0].createJio(result_list[1]);
}); })
.push(function () {
return gadget.getDeclaredGadget('panel');
}) })
.ready(function (g) {
return g.getDeclaredGadget('panel')
.push(function (panel_gadget) { .push(function (panel_gadget) {
return panel_gadget.render(); return panel_gadget.render();
});
}) })
.ready(function (g) {
return g.getDeclaredGadget('router') .push(function () {
return gadget.getDeclaredGadget('router');
})
.push(function (router_gadget) { .push(function (router_gadget) {
return router_gadget.start(); return router_gadget.start();
}); });
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.34539.19221.9523</string> </value> <value> <string>955.49842.36679.60381</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>1476198512.38</float> <float>1481029313.69</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