From c888c5457518c1ab0cd97215444d1d15975feec5 Mon Sep 17 00:00:00 2001 From: Xiaowu Zhang <xiaowu.zhang@nexedi.com> Date: Thu, 18 Jan 2018 08:57:52 +0000 Subject: [PATCH] erp5_hal_json_style: show correctly workflow title on history view --- .../ERP5Document_getHateoas.py | 12 +- .../testReportViewDisplayWorkflowTitle.xml | 58 +++++++++ .../testReportViewDisplayWorkflowTitle.zpt | 118 ++++++++++++++++++ 3 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testReportViewDisplayWorkflowTitle.xml create mode 100644 bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testReportViewDisplayWorkflowTitle.zpt diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py index 433c7a63f4..dc9a4bc6c5 100644 --- a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py @@ -937,7 +937,17 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti report_form_params = report_item.selection_params.copy() \ if report_item.selection_params is not None \ else {} - + # request.prefixed_selection_name maybe used in tales expression + if report_form: + listbox = getattr(getattr(report_context, report_form), 'listbox', None) + if listbox is not None: + listbox_selection_name = report_prefix + "_" + listbox.get_value('selection_name') + REQUEST.other['prefixed_selection_name'] = listbox_selection_name + if report_form_params: + params = portal.portal_selections.getSelectionParamsFor(listbox_selection_name) + params.update(report_form_params) + portal.portal_selections.setSelectionParamsFor(listbox_selection_name,params) + if report_item.selection_name: selection_name = report_prefix + "_" + report_item.selection_name report_form_params.update(selection_name=selection_name) diff --git a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testReportViewDisplayWorkflowTitle.xml b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testReportViewDisplayWorkflowTitle.xml new file mode 100644 index 0000000000..1737b598e2 --- /dev/null +++ b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testReportViewDisplayWorkflowTitle.xml @@ -0,0 +1,58 @@ +<?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>testReportViewDisplayWorkflowTitle</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> diff --git a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testReportViewDisplayWorkflowTitle.zpt b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testReportViewDisplayWorkflowTitle.zpt new file mode 100644 index 0000000000..bdd243d9a4 --- /dev/null +++ b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_page_templates_zuite/testReportViewDisplayWorkflowTitle.zpt @@ -0,0 +1,118 @@ +<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 Report View Workflow Title</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">Test Report View Workflow Title</td></tr> +</thead><tbody> +<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" /> + +<tr> + <td>open</td> + <td>${base_url}/web_site_module/renderjs_runner/#/foo_module/1?page=tab</td> + <td></td> +</tr> + +<!-- Wait for gadget to be loaded --> +<tr> + <td>waitForElementPresent</td> + <td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_tab.html']</td> + <td></td> +</tr> +<tr> + <td>waitForTextPresent</td> + <td>Title 1</td> + <td></td> +</tr> + +<!-- Follow one link --> +<tr> + <td>click</td> + <td>//div[@data-gadget-scope='m']//a[text()='History' and contains(@href, '#!change') and contains(@href, 'history') and contains(@href, 'u.page=')]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_pt_report_view.html']</td> + <td></td> +</tr> +<tr> + <td>waitForTextPresent</td> + <td>Current</td> + <td></td> +</tr> +<tr> + <td>waitForTextPresent</td> + <td>Draft</td> + <td></td> +</tr> + +<tr> + <td>verifyElementPresent</td> + <td>//h1[@data-i18n='Edit Workflow']</td> + <td></td> +</tr> + + +<tr> + <td>verifyElementPresent</td> + <td>//h1[@data-i18n='Foo Workflow']</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/#/web_page_module/rjs_renderjs_js?page=tab</td> + <td></td> +</tr> + +<tr> + <td>waitForElementPresent</td> + <td>//div[@data-gadget-scope='m']//a[text()='History' and contains(@href, '#!change') and contains(@href, 'history') and contains(@href, 'u.page=')]</td> + <td></td> +</tr> + +<tr> + <td>click</td> + <td>//div[@data-gadget-scope='m']//a[text()='History' and contains(@href, '#!change') and contains(@href, 'history') and contains(@href, 'u.page=')]</td> + <td></td> +</tr> + +<tr> + <td>waitForElementPresent</td> + <td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_pt_report_view.html']</td> + <td></td> +</tr> + + +<tr> + <td>waitForElementPresent</td> + <td>//h1[@data-i18n='External Processing Workflow']</td> + <td></td> +</tr> + + + +<tr> + <td>verifyElementPresent</td> + <td>//h1[@data-i18n='Document Publication Workflow']</td> + <td></td> +</tr> + + +<tr> + <td>verifyElementPresent</td> + <td>//h1[@data-i18n='Edit Workflow']</td> + <td></td> +</tr> + + +</tbody></table> +</body> +</html> \ No newline at end of file -- 2.30.9