Commit 536d0a29 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Store the global search state and module list search state

parent 9974e56d
......@@ -163,11 +163,11 @@
// Update the global links
.push(function () {
return RSVP.all([
context.getUrlFor({command: 'display', options: {page: "front"}}),
context.getUrlFor({command: 'display_stored_state', options: {page: "front"}}),
context.getUrlFor({command: 'display', options: {page: "history"}}),
context.getUrlFor({command: 'display', options: {page: "preference"}}),
context.getUrlFor({command: 'display', options: {page: "logout"}}),
context.getUrlFor({command: 'display', options: {page: "search"}}),
context.getUrlFor({command: 'display_stored_state', options: {page: "search"}}),
context.getUrlFor({command: 'display', options: {page: "worklist"}}),
context.getUrlFor({command: 'display'})
]);
......@@ -376,7 +376,7 @@
});
})
.push(function () {
return gadget.redirect({command: 'display', options: redirect_options});
return gadget.redirect({command: 'store_and_display', options: redirect_options});
});
}, /*useCapture=*/false, /*preventDefault=*/true);
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.19417.14549.47223</string> </value>
<value> <string>965.29136.38081.57361</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1517850106.11</float>
<float>1518441170.76</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -47,7 +47,10 @@
// Change UI language
COMMAND_CHANGE_LANGUAGE = "change_language",
VALID_URL_COMMAND_DICT = {},
STICKY_PARAMETER_LIST = ['editable'];
STICKY_PARAMETER_LIST = ['editable'],
// This is a hack to store the form_list search state per standalone
// page (without any jio_key)
PAGE_STATE_STORAGE_PREFIX = '__PAGE__';
VALID_URL_COMMAND_DICT[COMMAND_DISPLAY_STATE] = null;
VALID_URL_COMMAND_DICT[COMMAND_KEEP_HISTORY_AND_DISPLAY_STATE] = null;
......@@ -304,11 +307,16 @@
function execDisplayStoredStateCommand(gadget, next_options) {
// console.warn(command_options);
var jio_key = next_options.jio_key,
storage_key = jio_key,
queue;
delete next_options.jio_key;
if (jio_key) {
queue = gadget.props.jio_state_gadget.get(jio_key)
if ((!storage_key) && (next_options.page)) {
storage_key = PAGE_STATE_STORAGE_PREFIX + next_options.page;
}
if (storage_key) {
queue = gadget.props.jio_state_gadget.get(storage_key)
.push(function (options) {
calculateChangeOptions(options, next_options);
}, function (error) {
......@@ -340,17 +348,21 @@
}
function execStoreAndDisplayCommand(gadget, options) {
var jio_key,
var jio_key = options.jio_key,
storage_key = jio_key,
queue,
display_url;
jio_key = options.jio_key;
delete options.jio_key;
if ((!storage_key) && (options.page)) {
storage_key = PAGE_STATE_STORAGE_PREFIX + options.page;
}
display_url = getDisplayUrlFor(jio_key, options);
if (jio_key) {
queue = gadget.props.jio_state_gadget.put(jio_key, dropStickyParameterEntry(options));
if (storage_key) {
queue = gadget.props.jio_state_gadget.put(storage_key, dropStickyParameterEntry(options));
} else {
queue = new RSVP.Queue();
}
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.29255.31672.17100</string> </value>
<value> <string>965.29272.2871.14455</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1518440166.69</float>
<float>1518441236.24</float>
<string>UTC</string>
</tuple>
</state>
......
<?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>testPanelModuleLink</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 RenderJS UI</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test RenderJS UI</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<!-- Go to the module list -->
<tr>
<td colspan="3"><b>Go to the module list</b></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/?page=front</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="search_query python: 'Foos'">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
</tal:block>
<!-- Check sorted by modification date -->
<tr>
<td colspan="3"><b>Check sorted by modification date</b></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_sort" />
<tr>
<td>waitForElementPresent</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']//select</td>
<td></td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[1]</td>
<td>translated_title</td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[2]</td>
<td>ascending</td>
</tr>
<!-- Go to another page than search -->
<tr>
<td colspan="3"><b>Go to another page than search</b></td>
</tr>
<tr>
<td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_panel.html')]//a[@data-i18n='Preferences']</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Language</td>
<td></td>
</tr>
<!-- Check the the global modules link restore the search state -->
<tr>
<td colspan="3"><b>Check the the global modules link restore the search state</b></td>
</tr>
<tr>
<td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_panel.html')]//a[@data-i18n='Modules' and contains(@href, '#!display_stored_state') and contains(@href, 'n.page=front')]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<!-- Wait for gadget to be 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>
<tal:block tal:define="parsed_query python: '';
search_query python: 'Foos'">
<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>testPanelSearch</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 RenderJS UI</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test RenderJS UI</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<!-- Go to another page than search -->
<tr>
<td colspan="3"><b>Go to another page than search</b></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/?page=preference</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Language</td>
<td></td>
</tr>
<!-- Search from the panel -->
<tr>
<td colspan="3"><b>Search from the panel</b></td>
</tr>
<tr>
<td>type</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_panel.html')]//input[@name='search']</td>
<td>foobar</td>
</tr>
<tr>
<td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_panel.html')]//button[@type='submit']</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<!-- Wait for gadget to be loaded -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_search.html']</td>
<td></td>
</tr>
<tal:block tal:define="parsed_query python: '';
search_query python: 'foobar'">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_search_in_form_list" />
</tal:block>
<!-- Check sorted by modification date -->
<tr>
<td colspan="3"><b>Check sorted by modification date</b></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_sort" />
<tr>
<td>waitForElementPresent</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']//select</td>
<td></td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[1]</td>
<td>modification_date</td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[2]</td>
<td>descending</td>
</tr>
<!-- Go to another page than search -->
<tr>
<td colspan="3"><b>Go to another page than search</b></td>
</tr>
<tr>
<td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_panel.html')]//a[@data-i18n='Preferences']</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Language</td>
<td></td>
</tr>
<!-- Check the the global search link restore the search state -->
<tr>
<td colspan="3"><b>Check the the global search link restore the search state</b></td>
</tr>
<tr>
<td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_panel.html')]//a[@data-i18n='Search' and contains(@href, '#!display_stored_state') and contains(@href, 'n.page=search')]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<!-- Wait for gadget to be loaded -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_search.html']</td>
<td></td>
</tr>
<tal:block tal:define="parsed_query python: '';
search_query python: 'foobar'">
<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
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