Commit fb27d5de authored by Tristan Cavelier's avatar Tristan Cavelier

[erp5_web_renderjs_ui] Display module actions in panel

- Hardcodes a panel "VIEWS: List" to hide "consistency", "history" and "metadata".
- Only show "WORKFLOWS" on module document.

For instance, on Foo Module the menu panel shows now :

    VIEWS
      List
    ACTIONS
      Do Something

/reviewed-on nexedi/erp5!673
parent cfca73bf
<?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>do_nothing_action_jio</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>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Do Nothing 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_viewDoNothingActionDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,6 +9,7 @@ Foo Line | view
Foo Line | view_contentlist
Foo Line | view_dynamic_matrixbox
Foo Line | view_matrixbox
Foo Module | do_nothing_action_jio
Foo Module | do_nothing_report_jio
Foo Module | empty_mass_action
Foo Module | list
......
......@@ -6,6 +6,7 @@ data-i18n=You do not have the permissions to edit the object.
data-i18n=You are offline.
data-i18n=Action succeeded.
data-i18n=Data received.
data-i18n=List
-->
<html>
<head>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.40657.63647.56780</string> </value>
<value> <string>974.59811.2178.43622</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1554191060.89</float>
<float>1556802379.3</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -49,6 +49,8 @@ and handling data send&receive.
'gadget_html5_textarea.html',
'gadget_html5_select.html'
],
erp5_module_regexp = /^[^\/]+_module$/,
erp5_portal_document_regexp = /^portal_.*\/.+$/,
erp5_module_document_regexp = /^[^\/]+_module\/.+$/;
/*jslint regexp: false*/
......@@ -114,6 +116,7 @@ and handling data send&receive.
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
/////////////////////////////////////////////////////////////////
// Proxy methods to the child gadget
......@@ -268,6 +271,9 @@ and handling data send&receive.
gadget = this,
options = gadget.state.options,
page_template_gadget,
is_module = erp5_module_regexp.test(gadget.state.options.jio_key),
is_module_document = erp5_module_document_regexp.test(gadget.state.options.jio_key),
is_portal_document = erp5_portal_document_regexp.test(gadget.state.options.jio_key),
erp5_document = JSON.parse(gadget.state.erp5_document),
erp5_form = JSON.parse(gadget.state.erp5_form);
......@@ -307,17 +313,29 @@ and handling data send&receive.
}
})
.push(function () {
var jio_key = gadget.state.options.jio_key;
/*jslint regexp: true*/
if ((erp5_module_document_regexp.test(jio_key)) || (/^portal_.*\/.+$/.test(jio_key))) {
/*jslint regexp: false*/
return gadget.updatePanel({
erp5_document: erp5_document,
editable: gadget.state.options.editable,
jio_key: jio_key,
view: options.view
});
if (is_module) {
return gadget.getTranslationList(["List"]);
}
})
.push(function (translation_list) {
var display_workflow_list = true;
if (is_module) {
if (erp5_document._links) {
// hardcode "VIEWS: List" to hide "consistency", "history" and "metadata"
erp5_document._links.action_object_view =
[{"name": "view", "title": translation_list[0], "href": "view", "icon": null}];
display_workflow_list = false;
}
} else if (!(is_module_document || is_portal_document)) {
return;
}
return gadget.updatePanel({
display_workflow_list: display_workflow_list,
erp5_document: erp5_document,
editable: gadget.state.options.editable,
jio_key: gadget.state.options.jio_key,
view: options.view
});
});
})
/** SubmitContent should be called by the gadget which renders submit button
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.50141.1687.13277</string> </value>
<value> <string>975.56533.48127.29525</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1546616402.84</float>
<float>1558448080.86</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -61,6 +61,7 @@
jio_key = options.jio_key,
view = options.view,
visible = options.visible,
display_workflow_list,
context = this,
workflow_list,
view_list,
......@@ -70,6 +71,13 @@
if (visible === undefined) {
visible = context.state.visible;
}
if (options.display_workflow_list === undefined) {
display_workflow_list = true;
} else {
display_workflow_list = asBoolean(options.display_workflow_list);
}
if ((erp5_document !== undefined) && (jio_key !== undefined)) {
workflow_list = ensureArray(erp5_document._links.action_workflow);
view_list = ensureArray(erp5_document._links.action_object_view);
......@@ -102,6 +110,7 @@
.push(function (editable) {
return context.changeState({
visible: visible,
display_workflow_list: display_workflow_list,
workflow_list: workflow_list,
view_list: view_list,
action_list: action_list,
......@@ -115,6 +124,7 @@
.onStateChange(function onStateChange(modification_dict) {
var context = this,
gadget = this,
workflow_list,
queue = new RSVP.Queue();
if (modification_dict.hasOwnProperty("visible")) {
......@@ -233,9 +243,9 @@
.push(function () {
var i = 0,
parameter_list = [],
workflow_list = JSON.parse(gadget.state.workflow_list),
view_list = JSON.parse(gadget.state.view_list),
action_list = JSON.parse(gadget.state.action_list);
workflow_list = JSON.parse(gadget.state.workflow_list);
for (i = 0; i < view_list.length; i += 1) {
parameter_list.push({
......@@ -272,14 +282,16 @@
.push(function (result_list) {
var dl_element,
dl_fragment = document.createDocumentFragment(),
workflow_list = JSON.parse(gadget.state.workflow_list),
view_list = JSON.parse(gadget.state.view_list),
action_list = JSON.parse(gadget.state.action_list);
appendDt(dl_fragment, result_list[1][0], 'eye',
view_list, result_list[0], 0);
appendDt(dl_fragment, result_list[1][1], 'random',
workflow_list, result_list[0], view_list.length);
if (gadget.state.display_workflow_list) {
// show Workflows only on document
appendDt(dl_fragment, result_list[1][1], 'random',
workflow_list, result_list[0], view_list.length);
}
appendDt(dl_fragment, result_list[1][2], 'cogs',
action_list, result_list[0],
view_list.length + workflow_list.length);
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.50145.12391.26965</string> </value>
<value> <string>975.56491.25907.38877</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1546958744.66</float>
<float>1558448423.72</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>testFormListMenuActionLink</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>&#36;{base_url}/web_site_module/renderjs_runner/#/foo_module</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='&#36;{base_url}/web_site_module/renderjs_runner/gadget_erp5_pt_form_list.html']</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Add</td>
<td></td>
</tr>
<!-- Go to the action from the panel -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/open_menu_panel" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='panel' and contains(@class, 'visible')]//a[text()='Do Nothing Action']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='panel']//a[text()='Do Nothing Action']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='&#36;{base_url}/web_site_module/renderjs_runner/gadget_erp5_pt_form_dialog.html']</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': '&quot;Nothing&quot; action is done.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?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>testFormListMenuViewLink</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 Default Module View</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>&#36;{base_url}/web_site_module/renderjs_runner/#/foo_module</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='&#36;{base_url}/web_site_module/renderjs_runner/gadget_erp5_pt_form_list.html']</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Add</td>
<td></td>
</tr>
<!-- Go to the views from the panel -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/open_menu_panel" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='panel' and contains(@class, 'visible')]//a[text()='List']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='panel']//a[text()='List']</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='&#36;{base_url}/web_site_module/renderjs_runner/gadget_erp5_pt_form_list.html']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -75,6 +75,7 @@ param_dict = [
{ 'message': 'Foo Category', 'translation': 'Foo leibie', 'language': 'wo'},
{ 'message': 'Configure', 'translation': 'peizhi', 'language': 'wo'},
{ 'message': 'Configure Editor', 'translation': 'peizhibianjiqi', 'language': 'wo'},
{ 'message': 'List', 'translation': 'liebiao', 'language': 'wo'},
{ 'message': 'This page contains unsaved changes, do you really want to leave the page ?', 'translation': 'querenlikai?', 'language': 'wo'}
]
for tmp in param_dict:
......
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