Commit 2c71321f authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Worklist: speed up URLs calculation

parent 4a857ddc
...@@ -20,29 +20,20 @@ ...@@ -20,29 +20,20 @@
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlForList", "getUrlForList")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this, var gadget = this,
header_dict = { action_list;
page_title: 'Worklist',
page_icon: 'tasks'
};
return gadget.getUrlFor({command: 'display'}) // Fetch worklist data
.push(function (url) { return gadget.jio_getAttachment(
header_dict.front_url = url; 'portal_workflow',
return gadget.updateHeader(header_dict); 'links'
}) )
.push(function () {
return gadget.jio_getAttachment(
'portal_workflow',
'links'
);
})
.push(function (result) { .push(function (result) {
return gadget.jio_getAttachment( return gadget.jio_getAttachment(
// result.data.rows[0].id, // result.data.rows[0].id,
...@@ -50,12 +41,15 @@ ...@@ -50,12 +41,15 @@
result._links.action_worklist.href result._links.action_worklist.href
); );
}) })
// Calculate all URLs
.push(function (links) { .push(function (links) {
var action_list = links.worklist, var query_string,
query_string, // Back URL
promise_list = [gadget.translate('All work caught up!')], url_for_parameter_list = [{command: 'display'}],
display_options, display_options,
i; i;
action_list = links.worklist;
for (i = 0; i < action_list.length; i += 1) { for (i = 0; i < action_list.length; i += 1) {
query_string = new URI(action_list[i].href).query(true).query; query_string = new URI(action_list[i].href).query(true).query;
display_options = {extended_search: query_string}; display_options = {extended_search: query_string};
...@@ -73,31 +67,39 @@ ...@@ -73,31 +67,39 @@
page: 'search' page: 'search'
}; };
} }
promise_list.push(RSVP.all([ url_for_parameter_list.push(
gadget.getUrlFor({command: 'display_stored_state', options: display_options}), {command: 'display_stored_state', options: display_options}
// Remove the counter from the title );
action_list[i].name,
action_list[i].count
]));
} }
return RSVP.all(promise_list); return RSVP.all([
gadget.translate('All work caught up!'),
gadget.getUrlForList(url_for_parameter_list)
]);
}) })
// Add in the page
.push(function (result_list) { .push(function (result_list) {
var line_list = [], var line_list = [],
url_list = result_list[1],
i; i;
for (i = 1; i < result_list.length; i += 1) { for (i = 1; i < url_list.length; i += 1) {
line_list.push({ line_list.push({
link: result_list[i][0], link: url_list[i],
title: result_list[i][1], // Remove the counter from the title
count: result_list[i][2] title: action_list[i - 1].name,
count: action_list[i - 1].count
}); });
} }
gadget.element.querySelector('.document_list').innerHTML = gadget.element.querySelector('.document_list').innerHTML =
table_template({ table_template({
document_list: line_list, document_list: line_list,
empty_text: result_list[0] empty_text: result_list[0]
}); });
return gadget.updateHeader({
page_title: 'Worklist',
page_icon: 'tasks',
front_url: url_list[0]
});
}); });
}); });
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>968.41423.51057.42700</string> </value> <value> <string>968.41441.46653.47513</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>1530534841.9</float> <float>1530535868.66</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