Commit c6c7f700 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_web_renderjs_ui: Add support for object action

parent 78bb1e7b
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
{{/each}} {{/each}}
</ul> </ul>
{{#if action}} {{#if action_tab_list}}
<section class="ui-content-header-plain"> <section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c" data-i18n="[last]{{section_i18n}}"> <h3 class="ui-content-title ui-body-c" data-i18n="[last]{{section_i18n}}">
<span class="ui-icon ui-icon-custom ui-icon-random">&nbsp;</span> <span class="ui-icon ui-icon-custom ui-icon-random">&nbsp;</span>
...@@ -38,7 +38,9 @@ ...@@ -38,7 +38,9 @@
</h3> </h3>
</section> </section>
<ul data-role="listview" data-theme="c" data-inset="true" class="document-listview"> <ul data-role="listview" data-theme="c" data-inset="true" class="document-listview">
<li><a data-i18n="{{action.i18n}}" class="ui-body-inherit" href="{{action.link}}">{{action.title}}</a></li> {{#each action_tab_list}}
<li><a data-i18n="{{i18n}}" class="ui-body-inherit" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul> </ul>
{{/if}} {{/if}}
</script> </script>
......
...@@ -45,54 +45,57 @@ ...@@ -45,54 +45,57 @@
var gadget = this, var gadget = this,
erp5_document, erp5_document,
result_list, result_list,
action, view_list,
view_list; action_list;
return gadget.jio_getAttachment(options.jio_key, "links") return gadget.jio_getAttachment(options.jio_key, "links")
.push(function (result) { .push(function (result) {
var i, var i, i_len,
promise_list = [ promise_list = [
gadget.getUrlFor({command: 'change', options: {page: undefined}}), gadget.getUrlFor({command: 'change', options: {page: undefined}}),
gadget.getUrlFor({command: 'change', options: {page: "breadcrumb"}}) gadget.getUrlFor({command: 'change', options: {page: "breadcrumb"}})
]; ];
erp5_document = result; erp5_document = result;
view_list = erp5_document._links.action_workflow || []; view_list = erp5_document._links.action_workflow || [];
action_list = erp5_document._links.action_object_action || [];
if (view_list.constructor !== Array) { if (view_list.constructor !== Array) {
view_list = [view_list]; view_list = [view_list];
} }
if (action_list.constructor !== Array) {
view_list = [view_list];
}
for (i = 0; i < view_list.length; i += 1) { for (i = 0; i < view_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'change', options: {view: view_list[i].href, page: undefined, editable: undefined}})); promise_list.push(gadget.getUrlFor({command: 'change', options: {view: view_list[i].href, page: undefined, editable: undefined}}));
} }
if (erp5_document._links.action_object_clone_action) { if (erp5_document._links.action_object_clone_action) {
view_list.push(erp5_document._links.action_object_clone_action); action_list.push(erp5_document._links.action_object_clone_action);
promise_list.push(gadget.getUrlFor({ }
command: 'change', for (i = 0, i_len = action_list.length; i < i_len; i += 1) {
options: { promise_list.push(gadget.getUrlFor({command: 'change', options: {view: action_list[i].href, page: undefined, editable: true}}));
view: erp5_document._links.action_object_clone_action.href,
page: undefined,
editable: true
}
}));
} }
return RSVP.all(promise_list); return RSVP.all(promise_list);
}) })
.push(function (all_result) { .push(function (all_result) {
var i, var i,
tab_list = []; tab_list = [],
action_tab_list = [];
result_list = all_result; result_list = all_result;
for (i = 2; i < all_result.length; i += 1) { for (i = 0; i < view_list.length; i += 1) {
tab_list.push({ tab_list.push({
title: view_list[i - 2].title, title: view_list[i].title,
link: all_result[i], link: all_result[i + 2],
i18n: view_list[i - 2].title i18n: view_list[i].title
}); });
} }
if (erp5_document._links.action_object_clone_action) { for (i = 0; i < action_list.length; i += 1) {
action = tab_list.pop(); action_tab_list.push({
title: action_list[i].title,
link: all_result[i + view_list.length + 2],
i18n: action_list[i].title
});
} }
return gadget.translateHtml(table_template({ return gadget.translateHtml(table_template({
definition_title: "Workflow Transitions", definition_title: "Workflow Transitions",
...@@ -100,7 +103,7 @@ ...@@ -100,7 +103,7 @@
definition_i18n: "Workflow-Transitions", definition_i18n: "Workflow-Transitions",
section_i18n: "Actions", section_i18n: "Actions",
section_title: "Actions", section_title: "Actions",
action: action action_tab_list: action_tab_list
})); }));
}) })
.push(function (my_translated_html) { .push(function (my_translated_html) {
......
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