Commit d727a4ad authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] History: speed up URLs calculation

parent 2c71321f
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlForList", "getUrlForList")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -27,56 +27,56 @@ ...@@ -27,56 +27,56 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
id_list = options.id_list || [], id_list = options.id_list || [],
header_dict = { j,
page_title: 'History', query_list = [],
page_icon: 'history' queue,
}; row_list;
return gadget.getUrlFor({command: 'display'}) for (j = 0; j < id_list.length; j += 1) {
.push(function (front_url) { query_list.push(new SimpleQuery({
header_dict.front_url = front_url; key: 'relative_url',
return gadget.updateHeader(header_dict); value: id_list[j]
}) }));
.push(function () {
var i,
query_list = [];
for (i = 0; i < id_list.length; i += 1) {
query_list.push(new SimpleQuery({key: 'relative_url', value: id_list[i]}));
} }
if (i === 0) { if (j === 0) {
queue = new RSVP.Queue()
.push(function () {
return { return {
data: { data: {
rows: [] rows: []
} }
}; };
} });
return gadget.jio_allDocs({ } else {
queue = gadget.jio_allDocs({
query: Query.objectToSearchText(new ComplexQuery({operator: 'OR', query_list: query_list})), query: Query.objectToSearchText(new ComplexQuery({operator: 'OR', query_list: query_list})),
select_list: ["title", "translated_portal_type"], select_list: ["title", "translated_portal_type"],
limit: id_list.length limit: id_list.length
}); });
}) }
return queue
.push(function (result) { .push(function (result) {
var result_list = [], var url_for_parameter_list = [{command: 'display'}],
i; i;
for (i = 0; i < result.data.rows.length; i += 1) { row_list = result.data.rows;
result_list.push(RSVP.all([ for (i = 0; i < row_list.length; i += 1) {
gadget.getUrlFor({command: 'display', options: {jio_key: result.data.rows[i].id}}), url_for_parameter_list.push({
result.data.rows[i].value, command: 'display',
result.data.rows[i].id options: {jio_key: row_list[i].id}
])); });
} }
return RSVP.all(result_list); return gadget.getUrlForList(url_for_parameter_list);
}) })
.push(function (result_list) { .push(function (url_list) {
var i, var i,
document_list = [], document_list = [],
document_dict = {}; document_dict = {};
for (i = 0; i < result_list.length; i += 1) { for (i = 1; i < url_list.length; i += 1) {
document_dict[result_list[i][2]] = { document_dict[row_list[i - 1].id] = {
link: result_list[i][0], link: url_list[i],
title: (result_list[i][1].title || result_list[i][2]) + " (" + result_list[i][1].translated_portal_type + ")" title: (row_list[i - 1].value.title || row_list[i - 1].id) +
" (" + row_list[i - 1].value.translated_portal_type + ")"
}; };
} }
// Sort by access time // Sort by access time
...@@ -88,6 +88,11 @@ ...@@ -88,6 +88,11 @@
gadget.element.querySelector('.document_list').innerHTML = table_template( gadget.element.querySelector('.document_list').innerHTML = table_template(
{document_list: document_list} {document_list: document_list}
); );
return gadget.updateHeader({
page_title: 'History',
page_icon: 'history',
front_url: url_list[0]
});
}); });
}); });
}(window, rJS, RSVP, Handlebars, SimpleQuery, ComplexQuery, Query)); }(window, rJS, RSVP, Handlebars, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>superkato</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>966.40160.48147.18688</string> </value> <value> <string>968.41630.8511.54391</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>1522767706.51</float> <float>1530547123.46</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