Commit c34015d6 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Cédric Le Ninivin

erp5_web_renderjs_ui: prepare code to display object action on action gadget

/reviewed-on nexedi/erp5!110
parent 26e2d0bc
......@@ -16,32 +16,18 @@
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_action.js" type="text/javascript"></script>
<!-- XXX need theme here currently -->
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c" data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-custom ui-icon-random">&nbsp;</span>
<span class="ui-icon ui-icon-custom ui-icon-{{definition_icon}}">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul data-role="listview" data-theme="c" data-inset="true" class="document-listview">
{{#each documentlist}}
<li><a data-i18n="{{i18n}}" class="ui-body-inherit" href="{{link}}">{{title}}</a></li>
<li><a data-i18n="{{title}}" class="ui-body-inherit" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
{{#if action}}
<section class="ui-content-header-plain">
<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>
{{section_title}}
</h3>
</section>
<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>
</ul>
{{/if}}
</script>
</head>
......
......@@ -45,63 +45,88 @@
var gadget = this,
erp5_document,
result_list,
action,
view_list;
view_list,
action_list;
return gadget.jio_getAttachment(options.jio_key, "links")
.push(function (result) {
var i,
var i, i_len,
promise_list = [
gadget.getUrlFor({command: 'change', options: {page: undefined}})
];
erp5_document = result;
view_list = erp5_document._links.action_workflow || [];
action_list = []; // erp5_document._links.action_object_action
if (view_list.constructor !== Array) {
view_list = [view_list];
}
if (action_list.constructor !== Array) {
view_list = [view_list];
}
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: options.editable}}));
promise_list.push(
gadget.getUrlFor({
command: 'change',
options: {
view: view_list[i].href,
page: undefined,
editable: options.editable
}
})
);
}
if (erp5_document._links.action_object_clone_action) {
view_list.push(erp5_document._links.action_object_clone_action);
promise_list.push(gadget.getUrlFor({
command: 'change',
options: {
view: erp5_document._links.action_object_clone_action.href,
page: undefined,
editable: true
}
}));
action_list.push(erp5_document._links.action_object_clone_action);
}
for (i = 0, i_len = action_list.length; i < i_len; i += 1) {
promise_list.push(
gadget.getUrlFor({
command: 'change',
options: {
view: action_list[i].href,
page: undefined,
editable: true
}
})
);
}
return RSVP.all(promise_list);
})
.push(function (all_result) {
var i,
tab_list = [];
tab_list = [],
action_tab_list = [];
result_list = all_result;
for (i = 1; i < all_result.length; i += 1) {
for (i = 0; i < view_list.length; i += 1) {
tab_list.push({
title: view_list[i - 1].title,
link: all_result[i],
i18n: view_list[i - 1].title
title: view_list[i].title,
link: all_result[i + 1],
i18n: view_list[i].title
});
}
if (erp5_document._links.action_object_clone_action) {
action = tab_list.pop();
for (i = 0; i < action_list.length; i += 1) {
action_tab_list.push({
title: action_list[i].title,
link: all_result[i + 1 + view_list.length],
i18n: action_list[i].title
});
}
return RSVP.all([
gadget.translateHtml(table_template({
definition_title: "Workflow Transitions",
documentlist: tab_list,
definition_i18n: "Workflow-Transitions",
section_i18n: "Actions",
section_title: "Actions",
action: action
})),
gadget.translateHtml(
table_template({
definition_title: "Workflow Transitions",
definition_icon: "random",
documentlist: tab_list,
definition_i18n: "Workflow-Transitions"
}) + table_template({
definition_i18n: "Actions",
definition_title: "Actions",
definition_icon: "gear",
documentlist: action_tab_list
})
),
calculatePageTitle(gadget, erp5_document)
]);
})
......
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