diff --git a/bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py b/bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py index f87476a64956eab76da0fecec1d83fba418fd76c..d7fac228c4cc1da70e93eef9b0b826c288833550 100644 --- a/bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py +++ b/bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py @@ -108,6 +108,7 @@ def WorkflowTool_listActionParameterList(self): def Base_renderFormAtEndOfTransaction(self, request, response, form_id, **kw): def renderFormAndSetResponseBody(context, request, response, form_id, **kw): kw['message'] = request.get('portal_status_message') or kw['message'] + kw['level'] = request.get('portal_status_level') or kw.get('level') response.setBody(context.Base_renderForm(form_id, **kw)) transaction.get().addBeforeCommitHook( diff --git a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts/Foo_setTitle.py b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts/Foo_setTitle.py index 3d78cb262c8211ad415cb80bbb05a49d038c52a4..f7acba634b32a382d7bac5a65608157bd11df4ea 100644 --- a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts/Foo_setTitle.py +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts/Foo_setTitle.py @@ -1,3 +1,9 @@ foo = sci['object'] +request = container.REQUEST + if sci['kwargs']['workflow_method_args'] == ('before commit',): foo.setShortTitle("set by interaction workflow") + +if sci['kwargs']['workflow_method_args'] == ('Custom Message',): + request.set('portal_status_message', 'Custom Message.') + request.set('portal_status_level', 'error') diff --git a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_notification_zuite/testFormViewEditableSaveCustomMessage.xml b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_notification_zuite/testFormViewEditableSaveCustomMessage.xml new file mode 100644 index 0000000000000000000000000000000000000000..a9437d673daa0650bee9daceb618e1332df85db5 --- /dev/null +++ b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_notification_zuite/testFormViewEditableSaveCustomMessage.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>testFormViewEditableSaveCustomMessage</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_notification_zuite/testFormViewEditableSaveCustomMessage.zpt b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_notification_zuite/testFormViewEditableSaveCustomMessage.zpt new file mode 100644 index 0000000000000000000000000000000000000000..f628fb0a3fbff1a86fc7a935eb928e3756ffe6df --- /dev/null +++ b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_notification_zuite/testFormViewEditableSaveCustomMessage.zpt @@ -0,0 +1,76 @@ +<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 Custom Message for View Editable Save Action</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">Test Custom Message for View Editable Save Action</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?editable=true</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_pt_form_view_editable.html']</td> + <td></td> +</tr> +<tr> + <td>waitForTextPresent</td> + <td>Title 1</td> + <td></td> +</tr> + +<!-- Header has a save button --> +<tr> + <td>assertElementPresent</td> + <td>//div[@data-gadget-scope='header']//button[text()='Save' and @type='submit']</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>field_my_title</td> + <td>Custom Message</td> +</tr> +<tr> + <td>click</td> + <td>//div[@data-gadget-scope='header']//button[text()='Save' and @type='submit']</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>//div[@data-gadget-scope='header']//button[text()='Save' and @type='submit' and contains(@class, 'ui-icon-check')]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>//div[@data-gadget-scope='header']//a[text()='Foo: Custom Message' and contains(@href, '#!history_previous')]</td> + <td></td> +</tr> +<tr> + <td>assertTextNotPresent</td> + <td>Title 1</td> + <td></td> +</tr> + +<tal:block tal:define="notification_configuration python: {'class': 'error', + 'text': 'Custom Message.'}"> + <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" /> +</tal:block> + +</tbody></table> +</body> +</html> \ No newline at end of file