Commit f9c408f7 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Use getUrlForList to reduce number of acquired method call

parent 4234b52a
......@@ -146,6 +146,7 @@
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("renderEditorPanel", "renderEditorPanel")
.declareAcquiredMethod("redirect", "redirect")
......@@ -482,35 +483,28 @@
sort_list = JSON.parse(gadget.state.sort_list_json);
// Every line points to a sub-document so we need those links
for (i = 0; i < counter; i += 1) {
promise_list.push(
gadget.getUrlFor({
command: gadget.state.command,
options: {
jio_key: allDocs_result.data.rows[i].id,
uid: allDocs_result.data.rows[i].value.uid,
selection_index: gadget.state.begin_from + i,
query: gadget.state.query_string,
list_method_template: gadget.state.list_method_template,
"sort_list:json": sort_list
}
})
);
promise_list.push({
command: gadget.state.command,
options: {
jio_key: allDocs_result.data.rows[i].id,
uid: allDocs_result.data.rows[i].value.uid,
selection_index: gadget.state.begin_from + i,
query: gadget.state.query_string,
list_method_template: gadget.state.list_method_template,
"sort_list:json": sort_list
}
});
for (j = 0; j < column_list.length; j += 1) {
content_value = allDocs_result.data.rows[i].value[column_list[j][0]] || "";
if (content_value.url_value) {
if (content_value.url_value.command) {
url_promise_list.push(
gadget.getUrlFor(content_value.url_value)
);
url_promise_list.push(content_value.url_value);
}
}
}
}
promise_list.push.apply(promise_list, url_promise_list);
return new RSVP.Queue()
.push(function () {
return RSVP.all(promise_list);
})
return gadget.getUrlForList(promise_list)
.push(function (line_link_list) {
var row_list = [],
value,
......@@ -610,9 +604,9 @@
prev_param[gadget.state.key + '_begin_from'] = gadget.state.begin_from - lines;
setNext();
}
return RSVP.all([
gadget.getUrlFor({command: 'change', options: prev_param}),
gadget.getUrlFor({command: 'change', options: next_param})
return gadget.getUrlForList([
{command: 'change', options: prev_param},
{command: 'change', options: next_param}
]);
})
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.34816.49816.58760</string> </value>
<value> <string>967.34904.15900.7253</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1526292640.95</float>
<float>1526297884.31</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -9,6 +9,7 @@
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
......@@ -18,14 +19,21 @@
.allowPublicAcquisition('updateHeader', function () {
return;
})
.allowPublicAcquisition('getUrlFor', function (argument_list) {
if (argument_list[0].command === 'index') {
return this.getUrlFor({
command: 'display_stored_state',
options: {jio_key: argument_list[0].options.jio_key}
});
.allowPublicAcquisition('getUrlForList', function (argument_list) {
var i,
options_list = argument_list[0],
result_list = [];
for (i = 0; i < options_list.length; i += 1) {
if (options_list[i].command === 'index') {
result_list.push({
command: 'display_stored_state',
options: {jio_key: options_list[i].options.jio_key}
});
} else {
result_list.push(options_list[i]);
}
}
return this.getUrlFor.apply(this, argument_list);
return this.getUrlForList.apply(this, [result_list]);
})
.allowPublicAcquisition('jio_allDocs', function (argument_list) {
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.30895.62413.8584</string> </value>
<value> <string>967.35005.6239.57258</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1518597596.15</float>
<float>1526303943.53</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