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

ERP5JS: Tab gadget display jump and is used in form_view

/reviewed-on nexedi/erp5!94
parents 347cac18 9b88da4c
......@@ -57,13 +57,13 @@
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: 'change', options: {page: "jump"}})
gadget.getUrlFor({command: 'change', options: {page: "tab"}})
]);
})
.push(function (all_result) {
return gadget.updateHeader({
jump_url: all_result[7],
tab_url: all_result[7],
actions_url: all_result[2],
previous_url: all_result[5],
next_url: all_result[6],
......
/*global window, rJS, RSVP, Handlebars */
/*global window, rJS, RSVP, Handlebars, URI */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars) {
(function (window, rJS, RSVP, Handlebars, URI) {
"use strict";
/////////////////////////////////////////////////////////////////
......@@ -44,22 +44,33 @@
.declareMethod("render", function (options) {
var view_list,
tab_list = [],
jump_action_list = [],
gadget = this,
erp5_document;
erp5_document,
jump_list;
return gadget.jio_getAttachment(options.jio_key, "links")
.push(function (result) {
var i,
promise_list = [];
erp5_document = result,
view_list = erp5_document._links.view;
erp5_document = result;
view_list = erp5_document._links.view || [];
jump_list = erp5_document._links.action_object_jump || [];
// All ERP5 document should at least have one view.
// So, no need normally to test undefined
if (view_list.constructor !== Array) {
view_list = [view_list];
}
if (jump_list.constructor !== Array) {
jump_list = [jump_list];
}
promise_list.push(gadget.getUrlFor({command: 'change', options: {
view: "view",
page: undefined,
editable: undefined
}}));
for (i = 0; i < view_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'change', options: {
view: view_list[i].href,
......@@ -67,37 +78,51 @@
page: undefined
}}));
}
promise_list.push(gadget.getUrlFor({command: 'change', options: {
view: "view",
page: undefined,
editable: undefined
}}));
for (i = 0; i < jump_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'push_history', options: {
extended_search: new URI(jump_list[i].href).query(true).query,
page: 'search'
}}));
}
return RSVP.all(promise_list);
})
.push(function (all_result) {
var i;
for (i = 0; i < all_result.length - 1; i += 1) {
var i, j;
j = 1;
for (i = 0; i < view_list.length; i += 1) {
tab_list.push({
title: view_list[i].title,
i18n: view_list[i].title,
link: all_result[i]
link: all_result[j]
});
j += 1;
}
for (i = 0; i < jump_list.length; i += 1) {
jump_action_list.push({
title: jump_list[i].title,
link: all_result[j],
i18n: jump_list[i].title
});
j += 1;
}
return gadget.translateHtml(table_template({
definition_title: "Views",
definition_i18n: "Views",
definition_icon: "eye",
documentlist: [{
title: view_list[0].title,
link: all_result[all_result.length - 1]
link: all_result[0]
}]
}) + table_template({
definition_title: "Editables",
definition_i18n: "Editables",
definition_icon: "edit",
documentlist: tab_list
}) + table_template({
definition_title: "Jumps",
documentlist: jump_action_list,
definition_icon: "plane",
definition_i18n: "Jumps"
}));
})
.push(function (my_translated_html) {
......@@ -119,4 +144,4 @@
});
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
}(window, rJS, RSVP, Handlebars, URI));
\ No newline at end of file
......@@ -50,6 +50,21 @@
<td>Dummy Report</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Views</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Editables</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Jumps</td>
<td></td>
</tr>
</tbody></table>
</body>
......
......@@ -42,7 +42,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testFormViewJumpsLink</string> </value>
<value> <string>testFormViewTabsLink</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
......
......@@ -32,17 +32,17 @@
<!-- Header has a link to the action page -->
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='header']//a[text()='Jump' and contains(@href, '#!change') and contains(@href, 'n.page=jump')]</td>
<td>//div[@data-gadget-scope='header']//a[text()='Tabs' and contains(@href, '#!change') and contains(@href, 'n.page=tab')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='header']//a[text()='Jump' and contains(@href, '#!change') and contains(@href, 'n.page=jump')]</td>
<td>//div[@data-gadget-scope='header']//a[text()='Tabs' and contains(@href, '#!change') and contains(@href, 'n.page=tab')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_jump.html']</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_tab.html']</td>
<td></td>
</tr>
<tr>
......@@ -50,6 +50,21 @@
<td>Title 1</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Views</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Editables</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Jumps</td>
<td></td>
</tr>
</tbody></table>
</body>
......
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