Commit 599bbf90 authored by Tristan Cavelier's avatar Tristan Cavelier

[erp5_web_renderjs_ui] fix homonyms in a Multi Relation Field

/bug #20190204-1BF3A5A
https://nexedijs.erp5.net/#/bug_module/20190204-1BF3A5A

/reviewed-on !848
parent 051c6c2a
...@@ -565,7 +565,8 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, k ...@@ -565,7 +565,8 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, k
result.update({ result.update({
"relation_field_id": traversed_document.Field_getSubFieldKeyDict(field, "relation", key=result["key"]), "relation_field_id": traversed_document.Field_getSubFieldKeyDict(field, "relation", key=result["key"]),
"relation_item_key": traversed_document.Field_getSubFieldKeyDict(field, "item", key=result["key"]), "relation_item_key": traversed_document.Field_getSubFieldKeyDict(field, "item", key=result["key"]),
"relation_item_relative_url": [jump_reference.getRelativeUrl() for jump_reference in jump_reference_list] "relation_item_relative_url": [jump_reference.getRelativeUrl() for jump_reference in jump_reference_list],
"relation_item_uid": [jump_reference.getUid() for jump_reference in jump_reference_list],
}) })
return result return result
......
...@@ -6,7 +6,7 @@ big_category_list = ('c1', 'c10', 'c2', 'c20', 'c3', 'c4') ...@@ -6,7 +6,7 @@ big_category_list = ('c1', 'c10', 'c2', 'c20', 'c3', 'c4')
for i in range(start, start + num): for i in range(start, start + num):
category = category_list[i % len(category_list)] category = category_list[i % len(category_list)]
foo = context.newContent(id = str(i), title = 'Title %d' % i, quantity = 10.0 - float(i), foo = context.newContent(id=str(i), title=title_format.format(index=i), quantity=10.0 - float(i),
foo_category = category, portal_type=portal_type) foo_category = category, portal_type=portal_type)
if set_dates: if set_dates:
foo.setStartDate(DateTime(i, i, i)) foo.setStartDate(DateTime(i, i, i))
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>start=0, num=10, set_dates=0, portal_type=\'Foo\', create_line=0, big_category_related=False, category_list=None</string> </value> <value> <string>start=0, num=10, set_dates=0, portal_type=\'Foo\', create_line=0, big_category_related=False, category_list=None, title_format="Title {index:d}"</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -83,7 +83,8 @@ ...@@ -83,7 +83,8 @@
JSON.stringify(field_json.relation_item_relative_url); JSON.stringify(field_json.relation_item_relative_url);
state_dict.value_text_list = state_dict.value_text_list =
JSON.stringify(field_json.default); JSON.stringify(field_json.default);
state_dict.value_uid_list = JSON.stringify([]); state_dict.value_uid_list =
JSON.stringify(field_json.relation_item_uid);
state_dict.value_portal_type_list = JSON.stringify([]); state_dict.value_portal_type_list = JSON.stringify([]);
} }
return this.changeState(state_dict); return this.changeState(state_dict);
......
<?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>testMultiRelationFieldHomonyms</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=2&amp;title_format=Title0</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Created Successfully.</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=2&amp;num:int=2&amp;title_format=Title{index:d}</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</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>${base_url}/web_site_module/renderjs_runner/#/foo_module/3?editable=true</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tr>
<td>click</td>
<td>//a[text()="Relation Fields"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//input[@name="field_my_bar_category_title_list"]</td>
<td></td>
</tr>
<!-- Actual test -->
<tr> <!-- type the homonym in the mulit relation field and choose the whatever element (second for instance) -->
<td>type</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//fieldset[1]//input</td>
<td>Title0</td>
</tr>
<tr>
<td>fireEvent</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//fieldset[1]//input</td>
<td>input</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//ul[@class="search_ul"]//li</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//ul[@class="search_ul"]/li[2]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr> <!-- add another entry to the multi relation field -->
<td>type</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//fieldset[2]//input</td>
<td>Title2</td>
</tr>
<tr>
<td>fireEvent</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//fieldset[2]//input</td>
<td>input</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//ul[@class="search_ul"]//li</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//ul[@class="search_ul"]/li[1]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr> <!-- Check field values -->
<td>verifyValue</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//fieldset[1]//input</td>
<td>Title0</td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//fieldset[2]//input</td>
<td>Title2</td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@data-gadget-scope="field_my_bar_category_title_list"]//fieldset[3]//input</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