Commit 8f2221ca authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: Display notification when there is only a required field blocking the form

parent baf5d3aa
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>View With Validation Error</string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_with_validation_error_field</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>5.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View With Validation Error</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Foo_viewWithValidationError</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_first_failure</string>
<string>your_second_failure</string>
<string>your_third_failure</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Foo_viewWithValidationError</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Foo_viewWithValidationError</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Validation Error</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -58,4 +58,5 @@ Foo | view_print_dialog
Foo | view_printout_form
Foo | view_proxy_field
Foo | view_relation_field
Foo | view_url_parameter_dialog
\ No newline at end of file
Foo | view_url_parameter_dialog
Foo | view_with_validation_error_field
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=Update
data-i18n=Proceed
data-i18n=Cancel
data-i18n=Please fill all required fields to submit
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 PT Form Dialog</title>
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.11125.30548.29832</string> </value>
<value> <string>991.40916.23937.38946</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1581694316.93</float>
<float>1619388750.92</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -45,7 +45,13 @@
.push(function (is_valid) {
if (!is_valid) {
enableButton();
return;
return gadget.translate("Please fill all required fields to submit")
.push(function (message) {
return gadget.notifyChange({
"message": message,
"status": "error"
});
});
}
return getContent.apply(gadget)
.push(function (content_dict) {
......@@ -154,6 +160,8 @@
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("submitContent", "submitContent")
.allowPublicAcquisition("submitDialogWithCustomDialogMethod",
submitDialogWithCustomDialogMethod)
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.241.33421.16076</string> </value>
<value> <string>991.43808.38688.31368</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1601565340.43</float>
<float>1619563339.95</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -2,9 +2,7 @@
<html>
<head>
<!--
data-i18n=Action not handled
data-i18n=Nothing selected
data-i18n=Copied
data-i18n=Please fill all required fields to submit
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.48721.18403.49049</string> </value>
<value> <string>991.42429.55366.24695</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1554191271.73</float>
<float>1619479605.66</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -9,6 +9,7 @@
.declareAcquiredMethod("submitContent", "submitContent")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod('isDesktopMedia', 'isDesktopMedia')
......@@ -157,7 +158,16 @@
})
.push(function (is_valid) {
if (!is_valid) {
return null;
return gadget.translate("Please fill all required fields to submit")
.push(function (message) {
return gadget.notifyChange({
"message": message,
"status": "error"
});
})
.push(function () {
return null;
});
}
return gadget.getContent();
})
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.2796.18260.40345</string> </value>
<value> <string>991.43808.38688.31368</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1570779670.8</float>
<float>1619563288.81</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -48,16 +48,14 @@
</tr>
<!-- Fill long string to provoke form validation failure -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'error', 'text': 'Please fill all required fields to submit'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr>
<td>fireEvent</td>
<td>//input[@name="field_your_sixth_failure"]</td>
<td>focus</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][6]/div/span</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][6]/div/span[contains(text(), "Please fill out this field.")]</td>
......@@ -78,11 +76,10 @@
<td>field_your_sixth_failure</td>
<td>ABCD</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][8]/div/div/label[@class="is-invalid"][1]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'error', 'text': 'Please fill all required fields to submit'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][8]/div/div/label[@class="is-invalid"][1]</td>
......@@ -98,11 +95,7 @@
<td>//input[@name="field_your_eighth_failure" and @value="A"]</td>
<td>focus</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][8]/div/span[contains(text(), "Input is required but no input given.")]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][8]/div/span[contains(text(), "Input is required but no input given.")]</td>
......
<?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>testFormViewWithMultipleValidationError</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 Workflow Transition with Invalid Form</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Workflow Transition with Invalid Form</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr>
<td>store</td>
<td>${base_url}/web_site_module/renderjs_runner</td>
<td>renderjs_url</td>
</tr>
<tr>
<td>open</td>
<td>${renderjs_url}/#/foo_module/1?editable=1</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'View With Validation Error'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_panel_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>fireEvent</td>
<td>//input[@name="field_your_third_failure"]</td>
<td>focus</td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][3]/div/span</td>
<td></td>
</tr>
<tr>
<td>fireEvent</td>
<td>//input[@name="field_your_third_failure"]</td>
<td>blur</td>
</tr>
<!-- Fill long string to provoke form validation failure -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_save" />
<tal:block tal:define="notification_configuration python: {'class': 'error', 'text': 'Please fill all required fields to submit'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr>
<td>fireEvent</td>
<td>//input[@name="field_your_third_failure"]</td>
<td>focus</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][3]/div/span[contains(text(), "Please fill out this field.")]</td>
<td></td>
</tr>
<tr>
<td>fireEvent</td>
<td>//input[@name="field_your_third_failure"]</td>
<td>blur</td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//div[@data-gadget-url="${renderjs_url}/gadget_erp5_label_field.html"][3]/div/span[contains(text(), "Please fill out this field.")]</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>field_your_third_failure</td>
<td>ABCD</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_save" />
<tal:block tal:define="notification_configuration python: {'class': 'error', 'text': 'Input data has errors.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
</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