Commit e95b12d2 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_core/erp5_hal_json_style] Allow to use template in ERP5JS

parent 88f24700
<?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>testTemplatePreference</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 Template Preference</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<!-- Initialize -->
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/accounting_module</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': 'Add'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_header_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>select</td>
<td>//select[@name='field_your_select_action']</td>
<td>label=Sale Invoice Transaction</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': 'Object created.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>store</td>
<td tal:content="python: 'My foobar document %s' % DateTime()"></td>
<td>original_title</td>
</tr>
<tr>
<td>type</td>
<td>name=field_my_title</td>
<td>${original_title}</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tal:block tal:define="click_configuration python: {'text': 'Actions'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_header_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Make a Template'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_page_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': 'Templated created.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<!-- change the title to prevent possible confusion with the document created later -->
<tr>
<td>type</td>
<td>name=field_my_title</td>
<td>${original_title} old</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<!-- be sure the preference is indexed -->
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<!-- go to the module, and create a document from the template -->
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/accounting_module</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': 'Add'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_header_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>select</td>
<td>//select[@name='field_your_select_action']</td>
<td>label=${original_title}</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': 'Template created.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertValue</td>
<td>name=field_my_title</td>
<td>${original_title}</td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
portal = context.getPortalObject() portal = context.getPortalObject()
request = context.REQUEST
Base_translateString = portal.Base_translateString Base_translateString = portal.Base_translateString
preserved_parameter_dict = {} preserved_parameter_dict = {}
...@@ -10,8 +11,8 @@ kw['keep_items'] = preserved_parameter_dict ...@@ -10,8 +11,8 @@ kw['keep_items'] = preserved_parameter_dict
if doAction0 == 'add': if doAction0 == 'add':
return context.Folder_create(' '.join(Base_doAction[1:]), **kw) return context.Folder_create(' '.join(Base_doAction[1:]), **kw)
# Otherwise, check if this is an automatic menu (template) # Otherwise, check if this is an automatic menu (template)
"""
elif doAction0 == 'template': elif doAction0 == 'template':
template_relative_url = ' '.join(Base_doAction[1:]) template_relative_url = ' '.join(Base_doAction[1:])
template = context.getPortalObject().restrictedTraverse(template_relative_url) template = context.getPortalObject().restrictedTraverse(template_relative_url)
...@@ -23,14 +24,12 @@ elif doAction0 == 'template': ...@@ -23,14 +24,12 @@ elif doAction0 == 'template':
new_content = context[new_content_id] new_content = context[new_content_id]
new_content.makeTemplateInstance() new_content.makeTemplateInstance()
preserved_parameter_dict['portal_status_message'] = Base_translateString("Template created.") preserved_parameter_dict['portal_status_message'] = Base_translateString("Template created.")
redirect_url = new_content.absolute_url() return new_content.Base_redirect(keep_items=preserved_parameter_dict)
else: else:
preserved_parameter_dict['portal_status_message'] = Base_translateString("Template does not exist.") message = Base_translateString("Template does not exist.")
redirect_url = context.absolute_url()
else: else:
redirect_url = request['ACTUAL_URL'] message = Base_translateString('Error: the action "%s" is not recognised.' % (doAction0, ))
preserved_parameter_dict['portal_status_message'] =
""" request.RESPONSE.setStatus(400)
message = Base_translateString('Error: the action "%s" is not recognised.' % (doAction0, ))
context.REQUEST.RESPONSE.setStatus(400)
return context.Base_renderForm(dialog_id, message=message, level='error') return context.Base_renderForm(dialog_id, message=message, level='error')
translate = context.Base_translateString
result_list = [(translate(x), 'add %s' % x) for x in context.getVisibleAllowedContentTypeList()]
# Template
document_template_list = context.getDocumentTemplateList()
if document_template_list:
result_list.append(('-- %s --' % translate('Templates'), None))
for document_template in document_template_list:
result_list.append((document_template.getTitle(), 'template %s' % document_template.getRelativeUrl()))
return result_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getNewContentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: [(here.Base_translateString(x), \'add %s\' % x) for x in context.getVisibleAllowedContentTypeList()]</string> </value> <value> <string>python: here.Base_getNewContentList()</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</item> </item>
<item> <item>
<key> <string>category</string> </key> <key> <string>category</string> </key>
<value> <string>object_action</string> </value> <value> <string>object_jio_action</string> </value>
</item> </item>
<item> <item>
<key> <string>condition</string> </key> <key> <string>condition</string> </key>
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/Base_makeTemplateFromDocument</string> </value> <value> <string>string:${object_url}/Base_viewMakeTemplateFromDocumentDialog</string> </value>
  • This seem to introduce a failure in testFunctionalCore's "Test Accounting Transaction Template", probably just because there is now a new dialog on which we need to click OK.

  • ( I expected to be able to work on a fix today, but the day was too short )

  • 6ff0893f seems to be a fix for that

Please register or sign in to reply
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -32,6 +32,6 @@ template.makeTemplate() ...@@ -32,6 +32,6 @@ template.makeTemplate()
context.portal_caches.clearCacheFactory('erp5_ui_short') context.portal_caches.clearCacheFactory('erp5_ui_short')
kw['keep_items'] = dict(portal_status_message=message)
return context.Base_redirect(form_id, return context.Base_redirect(form_id,
keep_items=dict(portal_status_message=message),
**kw) **kw)
<?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_makeTemplateFromDocument</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>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>Default</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>Default</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_viewMakeTemplateFromDocumentDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Base_viewMakeTemplateFromDocumentDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</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>Make Template</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>
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