Commit f07ebe82 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: add push_history_stored_state router command

Add a new document in the history while trying to show its latest state

Use this command on the module's list and worklist, to come back to the expected page when done on a module.
parent 9eb3e1c0
......@@ -65,7 +65,7 @@
// Drop the sort parameter, to speed up the calculation
display_options['field_listbox_sort_list:json'] = undefined;
url_for_parameter_list.push(
{command: 'display_stored_state', options: display_options}
{command: 'push_history_stored_state', options: display_options}
);
}
return RSVP.all([
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.57135.22608.35276</string> </value>
<value> <string>986.32404.49746.11571</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1589292069.11</float>
<float>1600958231.92</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -86,7 +86,7 @@
// Calculate all module's urls
for (i = 0; i < len; i += 1) {
url_dict_list.push({
command: 'display_stored_state',
command: 'push_history_stored_state',
options: {jio_key: document_list[i].id}
});
}
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>981.53549.48387.50790</string> </value>
<value> <string>986.54125.60966.30924</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1581602868.55</float>
<float>1600957441.42</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -54,6 +54,8 @@
COMMAND_HISTORY_PREVIOUS = "history_previous",
// Store the current document in history and display the next one
COMMAND_PUSH_HISTORY = "push_history",
// Store the current document in history and display the next one latest state stored
COMMAND_PUSH_HISTORY_STORED_STATE = "push_history_stored_state",
// Change UI language
COMMAND_CHANGE_LANGUAGE = "change_language",
VALID_URL_COMMAND_DICT = {},
......@@ -78,6 +80,7 @@
VALID_URL_COMMAND_DICT[COMMAND_SELECTION_NEXT] = null;
VALID_URL_COMMAND_DICT[COMMAND_HISTORY_PREVIOUS] = null;
VALID_URL_COMMAND_DICT[COMMAND_PUSH_HISTORY] = null;
VALID_URL_COMMAND_DICT[COMMAND_PUSH_HISTORY_STORED_STATE] = null;
VALID_URL_COMMAND_DICT[COMMAND_LOGIN] = null;
VALID_URL_COMMAND_DICT[COMMAND_RAW] = null;
VALID_URL_COMMAND_DICT[COMMAND_RELOAD] = null;
......@@ -485,10 +488,9 @@
});
}
function execPushHistoryCommand(gadget, previous_options, next_options) {
function execPushHistoryCommand(gadget, previous_options, next_options, drop_options, use_stored_state) {
var jio_key = next_options.jio_key,
history_options;
delete next_options.jio_key;
if (previous_options.hasOwnProperty('cancel')) {
history_options = JSON.parse(previous_options.cancel);
history_options.selection = previous_options.selection;
......@@ -501,10 +503,18 @@
return addHistory(gadget, history_options)
.push(function (id) {
next_options.history = id;
if (use_stored_state === true) {
return execDisplayStoredStateCommand(gadget, next_options, drop_options);
}
delete next_options.jio_key;
return addNavigationHistoryAndDisplay(gadget, jio_key, next_options);
});
}
function execPushHistoryStoredStateCommand(gadget, previous_options, next_options, drop_options) {
return execPushHistoryCommand(gadget, previous_options, next_options, drop_options, true);
}
function execKeepHistoryAndDisplayCommand(gadget, previous_options, next_options, create_cancel_url) {
next_options.selection = previous_options.selection;
next_options.history = previous_options.history;
......@@ -925,6 +935,9 @@
if (command_options.path === COMMAND_PUSH_HISTORY) {
return execPushHistoryCommand(gadget, previous_options, next_options);
}
if (command_options.path === COMMAND_PUSH_HISTORY_STORED_STATE) {
return execPushHistoryStoredStateCommand(gadget, previous_options, next_options, drop_options);
}
if (command_options.path === COMMAND_LOGIN) {
return execLoginCommand(gadget, previous_options, next_options);
}
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>985.49865.7906.35925</string> </value>
<value> <string>986.61109.20595.59733</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1596764862.76</float>
<float>1601371634.14</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -34,12 +34,12 @@
<!-- Generate links to module -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Bars' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=bar_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Bars' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=bar_module')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td></td>
</tr>
......@@ -47,7 +47,7 @@
<!-- Header has a link to the previous history entry -->
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td></td>
</tr>
<tr>
......
......@@ -19,7 +19,7 @@
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td></td>
</tr>
<tr>
......
......@@ -33,7 +33,7 @@
<!-- Generate links to worklist on default module view -->
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Draft To Validate' and contains(@href, '#!display_stored_state')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Draft To Validate' and contains(@href, '#!push_history_stored_state')]</td>
<td></td>
</tr>
......@@ -41,7 +41,7 @@
<!-- Header has a link to the previous history entry -->
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='m']//a[text()='Draft To Validate' and contains(@href, '#!display_stored_state')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Draft To Validate' and contains(@href, '#!push_history_stored_state')]</td>
<td></td>
</tr>
......
......@@ -59,7 +59,7 @@
<!-- Generate links to worklist on default module view -->
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Draft To Validate' and contains(@href, '#!display_stored_state')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Draft To Validate' and contains(@href, '#!push_history_stored_state')]</td>
<td></td>
</tr>
......
......@@ -322,14 +322,14 @@
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td></td>
</tr>
......
......@@ -395,14 +395,14 @@
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=foo_module')]</td>
<td></td>
</tr>
......
......@@ -13,13 +13,12 @@
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/foo_module</td>
<td>${base_url}/web_site_module/renderjs_runner/#/?page=search</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<!-- Enter a search query to store the state -->
<tal:block tal:define="parsed_query python: '';
......@@ -27,39 +26,25 @@
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
</tal:block>
<!-- Go to the module page -->
<!-- Go to another page -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/open_menu_panel" />
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='panel']//a[text()='Modules']</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_front.html']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos']</td>
<td></td>
</tr>
<!-- Go to the search page -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/open_menu_panel" />
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos']</td>
<td>//div[@data-gadget-scope='panel']//a[text()='Search' and contains(@href, '#!display_stored_state')]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>waitForTextPresent</td>
<td>Foos</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<!-- Wait for gadget to be loaded -->
<tal:block tal:define="parsed_query python: '';
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testCommandPushHistoryStoredStateJumpToLatestDocumentContext</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Display Stored State</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Default Module View</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/foo_module</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<!-- Enter a search query to store the state -->
<tal:block tal:define="parsed_query python: '';
search_query python: 'title'">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
</tal:block>
<!-- Go to the module page -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/open_menu_panel" />
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='panel']//a[text()='Modules']</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_front.html']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state')]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>waitForTextPresent</td>
<td>Foos</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block tal:define="parsed_query python: '';
search_query python: 'title'">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_search_in_form_list" />
</tal:block>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testCommandPushHistoryStoredStateKeepHistory</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Display Stored State</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Default Module View</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_worklist.html']</td>
<td></td>
</tr>
<!-- Go to the module page -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/open_menu_panel" />
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='panel']//a[text()='Modules']</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_front.html']</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='m']//a[text()='Foos' and contains(@href, '#!push_history_stored_state')]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_form.html']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='header']//a[text()='Foos' and contains(@href, '#!history_previous')]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='header']//a[text()='Foos' and contains(@href, '#!history_previous')]</td>
<td></td>
</tr>
<!-- Wait for gadget to be loaded -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_front.html']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -34,7 +34,7 @@
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='m']//a[text()='Bars' and contains(@href, '#!display_stored_state') and contains(@href, 'n.jio_key=bar_module')]</td>
<td>//div[@data-gadget-scope='m']//a[text()='Bars' and contains(@href, '#!push_history_stored_state') and contains(@href, 'n.jio_key=bar_module')]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
......
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