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