Commit 30bdc0bb authored by Gabriel Monnerat's avatar Gabriel Monnerat Committed by Romain Courteaud

erp5_web_renderjs_ui: add generic function to merge action with raw actions by group

parent b3086168
<?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>category</string> </key>
<value> <string>object_jio_jump</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>jump_to_portal_type</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Manage portal</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Edit Portal Type</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}/Base_redirectToPortalTypeDocument</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: portal.portal_preferences.isPreferredHtmlStyleDevelopperMode()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, RSVP, SimpleQuery, ComplexQuery, Query,
ensureArray */
ensureArray, Array*/
/*jslint indent: 2, maxerr: 3, nomen: true, unparam: true, continue: true */
(function (window, RSVP, SimpleQuery, ComplexQuery, Query,
ensureArray) {
ensureArray, Array) {
"use strict";
///////////////////////////////
......@@ -164,6 +164,122 @@
///////////////////////////////
// Handle listbox action list
///////////////////////////////
function mergeGlobalActionWithRawActionList(gadget, links, group_id_list,
command_mapping,
editable_mapping) {
var i, j, group,
action_type,
current_href,
class_name,
options,
command,
view = gadget.state.view,
jump_view = gadget.state.jump_view,
group_mapping = {},
url_mapping = {},
default_command_mapping = {
"view": "display_with_history",
"action_object_jio_jump": "display_dialog_with_history",
"action_object_jio_action": "display_with_history_and_cancel",
"action_object_view": "display_with_history",
"action_workflow": "display_dialog_with_history",
"action_object_clone_action": "display_with_history_and_cancel",
"action_object_delete_action": "display_with_history_and_cancel"
};
editable_mapping = editable_mapping || {};
command_mapping = command_mapping || {};
for (i = 0; i < group_id_list.length; i += 1) {
group = group_id_list[i][0];
if (group_id_list[i] instanceof Array) {
group_mapping[group] = ensureArray(links[group]);
action_type = group + "_raw";
if (links.hasOwnProperty(action_type)) {
if (links[action_type] instanceof Array) {
for (i = 0; i < links[action_type].length; i += 1) {
if (links[action_type][i].href) {
group_mapping[group].push(links[action_type][i]);
}
}
} else {
group_mapping[group].push(links[action_type]);
}
}
if (group_id_list[i].length > 1) {
for (j = 1; j < group_id_list[i].length; j += 1) {
group_mapping[group] = group_mapping[
group
].concat(
ensureArray(links[group_id_list[i][j]])
);
action_type = group_id_list[i][j] + "_raw";
if (links.hasOwnProperty(action_type)) {
if (links[action_type] instanceof Array) {
for (i = 0; i < links[action_type].length; i += 1) {
if (links[action_type][i].href) {
group_mapping[group].push(links[action_type][i]);
}
}
} else {
group_mapping[group].push(links[action_type]);
}
}
}
}
} else {
group_mapping[group_id_list[i]] = ensureArray(
links[group_id_list[i]]
);
}
}
for (group in group_mapping) {
if (group_mapping.hasOwnProperty(group)) {
if (!url_mapping.hasOwnProperty(group)) {
url_mapping[group] = [];
}
for (i = 0; i < group_mapping[group].length; i += 1) {
class_name = "";
current_href = group_mapping[group][i].href;
if (view === 'view' && group_mapping[group][i].name === view) {
class_name = 'active';
} else if (current_href === view) {
class_name = 'active';
} else if (jump_view && ((current_href === jump_view) ||
(current_href === view))) {
class_name = 'active';
}
if (group_mapping[group][i].name.indexOf("_raw") !== -1) {
command = "raw";
options = {
title: group_mapping[group][i].title,
href: group_mapping[group][i].href
};
} else {
command = command_mapping[group] || default_command_mapping[group];
options = {
title: group_mapping[group][i].title,
class_name: class_name,
jio_key: gadget.state.jio_key,
view: group_mapping[group][i].href,
editable: editable_mapping[group]
};
}
if (group === "view") {
// Views in ERP5 must be forms but because of
// OfficeJS we keep it empty for different default
options.page = undefined;
}
url_mapping[group].push({
command: command,
options: options
});
}
}
}
return url_mapping;
}
function getListboxClipboardActionList() {
var action_list = ensureArray(this.state.erp5_document._links.action_object_list_action || []),
i,
......@@ -311,8 +427,9 @@
.allowPublicAcquisition("triggerListboxClipboardAction",
triggerListboxClipboardAction);
}
window.mergeGlobalActionWithRawActionList = mergeGlobalActionWithRawActionList;
window.triggerListboxClipboardAction = triggerListboxClipboardAction;
window.declareGadgetClassCanHandleListboxClipboardAction =
declareGadgetClassCanHandleListboxClipboardAction;
}(window, RSVP, SimpleQuery, ComplexQuery, Query, ensureArray));
\ No newline at end of file
}(window, RSVP, SimpleQuery, ComplexQuery, Query, ensureArray, Array));
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>986.51245.10858.8089</string> </value>
<value> <string>989.47571.17838.51694</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1602058138.58</float>
<float>1612185222.55</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray */
/*global window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray,
console, mergeGlobalActionWithRawActionList */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray) {
(function (window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray,
mergeGlobalActionWithRawActionList) {
"use strict";
function generateSection(title, icon, view_list) {
var i,
dom_list = [];
for (i = 0; i < view_list.length; i += 1) {
dom_list.push(domsugar('li', [domsugar('a', {
href: view_list[i].link,
......@@ -66,36 +67,33 @@
// what view we are at. If no view available than fallback to "links".
return gadget.jio_getAttachment(gadget.state.jio_key, gadget.state.view || "links")
.push(function (jio_attachment) {
var i, j,
url_for_kw_list = [],
url_mapping = mergeGlobalActionWithRawActionList(gadget,
jio_attachment._links,
["action_workflow",
["action_object_jio_action",
"action_object_jio_button",
"action_object_jio_fast_input"],
"action_object_clone_action",
"action_object_delete_action"], {
"action_workflow": "display_with_history_and_cancel"
}, {
action_object_clone_action: true
});
erp5_document = jio_attachment;
raw_list = ensureArray(erp5_document._links.action_object_development_mode_jump_raw);
var i,
j,
url_for_kw_list = [];
group_list = [
// Action list, editable, icon
ensureArray(erp5_document._links.action_workflow), undefined, 'random',
ensureArray(erp5_document._links.action_object_jio_action)
.concat(ensureArray(erp5_document._links.action_object_jio_button))
.concat(ensureArray(erp5_document._links.action_object_jio_fast_input)), undefined, 'gear',
ensureArray(erp5_document._links.action_object_clone_action), true, 'clone',
ensureArray(erp5_document._links.action_object_delete_action), undefined, 'trash-o'];
for (i = 0; i < group_list.length; i += 3) {
for (j = 0; j < group_list[i].length; j += 1) {
url_for_kw_list.push({command: 'display_with_history_and_cancel', options: {
jio_key: gadget.state.jio_key,
view: group_list[i][j].href,
editable: group_list[i + 1]
}});
}
}
url_mapping.action_workflow, 'random',
url_mapping.action_object_jio_action, 'gear',
url_mapping.action_object_clone_action, 'clone',
url_mapping.action_object_delete_action, 'trash-o'
];
// Move this code one place that can be shared
for (i in erp5_document._links) {
if (i.match(/.*_raw$/) && erp5_document._links[i].href) {
raw_list.push(erp5_document._links[i]);
for (i = 0; i < group_list.length; i += 2) {
for (j = 0; j < group_list[i].length; j += 1) {
url_for_kw_list.push(group_list[i][j]);
}
}
......@@ -126,17 +124,17 @@
raw_action_list = [],
link_list;
for (i = 0; i < group_list.length; i += 3) {
for (i = 0; i < group_list.length; i += 2) {
link_list = [];
for (j = 0; j < group_list[i].length; j += 1) {
link_list.push({
title: group_list[i][j].title,
title: group_list[i][j].options.title,
link: result_dict.url_list[k]
});
k += 1;
}
dom_list.push(
generateSection(result_dict.translation_list[i / 3], group_list[i + 2], link_list)
generateSection(result_dict.translation_list[i / 2], group_list[i + 1], link_list)
);
}
......@@ -164,4 +162,5 @@
return;
});
}(window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray));
}(window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray,
mergeGlobalActionWithRawActionList));
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.17757.52708.29969</string> </value>
<value> <string>989.47954.24695.28433</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1610395382.6</float>
<float>1612205919.8</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -23,7 +23,11 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_panel.js" type="text/javascript"></script>
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>985.48809.10432.44578</string> </value>
<value> <string>989.30774.63276.56746</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1596701351.5</float>
<float>1611763679.73</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>988.65434.35774.5563</string> </value>
<value> <string>989.47833.1016.53060</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1609322633.89</float>
<float>1612198632.86</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -281,9 +281,7 @@
]);
})
.push(function (translated_title_list) {
var field_href,
form_definition = modification_dict.form_definition,
action_confirm = form_gadget.element.querySelector('input.dialogconfirm');
var action_confirm = form_gadget.element.querySelector('input.dialogconfirm');
if (action_confirm !== null) {
if (form_gadget.state.action_title) {
action_confirm.value = form_gadget.state.action_title;
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>988.16932.41419.17169</string> </value>
<value> <string>989.30774.63276.56746</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1607348224.53</float>
<float>1612183252.61</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray */
/*global window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray,
mergeGlobalActionWithRawActionList */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/** Page for displaying Views, Jump and BreadCrumb navigation for a document.
*/
(function (window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray) {
(function (window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray,
mergeGlobalActionWithRawActionList) {
"use strict";
/** Go recursively up the parent-chain and insert breadcrumbs in the last argument.
......@@ -101,31 +103,23 @@
jump_list;
return gadget.jio_getAttachment(gadget.state.jio_key, "links")
.push(function (result) {
var i,
url_for_kw_list = [];
erp5_document = result;
view_list = ensureArray(erp5_document._links.view);
jump_list = ensureArray(erp5_document._links.action_object_jio_jump);
for (i = 0; i < view_list.length; i += 1) {
url_for_kw_list.push({command: 'display_with_history', options: {
jio_key: gadget.state.jio_key,
view: view_list[i].href,
page: undefined // Views in ERP5 must be forms but because of
// OfficeJS we keep it empty for different default
}});
}
for (i = 0; i < jump_list.length; i += 1) {
url_for_kw_list.push({command: 'display_dialog_with_history', options: {
jio_key: gadget.state.jio_key,
view: jump_list[i].href
}});
}
return mergeGlobalActionWithRawActionList(gadget,
erp5_document._links, [
"view",
"action_object_jio_jump"
]);
})
.push(function (group_mapping) {
var url_for_kw_list = [];
view_list = group_mapping.view;
jump_list = group_mapping.action_object_jio_jump;
url_for_kw_list = url_for_kw_list.concat(
view_list).concat(jump_list);
url_for_kw_list.push({command: 'cancel_dialog_with_history'});
return RSVP.hash({
url_list: gadget.getUrlForList(url_for_kw_list),
_: modifyBreadcrumbList(gadget,
......@@ -135,21 +129,20 @@
page_title: calculatePageTitle(gadget, erp5_document)
});
})
.push(function (result_dict) {
var i,
j = 0;
for (i = 0; i < view_list.length; i += 1) {
tab_list.push({
title: view_list[i].title,
title: view_list[i].options.title,
link: result_dict.url_list[j]
});
j += 1;
}
for (i = 0; i < jump_list.length; i += 1) {
jump_action_list.push({
title: jump_list[i].title,
title: jump_list[i].options.title,
link: result_dict.url_list[j]
});
j += 1;
......@@ -171,4 +164,4 @@
return;
});
}(window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray));
\ No newline at end of file
}(window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray, mergeGlobalActionWithRawActionList));
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>981.62315.62619.21640</string> </value>
<value> <string>989.31920.37858.10717</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1582128721.85</float>
<float>1611626994.73</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -224,12 +224,12 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.45868.14105.29764</string> </value>
<value> <string>989.47814.22170.38929</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,8 +256,8 @@
</tuple>
<state>
<tuple>
<float>1445935505.72</float>
<string>GMT</string>
<float>1612197547.78</float>
<string>UTC</string>
</tuple>
</state>
</object>
......@@ -331,4 +331,36 @@
</dictionary>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="Message" module="Products.ERP5Type.Message"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string>Translation data updated from web site ${web_site_id}.</string> </value>
</item>
<item>
<key> <string>domain</string> </key>
<value> <string>erp5_ui</string> </value>
</item>
<item>
<key> <string>mapping</string> </key>
<value>
<dictionary>
<item>
<key> <string>web_site_id</string> </key>
<value> <string>renderjs_runner</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>message</string> </key>
<value> <string>Translation data updated from web site ${web_site_id}.</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -12,4 +12,5 @@ Web Site | create_translation_data
Web Style | version_view
Web Style | view
Web Style | view_editor
Web Style | web_view
\ No newline at end of file
Web Style | web_view
portal_actions | jump_to_portal_type
\ No newline at end of file
......@@ -29,12 +29,12 @@
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//ul[@class="document-listview"]/li/a[text()="Edit Portal Type Preference"]</td>
<td>//ul[@class="document-listview"]/li/a[text()="Edit Portal Type"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//ul[@class="document-listview"]/li/a[text()="Edit Portal Type Preference"]</td>
<td>//ul[@class="document-listview"]/li/a[text()="Edit Portal Type"]</td>
<td></td>
</tr>
<tr>
......
......@@ -29,17 +29,17 @@
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Edit Portal Type Accounting Transaction Module</td>
<td>Edit Portal Type</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//dd[@class="document-listview"]/a[text()="Edit Portal Type Accounting Transaction Module"]</td>
<td>//dd[@class="document-listview"]/a[text()="Edit Portal Type"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//dd[@class="document-listview"]/a[text()="Edit Portal Type Accounting Transaction Module"]</td>
<td>//dd[@class="document-listview"]/a[text()="Edit Portal Type"]</td>
<td></td>
</tr>
<tr>
......@@ -54,12 +54,12 @@
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Edit Portal Type Base Type</td>
<td>Edit Portal Type</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//dd[@class="document-listview"]/a[text()="Edit Portal Type Base Type"]</td>
<td>//dd[@class="document-listview"]/a[text()="Edit Portal Type"]</td>
<td></td>
</tr>
<tr>
......@@ -74,12 +74,17 @@
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Edit Portal Type Accounting Transaction Module</td>
<td>Edit Portal Type</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//dd[@class="document-listview"]/a[text()="Edit Portal Type Accounting Transaction Module"]</td>
<td>//dd[@class="document-listview"]/a[text()="Edit Portal Type"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//a[@data-i18n="Accounting"]</td>
<td></td>
</tr>
<tr>
......
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