Commit 6aed2a71 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Warmup most used gadgets in ERP5 Form

Do the calculations while ERP5 renders the form in JSON
parent 4687f745
......@@ -7,6 +7,34 @@ and handling data send&receive.
(function (window, document, rJS, URI, RSVP, jIO, Blob, URL, asBoolean) {
"use strict";
var warmup_gadget_done = false,
warmup_list = ['gadget_erp5_label_field.html',
'gadget_erp5_pt_form_list.html',
'gadget_erp5_pt_form_dialog.html',
'gadget_erp5_pt_form_view_editable.html',
'gadget_erp5_pt_form_view.html',
'gadget_erp5_pt_embedded_form_render.html',
'gadget_html5_input.html',
'gadget_html5_textarea.html',
'gadget_html5_input.html',
'gadget_html5_select.html',
'gadget_html5_element.html',
'gadget_erp5_field_datetime.html',
'gadget_erp5_field_float.html',
'gadget_erp5_field_integer.html',
'gadget_erp5_field_list.html',
'gadget_erp5_field_email.html',
'gadget_erp5_field_formbox.html',
'gadget_erp5_field_listbox.html',
'gadget_erp5_field_multilist.html',
'gadget_erp5_field_relationstring.html',
'gadget_erp5_field_multirelationstring.html',
'gadget_erp5_relation_input.html',
'gadget_erp5_field_string.html',
'gadget_erp5_field_textarea.html',
'gadget_erp5_form.html'
];
/** Return local modifications to editable form fields after leaving the form
for a while - for example selecting a related object.
......@@ -132,7 +160,26 @@ and handling data send&receive.
} else {
promise_queue
.push(function () {
return gadget.jio_getAttachment(options.jio_key, options.view);
var result = gadget.jio_getAttachment(options.jio_key,
options.view),
i;
if (!warmup_gadget_done) {
// In order to speed up initial form rendering,
// preload most used gadgets while waiting for ERP5 form
// calculation
// Wait a big for the ajax query to be triggered
RSVP.delay(10)
.then(function () {
for (i = 0; i < warmup_list.length; i += 1) {
// No need to check the result, as it will fail later
// when rJS will try to instanciate one of this gadget
rJS.declareGadgetKlass(rJS.getAbsoluteURL(warmup_list[i],
gadget.__path));
}
});
warmup_gadget_done = true;
}
return result;
})
.push(function (result) {
new_state.erp5_document = result;
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.9690.7007.38997</string> </value>
<value> <string>970.64578.22606.18107</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,8 +248,8 @@
</tuple>
<state>
<tuple>
<float>1520945628.31</float>
<string>GMT+1</string>
<float>1539702055.43</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
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