Commit 41430911 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: relation field: do not crash the UI if there is an issue on server side

parent f724815d
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
data-i18n=Create New data-i18n=Create New
data-i18n=Explore the Search Result List data-i18n=Explore the Search Result List
data-i18n=Invalid search criteria data-i18n=Invalid search criteria
data-i18n=You are offline
data-i18n=Unexpected server error
--> -->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
......
...@@ -152,11 +152,13 @@ ...@@ -152,11 +152,13 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -200,16 +202,20 @@ ...@@ -200,16 +202,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -232,7 +238,7 @@ ...@@ -232,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.59811.2178.43622</string> </value> <value> <string>978.11125.30548.29832</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -250,7 +256,7 @@ ...@@ -250,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1563201471.02</float> <float>1586446578.07</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -259,16 +265,20 @@ ...@@ -259,16 +265,20 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<key> <string>_log</string> </key>
<value>
<list> <list>
<dictionary> <dictionary>
<item> <item>
...@@ -318,7 +328,9 @@ ...@@ -318,7 +328,9 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
</tuple> </value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
/*jslint indent: 2, maxerr: 3, nomen: true, maxlen: 80 */ /*jslint indent: 2, maxerr: 3, nomen: true, maxlen: 80 */
/*global window, rJS, RSVP, URI, /*global window, rJS, RSVP, URI,
SimpleQuery, ComplexQuery, Query, QueryFactory, document*/ SimpleQuery, ComplexQuery, Query, QueryFactory, document, XMLHttpRequest,
console*/
(function (window, rJS, RSVP, URI, document, (function (window, rJS, RSVP, URI, document,
SimpleQuery, ComplexQuery, Query, QueryFactory) { SimpleQuery, ComplexQuery, Query, QueryFactory, XMLHttpRequest, console) {
"use strict"; "use strict";
function displayNonEditableLink(gadget) { function displayNonEditableLink(gadget) {
...@@ -419,6 +420,24 @@ ...@@ -419,6 +420,24 @@
return gadget.notifyInvalid(translation_list[0]); return gadget.notifyInvalid(translation_list[0]);
}); });
} }
// do not crash interface if allDocs fails
if (error.target instanceof XMLHttpRequest) {
console.warn(error);
return gadget.getTranslationList([
"You are offline",
"Unexpected server error"
])
.push(function (translation_list) {
if (error.target.status === 0) {
return gadget.notifyInvalid(translation_list[0]);
}
if (error.target.status >= 500) {
return gadget.notifyInvalid(translation_list[1]);
}
throw error;
});
}
// Crash by default
throw error; throw error;
}); });
}); });
...@@ -568,4 +587,4 @@ ...@@ -568,4 +587,4 @@
}, true, false); }, true, false);
}(window, rJS, RSVP, URI, document, }(window, rJS, RSVP, URI, document,
SimpleQuery, ComplexQuery, Query, QueryFactory)); SimpleQuery, ComplexQuery, Query, QueryFactory, XMLHttpRequest, console));
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>982.20937.32183.16281</string> </value> <value> <string>983.6083.54777.37051</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1583405380.32</float> <float>1586446542.77</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