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