Commit 93f39e70 authored by Tristan Cavelier's avatar Tristan Cavelier

[erp5_web_renderjs_ui] Handle errors while typing in a relation input

For instance, typing a backslash in a relation field does not crash the ui anymore.

/bug #20180123-D78557
https://nexedijs.erp5.net/#/bug_module/20180123-D78557
parent 506f9cd6
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
data-i18n=No such document was found data-i18n=No such document was found
data-i18n=Create New data-i18n=Create New
data-i18n=Explore the Search Result List data-i18n=Explore the Search Result List
data-i18n=No such document was found data-i18n=Invalid search criteria
--> -->
<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" />
......
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.20733.1333.20838</string> </value> <value> <string>974.59811.2178.43622</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1541150851.14</float> <float>1563201471.02</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -243,7 +243,8 @@ ...@@ -243,7 +243,8 @@
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
var plane = gadget.element.querySelector("a"), var plane = gadget.element.querySelector("a"),
ul = gadget.element.querySelector(".search_ul"); ul = gadget.element.querySelector(".search_ul"),
translation_promise;
plane.href = ''; plane.href = '';
// uid is known // uid is known
...@@ -309,8 +310,12 @@ ...@@ -309,8 +310,12 @@
return RSVP.delay(200); return RSVP.delay(200);
}) })
.push(function () { .push(function () {
return RSVP.all([ translation_promise = gadget.getTranslationList([
gadget.jio_allDocs({ 'Create New',
'Explore the Search Result List'
]);
return gadget.jio_allDocs({
query: Query.objectToSearchText(new ComplexQuery({ query: Query.objectToSearchText(new ComplexQuery({
operator: "AND", operator: "AND",
query_list: [ query_list: [
...@@ -326,12 +331,11 @@ ...@@ -326,12 +331,11 @@
limit: [0, 10], limit: [0, 10],
select_list: [gadget.state.catalog_index, "uid"], select_list: [gadget.state.catalog_index, "uid"],
sort_on: JSON.parse(gadget.state.sort_list_json) sort_on: JSON.parse(gadget.state.sort_list_json)
}), })
gadget.getTranslationList([ .push(function (result) {
'Create New', return new RSVP.Queue()
'Explore the Search Result List' .push(function () {
]) return RSVP.all([result, translation_promise]);
]);
}) })
.push(function (result_list) { .push(function (result_list) {
var i, var i,
...@@ -395,6 +399,22 @@ ...@@ -395,6 +399,22 @@
ul.removeChild(ul.firstChild); ul.removeChild(ul.firstChild);
} }
ul.appendChild(fragment_element); ul.appendChild(fragment_element);
});
}, function (error) {
if (error instanceof Error &&
error.hash &&
error.hash.expected &&
error.hash.expected.length === 1 &&
error.hash.expected[0] === "'QUOTE'") {
return gadget.getTranslationList([
"Invalid search criteria"
])
.push(function (translation_list) {
return gadget.notifyInvalid(translation_list[0]);
});
}
throw error;
});
}); });
}); });
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.23288.3697.17425</string> </value> <value> <string>977.6117.6830.21572</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1541156739.42</float> <float>1563260997.53</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -311,7 +311,7 @@ ...@@ -311,7 +311,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1541669313.00</float> <float>1541669313.0</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testRelationFieldBackslash</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test RenderJS UI</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test RenderJS UI</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<!-- Clean Up -->
<tr>
<td>open</td>
<td>&#36;{base_url}/foo_module/ListBoxZuite_reset</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Reset Successfully.</td>
<td></td>
</tr>
<!-- Initialize -->
<tr>
<td>open</td>
<td>&#36;{base_url}/foo_module/FooModule_createObjects?num:int=1</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Created Successfully.</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr>
<td>open</td>
<td>&#36;{base_url}/web_site_module/renderjs_runner/#/foo_module?editable=true</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<!-- Go to foo_module/0 in View tab -->
<tr>
<td>waitForElementPresent</td>
<td>//a[text()="Title 0"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[text()="Title 0"]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<!-- Check the relation field does not crash when typing a backslash -->
<tr>
<td>type</td>
<td>//input[@name="field_my_foo_category_title"]</td>
<td>\</td>
</tr>
<tr>
<td>fireEvent</td>
<td>//input[@name='field_my_foo_category_title']</td>
<td>input</td>
</tr>
<tr>
<!-- This behavior may change.
Actually, this popup is displayed on internal query "syntax" error.
This error will be fixed later and so the popup won't be shown anymore. -->
<td>waitForTextPresent</td>
<td>Invalid search criteria</td>
<td></td>
</tr>
<!-- Check we can continue to work by selecting an existing category and save -->
<tr>
<td>type</td>
<td>//input[@name="field_my_foo_category_title"]</td>
<td>Quantity</td>
</tr>
<tr>
<td>fireEvent</td>
<td>//input[@name='field_my_foo_category_title']</td>
<td>input</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//li[@data-relative-url='portal_categories/divergence_scope/quantity']</td>
<td></td>
</tr>
<tr>
<td>fireEvent</td>
<td>//input[@name='field_my_foo_category_title']</td>
<td>blur</td>
</tr>
<tr>
<td>click</td>
<td>//li[@data-relative-url='portal_categories/divergence_scope/quantity']</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr>
<td>verifyValue</td>
<td>//input[@name="field_my_foo_category_title"]</td>
<td>Quantity</td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
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