Commit 39926539 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_hal_json_style] Always return listbox_uid

Some dialog expect to get the line uid list, even if no cell was directly editable.
parent d4075cf4
...@@ -1873,7 +1873,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -1873,7 +1873,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
# ERP5 stores&send the list of editable elements in a hidden field called # ERP5 stores&send the list of editable elements in a hidden field called
# only database results can be editable so it belongs here # only database results can be editable so it belongs here
if editable_field_dict and listbox_field_id: if listbox_field_id:# and source_field.get_value("editable"):
contents_item['listbox_uid:list'] = { contents_item['listbox_uid:list'] = {
'key': "%s_uid:list" % listbox_field_id, 'key': "%s_uid:list" % listbox_field_id,
'value': contents_uid 'value': contents_uid
......
...@@ -1240,6 +1240,8 @@ return context.getPortalObject().foo_module.contentValues() ...@@ -1240,6 +1240,8 @@ return context.getPortalObject().foo_module.contentValues()
) )
result_dict = json.loads(result) result_dict = json.loads(result)
#editalble creation date is defined at proxy form #editalble creation date is defined at proxy form
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
self.assertEqual(result_dict['_embedded']['contents'][0]['creation_date']['field_gadget_param']['type'], 'DateTimeField') self.assertEqual(result_dict['_embedded']['contents'][0]['creation_date']['field_gadget_param']['type'], 'DateTimeField')
self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['field_gadget_param']['type'], 'DateTimeField') self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['field_gadget_param']['type'], 'DateTimeField')
# There is a count method on this listbox # There is a count method on this listbox
...@@ -1284,6 +1286,9 @@ return '%s/Base_viewMetadata?reset:int=1' % context.getRelativeUrl() ...@@ -1284,6 +1286,9 @@ return '%s/Base_viewMetadata?reset:int=1' % context.getRelativeUrl()
form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox') form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox')
result_dict = json.loads(result) result_dict = json.loads(result)
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
# Test the URL value # Test the URL value
self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['url_value']['command'], 'push_history') self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['url_value']['command'], 'push_history')
self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['url_value']['options']['jio_key'], self.portal.foo_module.contentValues()[0].getRelativeUrl()) self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['url_value']['options']['jio_key'], self.portal.foo_module.contentValues()[0].getRelativeUrl())
...@@ -1331,6 +1336,9 @@ return url ...@@ -1331,6 +1336,9 @@ return url
form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox') form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox')
result_dict = json.loads(result) result_dict = json.loads(result)
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
# Test the URL value # Test the URL value
self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['url_value']['command'], 'raw') self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['url_value']['command'], 'raw')
self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['url_value']['options']['url'], 'https://officejs.com') self.assertEqual(result_dict['_embedded']['contents'][0]['modification_date']['url_value']['options']['url'], 'https://officejs.com')
...@@ -1375,6 +1383,9 @@ return url ...@@ -1375,6 +1383,9 @@ return url
form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox') form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox')
result_dict = json.loads(result) result_dict = json.loads(result)
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
# Test the URL value # Test the URL value
self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['command'], 'raw') self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['command'], 'raw')
self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['options']['url'], 'https://officejs.com') self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['options']['url'], 'https://officejs.com')
...@@ -1415,6 +1426,9 @@ return context.getPortalObject().foo_module.contentValues() ...@@ -1415,6 +1426,9 @@ return context.getPortalObject().foo_module.contentValues()
form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox') form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox')
result_dict = json.loads(result) result_dict = json.loads(result)
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
# Test the URL value # Test the URL value
self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value'], {}) self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value'], {})
...@@ -1458,6 +1472,9 @@ return url ...@@ -1458,6 +1472,9 @@ return url
form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox') form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox')
result_dict = json.loads(result) result_dict = json.loads(result)
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
# Test the URL value # Test the URL value
self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['command'], 'raw') self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['command'], 'raw')
self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['options'].keys(), [u'url', u'reset']) self.assertEqual(result_dict['_embedded']['contents'][0]['title']['url_value']['options'].keys(), [u'url', u'reset'])
...@@ -1531,6 +1548,8 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id ...@@ -1531,6 +1548,8 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
) )
result_dict = json.loads(result) result_dict = json.loads(result)
self.assertEqual(2, len(result_dict['_embedded']['contents'])) self.assertEqual(2, len(result_dict['_embedded']['contents']))
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
self.assertIn("field_listbox", result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['key']) self.assertIn("field_listbox", result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['key'])
self.assertEqual("StringField", result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['type']) self.assertEqual("StringField", result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['type'])
self.assertEqual(document_list[0].getId(), result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['default']) self.assertEqual(document_list[0].getId(), result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['default'])
...@@ -1540,6 +1559,25 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id ...@@ -1540,6 +1559,25 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
# There is a count method on the listbox # There is a count method on the listbox
self.assertEqual(result_dict['_embedded']['count'], 0) self.assertEqual(result_dict['_embedded']['count'], 0)
# Render a Document without using Form Field template ('reference')
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request,
mode="search",
local_roles=["Assignor", "Assignee"],
list_method='Test_listProducts',
select_list=['reference'],
form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox'
)
result_dict = json.loads(result)
self.assertEqual(2, len(result_dict['_embedded']['contents']))
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
self.assertEqual(document_list[0].getReference(), result_dict['_embedded']['contents'][0]['reference'].encode('UTF-8'))
# There is a count method on the listbox
self.assertEqual(result_dict['_embedded']['count'], 0)
# Test rendering without form template of attribute, getterm and a script # Test rendering without form template of attribute, getterm and a script
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas( result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request, REQUEST=fake_request,
......
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