Commit 5eb06085 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

erp5_web_renderjs_ui: do not display submit and cancel if action is empty in form_dialog.

this is useful for an intermadiate dialog that does not require submit
button but still top 'cancel' link works.
parent 57e82771
Pipeline #9895 passed with stage
in 0 seconds
......@@ -181,6 +181,7 @@
form_definition: options.form_definition,
erp5_form: options.erp5_form || {},
// editable: true, // ignore global editable state (be always editable)
has_action: Boolean(options.form_definition.action),
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,
......@@ -249,15 +250,17 @@
);
}
dom_list.push(
domsugar('input', {disabled: true,
name: 'action_confirm',
class: 'dialogconfirm',
type: 'submit',
value: translation_list[1]}),
domsugar('a', {class: 'dialogcancel',
text: translation_list[2]})
);
if (form_gadget.state.has_action) {
dom_list.push(
domsugar('input', {disabled: true,
name: 'action_confirm',
class: 'dialogconfirm',
type: 'submit',
value: translation_list[1]}),
domsugar('a', {class: 'dialogcancel',
text: translation_list[2]})
);
}
domsugar(form_gadget.element
.querySelector('.dialog_button_container'),
......@@ -275,10 +278,12 @@
})
.push(function (translated_title_list) {
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];
if (action_confirm !== null) {
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];
......@@ -311,7 +316,10 @@
]);
})
.push(function (all_result) {
form_gadget.element.querySelector('a.dialogcancel').href = all_result[0];
var action_cancel = form_gadget.element.querySelector('a.dialogcancel');
if (action_cancel !== null) {
action_cancel.href = all_result[0];
}
form_gadget.enableButtonAsJob();
return form_gadget.updateHeader({
cancel_url: all_result[0],
......@@ -347,7 +355,9 @@
gadget.element.querySelector('.dialog_button_container'),
update_button = button_container.querySelector('button'),
submit_input = button_container.querySelector('input');
submit_input.disabled = false;
if (submit_input !== null) {
submit_input.disabled = false;
}
if (update_button !== null) {
update_button.disabled = false;
}
......
<?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>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_dialog_without_action</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</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>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Dialog Without Action</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_viewDialogWithoutAction</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>testFormDialogWithoutAction</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 Dialog Without 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=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': 'Dialog Without Action'}">
<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>assertElementNotPresent</td>
<td>//input[@name='action_confirm']</td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//a[@class='dialogcancel']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?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></string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></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>
<string>my_title</string>
</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_viewDialogWithoutAction</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Foo_viewDialogWithoutAction</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>Dialog Without Action</string> </value>
  • It's not important, but this does not pass ERP5Site_checkNamingConventions:

    erp5_web_renderjs_ui_test/Foo_viewDialogWithoutAction : Title of the Form itself : 'Without' is a closed-class word and should not be titlecased

    I think we don't install recent business templates in naming convention tests. We rewrite this test to integrate it in coding style anyway, so we'll fix all the new business templates once we start running this check in coding style.

Please register or sign in to reply
</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>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Title</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Foo | view_complex_time_serie_graph
Foo | view_dialog_without_action
Foo | view_field_submit_action_dialog
Foo | view_formlist
Foo | view_simple_graph
\ No newline at end of file
  • @kazuhiko @romain we have some report dialogs where the report is rendered directly in the dialog, like the new stock browser.

    It looks like this:

    stock browser dialog screenshot

    In such dialogs, there is an action because action is required on dialogs, so we have an action that in reality is semantically an "Update" button.

    Now with these changes, I understand this commit correctly, action is longer required on dialogs. So I was thinking of using this, to configure this dialog to have only an update action, then it would look like this:

    image

    I think it makes more sense, because it's a dialog where user change parameters, click "update" to see the new result, but can never click "Action" to "Do the action", because there's no action in reality.

    Problem is that this does not work :) clicking the button cause an Cannot set property 'disabled' of null error raised here.

    I think that's a bug, that can be fixed with something like this:

    --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
    +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
    @@ -25,13 +25,17 @@
               gadget.element.querySelector('.dialog_button_container'),
           update_button = button_container.querySelector('button'),
           submit_input = button_container.querySelector('input');
    -    submit_input.disabled = true;
    +    if (submit_input !== null) {
    +      submit_input.disabled = true;
    +    }
         if (update_button !== null) {
           update_button.disabled = true;
         }
     
         function enableButton() {
    -      submit_input.disabled = false;
    +      if (submit_input !== null) {
    +        submit_input.disabled = false;
    +      }
           if (update_button !== null) {
             update_button.disabled = false;
           }

    is this something we want to support ?

    /cc @tb

  • mentioned in merge request !1179 (merged)

    Toggle commit list
  • @jerome I just didn't imagine the usecase where we needed update only. Your change seems fine. Please add one more functional test.

  • Thanks for feedback I'm trying to do this now.

  • BTW, why this was not implemented for erp5_xhtml_style ?

  • For stock browser I think I need xhtml_style support, so I will also implement it

  • @jerome indeed, it should be better. thanks !

  • mentioned in merge request !1181 (merged)

    Toggle commit list
  • mentioned in commit 9262d3a5

    Toggle commit list
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