Commit 0c568094 authored by Valentin Benozillo's avatar Valentin Benozillo

Action title

@nexedi 
This will add a form setting field 'action title', in order to setup the text content of the form action button.
So far the action button text content is the title of the form which can be inconvenient some times. 
If 'action title' is not set-up it fallback to the form title.

![Screenshot_2019-09-04_at_18.50.04](/uploads/e3b49369f347c64a14fa0218c5923c9f/Screenshot_2019-09-04_at_18.50.04.png)

/reviewed-on nexedi/erp5!925
parents 35712c2c 9419b1ad
......@@ -1154,6 +1154,7 @@ def renderFormDefinition(form, response_dict):
response_dict["title"] = Base_translateString(form.getTitle())
response_dict["pt"] = form.pt
response_dict["action"] = form.action
response_dict["action_title"] = Base_translateString(form.action_title)
response_dict["update_action"] = form.update_action
response_dict["update_action_title"] = Base_translateString(form.update_action_title)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>A view for action title</string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_action_title</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>5.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Action Title</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Foo_viewActionTitleDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_redirect</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string>An action title</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></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Foo_viewActionTitleDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Foo_viewDoNothingReportDialog</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>A Form Title</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>
......@@ -28,6 +28,7 @@ Foo | dummy_report
Foo | list
Foo | select_bar
Foo | view
Foo | view_action_title
Foo | view_crash_on_save
Foo | view_duration_field
Foo | view_formbox
......
......@@ -174,6 +174,7 @@
form_definition: options.form_definition,
erp5_form: options.erp5_form || {},
// editable: true, // ignore global editable state (be always editable)
action_title: options.form_definition.action_title,
has_update_action: Boolean(options.form_definition.update_action),
update_action_title: options.form_definition.update_action_title,
// pass extended_search from previous view in case any gadget is curious
......@@ -254,7 +255,12 @@
]);
})
.push(function (translated_title_list) {
form_gadget.element.querySelector('input.dialogconfirm').value = translated_title_list[1];
var action_confirm = form_gadget.element.querySelector('input.dialogconfirm')
if (form_gadget.state.action_title) {
action_confirm.value = form_gadget.state.action_title;
} else {
action_confirm.value = translated_title_list[1];
}
selector.textContent = "\u00A0" + translated_title_list[0];
selector.className = "ui-content-title ui-body-c ui-icon ui-icon-custom" + icon;
......
......@@ -208,7 +208,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>georgios.dagkakis</string> </value>
<value> <string>valentin</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -222,7 +222,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.52803.20172.15991</string> </value>
<value> <string>978.13676.64074.1365</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -240,7 +240,7 @@
</tuple>
<state>
<tuple>
<float>1562070551.41</float>
<float>1567589301.19</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>testFormDialogActionTitle</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 Form View Editable Save Action</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Default Module View</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=1</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': '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': 'Action Title'}">
<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" />
<tr>
<td>assertElementPresent</td>
<td>//input[@name='action_confirm' and @value='An action title']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -64,7 +64,11 @@
<td>//option[text()='Foo Line']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//input[@name='action_confirm' and @value='Create Document']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -17,4 +17,7 @@ if workflow_action:
message = translateString("Workflow state may have been updated by other user. Please try again.")
context.Base_redirect('view', keep_items={'portal_status_message': message})
if form.action_title:
return form.action_title
return form.title
......@@ -60,6 +60,7 @@ form.manage_settings(
field_name=form.name,
field_description=form.description,
field_action='Base_doSelect',
field_action_title=form.action_title,
field_update_action=form.update_action,
field_update_action_title=form.update_action_title,
field_enctype=form.enctype,
......@@ -101,6 +102,7 @@ form.manage_settings(
field_name=form.name,
field_description=form.description,
field_action='Base_edit',
field_action_title=form.action_title,
field_update_action=form.update_action,
field_update_action_title=form.update_action_title,
field_enctype=form.enctype,
......
......@@ -517,6 +517,10 @@ def create_settings_form():
title='Form action',
required=0,
default="")
action_title = fields.StringField('action_title',
title="Action Title",
required=0,
default="")
update_action = fields.StringField('update_action',
title='Form update action',
required=0,
......@@ -558,7 +562,7 @@ def create_settings_form():
title='Setters for these properties should be'
'<br /> called by edit() in the defined order')
form.add_fields([title, description, row_length, name, pt, action, update_action, update_action_title,
form.add_fields([title, description, row_length, name, pt, action, action_title, update_action, update_action_title,
method, enctype, encoding, stored_encoding, unicode_mode, edit_order])
return form
......@@ -620,6 +624,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
# Default Attributes
pt = 'form_view'
action_title = ''
update_action = ''
update_action_title = ''
edit_order = []
......
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