Commit 14a1904e authored by Gabriel Monnerat's avatar Gabriel Monnerat Committed by Romain Courteaud

erp5_web_renderjs_ui: fix issue that erase current value from input

Avoid propagate empty value to change_state and only set new value if it is in modification_dict
parent 5ad2ec85
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
tmp; // general use short-scope variable tmp; // general use short-scope variable
if (this.state.type === 'checkbox') { if (this.state.type === 'checkbox') {
textarea.checked = this.state.checked; textarea.checked = this.state.checked;
} else { }
if (modification_dict.hasOwnProperty("value")) {
textarea.setAttribute('value', this.state.value); textarea.setAttribute('value', this.state.value);
textarea.value = this.state.value; textarea.value = this.state.value;
} }
...@@ -240,7 +242,6 @@ ...@@ -240,7 +242,6 @@
.declareJob('deferErrorText', function deferErrorText(error_text) { .declareJob('deferErrorText', function deferErrorText(error_text) {
var input = this.element.querySelector("input"); var input = this.element.querySelector("input");
return this.changeState({ return this.changeState({
value: input.value,
error_text: error_text error_text: error_text
}); });
}) })
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.27756.45244.12953</string> </value> <value> <string>990.27297.58624.60416</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>1603216380.65</float> <float>1614639525.14</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>testFloatFieldBrowserValidationMessage</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 issue with floating point and value disappearing</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test issue with floating point and value disappearing</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr><td>open</td>
<td>${base_url}/foo_module/1/Foo_createObjects?start:int=1&amp;num:int=1</td><td></td></tr>
<tr><td>open</td>
<td>${base_url}/foo_module/Zuite_waitForActivities</td><td></td></tr>
<!-- Shortcut for full renderjs url -->
<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>
<tr><td>waitForElementPresent</td>
<td>//input[@name="field_my_quantity"]</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tr><td>assertText</td>
<td>//div[@data-gadget-scope="field_my_quantity_read_only"]//p</td>
<td>0.0</td></tr>
<tr><td>assertValue</td>
<td>//input[@name="field_my_quantity"]</td>
<td>0.0</td></tr>
<tr>
<td>fireEvent</td>
<td>field_my_quantity</td>
<td>focus</td>
</tr>
<tr><td>assertElementNotPresent</td>
<td>//input[@name="field_my_quantity" and @class="is-invalid"]</td>
<td></td></tr>
<tr>
<tr>
<td>type</td>
<td>field_my_quantity</td>
<td>1.234</td>
</tr>
<tr><td>assertElementPresent</td>
<td>//input[@name="field_my_quantity" and @class="is-invalid"]</td>
<td></td></tr>
<tr>
<tr>
<td>assertValue</td>
<td>field_my_quantity</td>
<td>1.234</td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
...@@ -34,46 +34,25 @@ ...@@ -34,46 +34,25 @@
<tr><td>type</td> <tr><td>type</td>
<td>field_my_delivery_ratio</td> <td>field_my_delivery_ratio</td>
<td>12.34</td></tr> <td>12.34</td></tr>
<tr><td>fireEvent</td>
<td>field_my_quantity</td>
<td>blur</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_save" />
<tr><td>waitForElementPresent</td>
<td>//button[text()="Input data has errors."]</td><td></td></tr>
<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>
<tr> <tr>
<td>waitForElementPresent</td> <td>assertElementPresent</td>
<td>//input[@name="field_my_delivery_ratio" and @class="is-invalid"]</td> <td>//input[@name="field_my_delivery_ratio" and @class="is-invalid"]</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>waitForElementPresent</td>
<td>//input[@name="field_my_delivery_ratio" and @class="is-invalid"]</td>
<td></td>
</tr>
<tr>
<td>fireEvent</td>
<td>//input[@name="field_my_delivery_ratio" and @class="is-invalid"]</td>
<td>focus</td>
</tr>
<tr><td>assertElementPresent</td>
<td>//div[@data-gadget-scope="field_my_delivery_ratio"]//span[text()='The number you input has too large precision.']</td><td></td></tr>
<tr><td>type</td> <tr><td>type</td>
<td>field_my_delivery_ratio</td> <td>field_my_delivery_ratio</td>
<td>20.0</td></tr> <td>20.0</td></tr>
<tr><td>fireEvent</td>
<td>field_my_delivery_ratio</td>
<td>blur</td></tr>
<tr><td>assertElementNotPresent</td>
<td>//div[@data-gadget-scope="field_my_delivery_ratio"]//span[text()='The number you input has too large precision.']</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr><td>verifyValue</td> <tr><td>verifyValue</td>
<td>field_my_delivery_ratio</td> <td>field_my_delivery_ratio</td>
<td>20.0</td></tr> <td>20.0</td></tr>
<tr>
<td>assertElementNotPresent</td>
<td>//input[@name="field_my_delivery_ratio" and @class="is-invalid"]</td>
<td></td>
</tr>
<tr><td>verifyText</td> <tr><td>verifyText</td>
<td>//div[@data-gadget-scope="field_my_delivery_ratio_read_only"]//p</td> <td>//div[@data-gadget-scope="field_my_delivery_ratio_read_only"]//p</td>
<td>20.0%</td></tr> <td>20.0%</td></tr>
......
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
<tr><td>assertElementPresent</td> <tr><td>assertElementPresent</td>
<td>//p[@id='field_my_delivery_ratio_read_only' and text()='1,0000']</td> <td>//p[@id='field_my_delivery_ratio_read_only' and text()='1,0000']</td>
<td></td></tr> <td></td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_your_empty_percent' and not(text())]</td>
<td></td></tr>
<tr><td>type</td> <tr><td>type</td>
<td>field_my_delivery_ratio</td> <td>field_my_delivery_ratio</td>
......
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