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 9157a1a062a2810755a1f994d4c26efe61e9fbc7..f87476a64956eab76da0fecec1d83fba418fd76c 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 @@ -2,7 +2,7 @@ from Acquisition import aq_self, aq_base, aq_inner from Products.ERP5Type.Utils import UpperCase from ZODB.POSException import ConflictError from AccessControl import Unauthorized - +import transaction def Base_aqSelf(self): return aq_self(self) @@ -103,3 +103,16 @@ def WorkflowTool_listActionParameterList(self): return result_list + + +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'] + response.setBody(context.Base_renderForm(form_id, **kw)) + + transaction.get().addBeforeCommitHook( + renderFormAndSetResponseBody, ( + self, + request, + response, + form_id,), kw) \ No newline at end of file diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_edit.py b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_edit.py index a9dd50df0c083644ca479e092c3a0dc42bd41677..7c6492c9bd440be0b0f7eb2dd1e3f448795da3d0 100644 --- a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_edit.py +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_edit.py @@ -254,9 +254,11 @@ if context.REQUEST.get('is_web_mode', False) and \ not editable_mode: form_id = 'view' -# Directly render the form after a successful edit +# Directly render the form after a successful edit, but in a before commit +# hook, so that if interactions modify the state we render the new state. + # Cleanup formulator's special key in request to ensure field are only calculated from context and not the request anymore for key in list(context.REQUEST.keys()): if str(key).startswith('field') or str(key).startswith('subfield'): context.REQUEST.form.pop(key, None) -return context.Base_renderForm(form_id, message=message) +return context.Base_renderFormAtEndOfTransaction(request, request.response, form_id, message=message) diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_renderFormAtEndOfTransaction.xml b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_renderFormAtEndOfTransaction.xml new file mode 100644 index 0000000000000000000000000000000000000000..4d29ee60fa5bcdd04d6cba41a3d9098ba6aafce2 --- /dev/null +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_renderFormAtEndOfTransaction.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _function + Base_renderFormAtEndOfTransaction + + + _module + HalStyle + + + id + Base_renderFormAtEndOfTransaction + + + title + + + + + + diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testEditWithBeforeCommitInteractionWorkflow.xml b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testEditWithBeforeCommitInteractionWorkflow.xml new file mode 100644 index 0000000000000000000000000000000000000000..58fab0aa3b60fddf2d2877f57addfee7c4e269a9 --- /dev/null +++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testEditWithBeforeCommitInteractionWorkflow.xml @@ -0,0 +1,58 @@ + + + + + + + + + + _bind_names + + + + + + + + + + _asgns + + + + name_subpath + traverse_subpath + + + + + + + + + + + content_type + text/html + + + expand + 0 + + + id + testEditWithBeforeCommitInteractionWorkflow + + + output_encoding + utf-8 + + + title + + + + + + diff --git a/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testEditWithBeforeCommitInteractionWorkflow.zpt b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testEditWithBeforeCommitInteractionWorkflow.zpt new file mode 100644 index 0000000000000000000000000000000000000000..83d684aaee44c62b5c0b73be2644656a9f556735 --- /dev/null +++ b/bt5/erp5_ui_test/PathTemplateItem/portal_tests/document_zuite/testEditWithBeforeCommitInteractionWorkflow.zpt @@ -0,0 +1,71 @@ + + + +Test Edit with "Before Commit" interaction worklow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test Edit with "Before Commit" interaction worklow
open${base_url}/foo_module/FooModule_createObjects?num:int=1
assertTextPresentCreated Successfully.
open${base_url}/foo_module/Zuite_waitForActivities
assertTextPresentDone.
open${base_url}/foo_module/0
typefield_my_titlebefore commit
clickAndWaitBase_edit:method
assertValuefield_my_titlebefore commit
assertValuefield_my_short_titleset by interaction workflow
open${base_url}/foo_module/Zuite_waitForActivities
assertTextPresentDone.
+ + \ No newline at end of file diff --git a/bt5/erp5_ui_test/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/bt5/erp5_ui_test/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml index 18945ee6615fad360758a9a5bd6e8afb9e66cc33..b0d2d47f6c5a847ed946b668ac84162a2511a1b3 100644 --- a/bt5/erp5_ui_test/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml +++ b/bt5/erp5_ui_test/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml @@ -1,11 +1,11 @@ Bar - edit_workflow, foo_workflow, bar_validation_workflow + bar_validation_workflow, edit_workflow, foo_workflow Foo - edit_workflow, foo_workflow, foo_validation_workflow + edit_workflow, foo_interaction_workflow, foo_validation_workflow, foo_workflow Foo Line diff --git a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow.xml b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow.xml new file mode 100644 index 0000000000000000000000000000000000000000..3178e6f5e479a1a9ea75c22120af5689d6491a5f --- /dev/null +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _objects + + + + + + groups + + + + + + id + foo_interaction_workflow + + + + + diff --git a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/interactions.xml b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/interactions.xml new file mode 100644 index 0000000000000000000000000000000000000000..e18bf8cbf778a6808aa24ec39bba4b527d7b1bef --- /dev/null +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/interactions.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _mapping + + + + + + _objects + + + + + + id + interactions + + + + + diff --git a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/interactions/setTitle.xml b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/interactions/setTitle.xml new file mode 100644 index 0000000000000000000000000000000000000000..14345fc16d3a736b7178529325db978b5c145d09 --- /dev/null +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/interactions/setTitle.xml @@ -0,0 +1,100 @@ + + + + + + + + + + actbox_category + workflow + + + actbox_name + + + + actbox_url + + + + activate_script_name + + + + + + after_script_name + + + + + + before_commit_script_name + + + Foo_setTitle + + + + + description + + + + guard + + + + + + id + setTitle + + + method_id + + + _setTitle + + + + + once_per_transaction + 1 + + + portal_type_filter + + + + + + portal_type_group_filter + + + + + + script_name + + + + + + temporary_document_disallowed + 0 + + + title + + + + trigger_type + 2 + + + + + diff --git a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts.xml b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts.xml new file mode 100644 index 0000000000000000000000000000000000000000..072c8f6540c07806bee17a34c920ec09b2de1bd5 --- /dev/null +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts.xml @@ -0,0 +1,28 @@ + + + + + + + + + + _mapping + + + + + + _objects + + + + + + id + scripts + + + + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..3d78cb262c8211ad415cb80bbb05a49d038c52a4 --- /dev/null +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts/Foo_setTitle.py @@ -0,0 +1,3 @@ +foo = sci['object'] +if sci['kwargs']['workflow_method_args'] == ('before commit',): + foo.setShortTitle("set by interaction workflow") diff --git a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts/Foo_setTitle.xml b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts/Foo_setTitle.xml new file mode 100644 index 0000000000000000000000000000000000000000..398133470b1a4e52dea3d09626dabc98d41ffcdc --- /dev/null +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/scripts/Foo_setTitle.xml @@ -0,0 +1,62 @@ + + + + + + + + + + Script_magic + 3 + + + _bind_names + + + + + + + + + + _asgns + + + + name_container + container + + + name_context + context + + + name_m_self + script + + + name_subpath + traverse_subpath + + + + + + + + + + + _params + sci + + + id + Foo_setTitle + + + + + diff --git a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/variables.xml b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/variables.xml new file mode 100644 index 0000000000000000000000000000000000000000..6ae03699d19840ac42b097dfc0a5f34edd416170 --- /dev/null +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/variables.xml @@ -0,0 +1,22 @@ + + + + + + + + + + _mapping + + + + + + id + variables + + + + + diff --git a/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/worklists.xml b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/worklists.xml new file mode 100644 index 0000000000000000000000000000000000000000..c3432aa051eac2d67ec0692a384adb38d1b6bac8 --- /dev/null +++ b/bt5/erp5_ui_test/WorkflowTemplateItem/portal_workflow/foo_interaction_workflow/worklists.xml @@ -0,0 +1,22 @@ + + + + + + + + + + _mapping + + + + + + id + worklists + + + + + diff --git a/bt5/erp5_ui_test/bt/template_action_path_list b/bt5/erp5_ui_test/bt/template_action_path_list index f889ec5ef50baf73a5a55772ecf2edc99694bc06..09519b1e67fefb315d60d2ba06237aa51ecee5b4 100644 --- a/bt5/erp5_ui_test/bt/template_action_path_list +++ b/bt5/erp5_ui_test/bt/template_action_path_list @@ -26,6 +26,7 @@ Foo | dummy_multicheckboxfield_report Foo | dummy_multilistfield_report Foo | dummy_radiofield_report Foo | dummy_report +Foo | fail_dialog_action_jio Foo | list Foo | python_action_jio Foo | python_error_action_jio diff --git a/bt5/erp5_ui_test/bt/template_portal_type_workflow_chain_list b/bt5/erp5_ui_test/bt/template_portal_type_workflow_chain_list index a84ae909f3a2f65291c5eedb6e83685c1d1abe3c..e48ed24645d0e62b1f23a604083d87d41280f3d4 100644 --- a/bt5/erp5_ui_test/bt/template_portal_type_workflow_chain_list +++ b/bt5/erp5_ui_test/bt/template_portal_type_workflow_chain_list @@ -1,7 +1,8 @@ +Bar | bar_validation_workflow Bar | edit_workflow Bar | foo_workflow -Bar | bar_validation_workflow Foo Line | pricing_interaction_workflow Foo | edit_workflow -Foo | foo_workflow +Foo | foo_interaction_workflow Foo | foo_validation_workflow +Foo | foo_workflow \ No newline at end of file diff --git a/bt5/erp5_ui_test/bt/template_workflow_id_list b/bt5/erp5_ui_test/bt/template_workflow_id_list index 1f124af28b04b768085ed34990a621caee6289e9..55affe2d91b61f08b202540723da7ced33b156f1 100644 --- a/bt5/erp5_ui_test/bt/template_workflow_id_list +++ b/bt5/erp5_ui_test/bt/template_workflow_id_list @@ -1,3 +1,4 @@ bar_validation_workflow -foo_workflow +foo_interaction_workflow foo_validation_workflow +foo_workflow \ No newline at end of file diff --git a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testEditWithBeforeCommitInteractionWorkflow.xml b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testEditWithBeforeCommitInteractionWorkflow.xml new file mode 100644 index 0000000000000000000000000000000000000000..58fab0aa3b60fddf2d2877f57addfee7c4e269a9 --- /dev/null +++ b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testEditWithBeforeCommitInteractionWorkflow.xml @@ -0,0 +1,58 @@ + + + + + + + + + + _bind_names + + + + + + + + + + _asgns + + + + name_subpath + traverse_subpath + + + + + + + + + + + content_type + text/html + + + expand + 0 + + + id + testEditWithBeforeCommitInteractionWorkflow + + + output_encoding + utf-8 + + + title + + + + + + diff --git a/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testEditWithBeforeCommitInteractionWorkflow.zpt b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testEditWithBeforeCommitInteractionWorkflow.zpt new file mode 100644 index 0000000000000000000000000000000000000000..76b8ec597193e908c6c715024953a6539725913c --- /dev/null +++ b/bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testEditWithBeforeCommitInteractionWorkflow.zpt @@ -0,0 +1,90 @@ + + + +Test Edit with "Before Commit" interaction worklow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test Edit with "Before Commit" interaction worklow
open${base_url}/bar_module/ListBoxZuite_reset
assertTextPresentReset Successfully.
open${base_url}/web_site_module/renderjs_runner/#/foo_module
waitForElementPresent//input[@name="field_my_title"]
type//input[@name="field_my_title"]before commit
waitForElementPresent//input[@name="field_my_title"]
assertValue//input[@name="field_my_title"]before commit
assertValue//input[@name="field_my_short_title"]set by interaction workflow
open${base_url}/bar_module/Zuite_waitForActivities
assertTextPresentDone.
+ + \ No newline at end of file