Commit f230974a authored by Tristan Cavelier's avatar Tristan Cavelier

[erp5_web_renderjs_ui] fix listfield html5 element update

While rendering a field_list gadget in non-editable mode,
the `text_content` parameter was given only in the first `render` call.

/bug #20190204-39AF19
https://nexedijs.erp5.net/#/bug_module/20190204-39AF19

/reviewed-on nexedi/erp5!860
parent 156e665a
...@@ -52,24 +52,25 @@ ...@@ -52,24 +52,25 @@
} }
state.item_list = JSON.parse(this.state.item_list); state.item_list = JSON.parse(this.state.item_list);
if (modification_dict.hasOwnProperty('editable')) { if (this.state.editable) {
if (this.state.editable) { url = 'gadget_html5_select.html';
url = 'gadget_html5_select.html'; } else {
} else { url = 'gadget_html5_element.html';
url = 'gadget_html5_element.html';
item_list = state.item_list; item_list = state.item_list;
for (i = 0; i < item_list.length; i += 1) { for (i = 0; i < item_list.length; i += 1) {
if (item_list[i][1] === this.state.value) { if (item_list[i][1] === this.state.value) {
text_content = item_list[i][0]; text_content = item_list[i][0];
}
}
if (text_content === undefined) {
text_content = '??? (' + this.state.value + ')';
} }
state.text_content = text_content;
} }
if (text_content === undefined) {
text_content = '??? (' + this.state.value + ')';
}
state.text_content = text_content;
}
if (modification_dict.hasOwnProperty('editable')) {
result = this.declareGadget(url, {scope: 'sub'}) result = this.declareGadget(url, {scope: 'sub'})
.push(function (input) { .push(function (input) {
// Clear first to DOM, append after to reduce flickering/manip // Clear first to DOM, append after to reduce flickering/manip
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.14932.39176.42649</string> </value> <value> <string>975.29304.53589.37529</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1556038383.15</float> <float>1556814300.71</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>testListFieldUpdateNonEditable</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>${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>${base_url}/foo_module/FooModule_createObjects?num:int=1</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Created Successfully.</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/foo_module/0?editable=true</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//select[@name='field_my_local_title']</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>//select[@name='field_my_local_title']</td>
<td>First title</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr>
<td>click</td>
<td>//input[@name='editable']</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<!-- Actual test -->
<tr>
<td>assertTextPresent</td>
<td>First title</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[contains(@class, "active") and text()="View"]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertTextPresent</td>
<td>First title</td>
<td></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