Commit 92594d68 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: Add action in ERP5JS UI to access update action script on backend

parent a20c02c9
......@@ -1248,6 +1248,10 @@ def renderFormDefinition(form, response_dict):
response_dict["edit_form_action_href"] = '%s/%s/manage_main' % (
site_root.getId(),
form.action)
if form.update_action:
response_dict["edit_form_update_href"] = '%s/%s/manage_main' % (
site_root.getId(),
form.update_action)
def statusLevelToString(level):
......
......@@ -183,6 +183,10 @@
if (options.form_definition.hasOwnProperty("edit_form_action_href")) {
hash += "edit_form_action";
}
if (options.form_definition.hasOwnProperty("edit_form_update_href")) {
hash += "edit_form_update_action";
}
return this.changeState({
erp5_document: options.erp5_document,
form_definition: options.form_definition,
......@@ -233,6 +237,7 @@
dev_element_list,
parent_element,
field_href,
developer_action_mapping,
j;
if (modification_dict.hasOwnProperty('hash')) {
......@@ -252,24 +257,32 @@
for (j = 0; j < dev_element_list.length; j += 1) {
form_gadget.element.removeChild(dev_element_list[j]);
}
if (form_definition.hasOwnProperty("edit_form_href")) {
field_href = addDeveloperAction(
developer_action_mapping = {
"edit_form_href": [
"edit-form ui-icon-edit ui-btn-icon-left",
form_definition.edit_form_href,
"Edit this form"
);
form_gadget.element.insertBefore(field_href, dom_element);
}
if (form_definition.hasOwnProperty("edit_form_action_href")) {
field_href = addDeveloperAction(
],
"edit_form_action_href": [
"edit-form-action ui-icon-external-link ui-btn-icon-left",
form_definition.edit_form_action_href,
"Edit this form's action"
],
"edit_form_update_href": [
"edit-form-action ui-icon-external-link-square ui-btn-icon-left",
"Edit this form's update action"
]
};
for (j in developer_action_mapping) {
if (developer_action_mapping.hasOwnProperty(j) &&
form_definition.hasOwnProperty(j)) {
field_href = addDeveloperAction(
developer_action_mapping[j][0],
form_definition[j],
developer_action_mapping[j][1]
);
form_gadget.element.insertBefore(field_href, dom_element);
}
}
}
});
})
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>990.57432.47622.47940</string> </value>
<value> <string>991.26405.47.57924</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1616447651.73</float>
<float>1618519262.64</float>
<string>UTC</string>
</tuple>
</state>
......
<?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>testDeveloperEditFormUpdateAction</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>Test Developer Edit Form Update Action</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 Fields without label</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr>
<td rowspan="1" colspan="3">Test Parallel Field
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/expected_failure_for_anonymous_selection" />
</td>
</tr>
</thead>
<tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/?page=preference</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/enable_developer_mode" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/go_to_module_list" />
<tr>
<td>click</td>
<td>//a[text()="Foos"]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_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/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" />
<tal:block tal:define="click_configuration python: {'text': 'Dialog with only Update'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_panel_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_form.html')]/a[@href="portal_skins/erp5_ui_test/Foo_viewDialogWithOnlyUpdateDialog/manage_main"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_form.html')]/a[@href="hateoas/Foo_viewDialogWithOnlyUpdateDialog/manage_main"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_form.html')]/a[@href="hateoas/Foo_viewDialogWithOnlyUpdateDialog/manage_main"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//a[@href="my_title/manage_workspace"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//a[contains(@href, "/web_site_module/renderjs_runner/hateoas/Foo_viewDialogWithOnlyUpdateDialog/manage_workspace")]</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
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