Commit 4e5fc085 authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request_ui: show jump actions in panel

For consistency with default ERP5JS and because it's convinient to have the
jump here, to access the document tab that is now a jump action.
parent ed338a9c
...@@ -58,6 +58,12 @@ ...@@ -58,6 +58,12 @@
<a data-i18n="{{title}}" class="ui-body-inherit" href="{{href}}">{{title}}</a> <a data-i18n="{{title}}" class="ui-body-inherit" href="{{href}}">{{title}}</a>
</dd> </dd>
{{/each}} {{/each}}
<dt class="ui-content-title ui-body-c ui-btn ui-btn-icon-left ui-icon-plane" data-i18n="Jumps">Jumps</dt>
{{#each jump_list}}
<dd data-role="listview" data-theme="c" data-inset="true" class="document-listview">
<a data-i18n="{{title}}" class="ui-body-inherit" href="{{href}}">{{title}}</a>
</dd>
{{/each}}
</script> </script>
<!-- custom script --> <!-- custom script -->
......
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1593352275.81</float> <float>1625463570.56</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -50,24 +50,31 @@ ...@@ -50,24 +50,31 @@
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var erp5_document = options.erp5_document, var erp5_document = options.erp5_document,
workflow_list, workflow_list,
view_list; view_list,
jump_list;
if (erp5_document !== undefined) { if (erp5_document !== undefined) {
workflow_list = erp5_document._links.action_workflow || []; workflow_list = erp5_document._links.action_workflow || [];
view_list = erp5_document._links.action_object_view || []; view_list = erp5_document._links.action_object_view || [];
jump_list = erp5_document._links.action_object_jio_jump || [];
if (workflow_list.constructor !== Array) { if (workflow_list.constructor !== Array) {
workflow_list = [workflow_list]; workflow_list = [workflow_list];
} }
if (view_list.constructor !== Array) { if (view_list.constructor !== Array) {
view_list = [view_list]; view_list = [view_list];
} }
// Prevent has much as possible to modify the DOM panel if (jump_list.constructor !== Array) {
jump_list = [jump_list];
}
// Prevent as much as possible to modify the DOM panel
// stateChange prefer to compare strings // stateChange prefer to compare strings
workflow_list = JSON.stringify(workflow_list); workflow_list = JSON.stringify(workflow_list);
view_list = JSON.stringify(view_list); view_list = JSON.stringify(view_list);
jump_list = JSON.stringify(jump_list);
} }
return this.changeState({ return this.changeState({
workflow_list: workflow_list, workflow_list: workflow_list,
view_list: view_list, view_list: view_list,
jump_list: jump_list,
global: true, global: true,
editable: options.editable editable: options.editable
}); });
...@@ -134,7 +141,8 @@ ...@@ -134,7 +141,8 @@
(modification_dict.hasOwnProperty("desktop") || (modification_dict.hasOwnProperty("desktop") ||
modification_dict.hasOwnProperty("editable") || modification_dict.hasOwnProperty("editable") ||
modification_dict.hasOwnProperty("workflow_list") || modification_dict.hasOwnProperty("workflow_list") ||
modification_dict.hasOwnProperty("view_list"))) { modification_dict.hasOwnProperty("view_list") ||
modification_dict.hasOwnProperty("jump_list"))) {
if (!(this.state.desktop && (this.state.view_list !== undefined))) { if (!(this.state.desktop && (this.state.view_list !== undefined))) {
queue queue
.push(function () { .push(function () {
...@@ -146,7 +154,8 @@ ...@@ -146,7 +154,8 @@
var i = 0, var i = 0,
promise_list = [], promise_list = [],
workflow_list = JSON.parse(gadget.state.workflow_list), workflow_list = JSON.parse(gadget.state.workflow_list),
view_list = JSON.parse(gadget.state.view_list); view_list = JSON.parse(gadget.state.view_list),
jump_list = JSON.parse(gadget.state.jump_list);
for (i = 0; i < workflow_list.length; i += 1) { for (i = 0; i < workflow_list.length; i += 1) {
promise_list.push( promise_list.push(
...@@ -170,15 +179,27 @@ ...@@ -170,15 +179,27 @@
}) })
); );
} }
for (i = 0; i < jump_list.length; i += 1) {
promise_list.push(
gadget.getUrlFor({
command: 'change',
options: {
view: jump_list[i].href,
page: undefined
}
})
);
}
return RSVP.all(promise_list); return RSVP.all(promise_list);
}) })
.push(function (result_list) { .push(function (result_list) {
var i, var i,
result_workflow_list = [], result_workflow_list = [],
result_view_list = [], result_view_list = [],
result_jump_list = [],
workflow_list = JSON.parse(gadget.state.workflow_list), workflow_list = JSON.parse(gadget.state.workflow_list),
view_list = JSON.parse(gadget.state.view_list); view_list = JSON.parse(gadget.state.view_list),
jump_list = JSON.parse(gadget.state.jump_list);
for (i = 0; i < workflow_list.length; i += 1) { for (i = 0; i < workflow_list.length; i += 1) {
result_workflow_list.push({ result_workflow_list.push({
title: workflow_list[i].title, title: workflow_list[i].title,
...@@ -191,10 +212,17 @@ ...@@ -191,10 +212,17 @@
href: result_list[i + workflow_list.length] href: result_list[i + workflow_list.length]
}); });
} }
for (i = 0; i < jump_list.length; i += 1) {
result_jump_list.push({
title: jump_list[i].title,
href: result_list[i + workflow_list.length + view_list.length]
});
}
return gadget.translateHtml( return gadget.translateHtml(
panel_template_body_desktop({ panel_template_body_desktop({
workflow_list: result_workflow_list, workflow_list: result_workflow_list,
view_list: result_view_list view_list: result_view_list,
jump_list: result_jump_list
}) })
).push(function (my_translated_or_plain_html) { ).push(function (my_translated_or_plain_html) {
gadget.element.querySelector("dl").innerHTML = my_translated_or_plain_html; gadget.element.querySelector("dl").innerHTML = my_translated_or_plain_html;
......
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1613149288.51</float> <float>1625467130.12</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -236,6 +236,73 @@ ...@@ -236,6 +236,73 @@
<td></td> <td></td>
</tr> </tr>
</tal:block> </tal:block>
<!-- Attached documents can also be found from "Documents" action -->
<tal:block tal:define="click_configuration python: {'text': 'Views'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_header_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Documents'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_page_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': 'Documents related to Support Request : test.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<!-- dismiss this notification, because we'll have another one later. -->
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='notification' and @class='visible']//button</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_no_notification" />
<tr>
<td>waitForTextPresent</td>
<td>test_support_request_text</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>test_support_request_text</td>
<td></td>
</tr>
<!-- on "desktop", this is always visible from the main view -->
<!-- fake a large enough screen -->
<tr>
<td>getEval</td>
<td>
window.matchMedia = function () {return {matches:true}};
event = document.createEvent("Event");
event.initEvent('resize', true, true);
window.dispatchEvent(event);
</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope="panel"]//a[@data-i18n="Documents"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope="panel"]//a[@data-i18n="Documents"]</td>
<td></td>
</tr>
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': 'Documents related to Support Request : test.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr>
<td>waitForTextPresent</td>
<td>test_support_request_text</td>
<td></td>
</tr>
</tbody> </tbody>
</table> </table>
</body> </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