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