Commit 87b8fe07 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Reduce number of created Queue

parent ee9ff19e
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
function addField(field, rendered_document, form_definition, form_gadget, group_name, modification_dict) { function addField(field, rendered_document, form_definition, form_gadget, group_name, modification_dict) {
var field_name = field[0], var field_name = field[0],
field_element, field_element,
suboptions; suboptions,
queue;
if (!rendered_document.hasOwnProperty(field_name)) { if (!rendered_document.hasOwnProperty(field_name)) {
return; return;
...@@ -45,18 +46,17 @@ ...@@ -45,18 +46,17 @@
} }
field_element = document.createElement("div"); field_element = document.createElement("div");
return new RSVP.Queue()
.push(function () {
var rendered_field_name = rendered_document[field_name].key;
if (modification_dict.hasOwnProperty('hash')) { if (modification_dict.hasOwnProperty('hash')) {
return form_gadget.declareGadget('gadget_erp5_label_field.html', { queue = form_gadget.declareGadget('gadget_erp5_label_field.html', {
scope: rendered_field_name, // ugly! Should be just `field_name` but too many tests depend on it scope: rendered_document[field_name].key, // ugly! Should be just `field_name` but too many tests depend on it
element: field_element, element: field_element,
sandbox: "public" sandbox: "public"
}); });
} else {
queue = form_gadget.getDeclaredGadget(rendered_document[field_name].key);
} }
return form_gadget.getDeclaredGadget(rendered_field_name); return queue
})
.push(function (label_gadget) { .push(function (label_gadget) {
if (modification_dict.hasOwnProperty('hash')) { if (modification_dict.hasOwnProperty('hash')) {
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>964.58561.19908.14080</string> </value> <value> <string>970.11330.19298.59511</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>1516274548.88</float> <float>1537454067.98</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -8,21 +8,19 @@ ...@@ -8,21 +8,19 @@
var MAIN_SCOPE = "m"; var MAIN_SCOPE = "m";
function renderMainGadget(gadget, url, options) { function renderMainGadget(gadget, url, options) {
var page_gadget;
return gadget.declareGadget(url, { return gadget.declareGadget(url, {
scope: MAIN_SCOPE scope: MAIN_SCOPE
}) })
.push(function (page_gadget) { .push(function (result) {
page_gadget = result;
gadget.props.m_options_string = JSON.stringify(options); gadget.props.m_options_string = JSON.stringify(options);
if (page_gadget.render === undefined) { if (page_gadget.render !== undefined) {
return [page_gadget]; return page_gadget.render(options);
} }
return RSVP.all([
page_gadget,
page_gadget.render(options)
]);
}) })
.push(function (all_result) { .push(function () {
return all_result[0]; return page_gadget;
}); });
} }
...@@ -67,8 +65,6 @@ ...@@ -67,8 +65,6 @@
} }
function increaseLoadingCounter(gadget) { function increaseLoadingCounter(gadget) {
return new RSVP.Queue()
.push(function () {
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 gadget.getDeclaredGadget("header")
...@@ -76,12 +72,10 @@ ...@@ -76,12 +72,10 @@
return header_gadget.notifyLoading(); return header_gadget.notifyLoading();
}); });
} }
}); return new RSVP.Queue();
} }
function decreaseLoadingCounter(gadget) { function decreaseLoadingCounter(gadget) {
return new RSVP.Queue()
.push(function () {
gadget.props.loading_counter -= 1; gadget.props.loading_counter -= 1;
if (gadget.props.loading_counter < 0) { if (gadget.props.loading_counter < 0) {
gadget.props.loading_counter = 0; gadget.props.loading_counter = 0;
...@@ -93,16 +87,12 @@ ...@@ -93,16 +87,12 @@
return header_gadget.notifyLoaded(); return header_gadget.notifyLoaded();
}); });
} }
}); return new RSVP.Queue();
} }
function callJioGadget(gadget, method, param_list) { function callJioGadget(gadget, method, param_list) {
var called = false; var called = true;
return new RSVP.Queue() return increaseLoadingCounter(gadget)
.push(function () {
called = true;
return increaseLoadingCounter(gadget);
})
.push(function () { .push(function () {
return gadget.getDeclaredGadget("jio_gadget"); return gadget.getDeclaredGadget("jio_gadget");
}) })
...@@ -577,14 +567,11 @@ ...@@ -577,14 +567,11 @@
} }
if (modification_dict.hasOwnProperty('url')) { if (modification_dict.hasOwnProperty('url')) {
return new RSVP.Queue()
.push(function () {
return renderMainGadget( return renderMainGadget(
gadget, gadget,
route_result.url, route_result.url,
route_result.options route_result.options
); )
})
.push(function (main_gadget) { .push(function (main_gadget) {
// Append loaded gadget in the page // Append loaded gadget in the page
if (main_gadget !== undefined) { if (main_gadget !== undefined) {
...@@ -637,10 +624,7 @@ ...@@ -637,10 +624,7 @@
// (ERP5 title by default + sidebar) // (ERP5 title by default + sidebar)
initHeaderOptions(gadget); initHeaderOptions(gadget);
initPanelOptions(gadget); initPanelOptions(gadget);
return new RSVP.Queue() return increaseLoadingCounter(gadget)
.push(function () {
return increaseLoadingCounter(gadget);
})
.push(function () { .push(function () {
var promise_list = [ var promise_list = [
route(gadget, 'panel', 'close'), route(gadget, 'panel', 'close'),
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>968.42891.50280.153</string> </value> <value> <string>970.25626.47614.53111</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>1530622831.54</float> <float>1537451374.56</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