Commit c02f8a26 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Page search: do not sort by default

Sorting on all documents is a performance killer.

In case no query parameter is available, do not trigger any allDocs
calculation and do not display the listbox, as results would be
meaningless.
parent 705eec7b
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
data-i18n=Reference data-i18n=Reference
data-i18n=Description data-i18n=Description
data-i18n=State data-i18n=State
data-i18n=What are you looking for?
--> -->
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
......
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>968.5552.51560.44322</string> </value> <value> <string>975.17545.20356.42120</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1534501341.4</float> <float>1564471789.75</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS */ /*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) { (function (window, rJS, RSVP) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -11,13 +11,15 @@ ...@@ -11,13 +11,15 @@
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("translate", "translate")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.allowPublicAcquisition("jio_allDocs", function (param_list) { .allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this; var gadget = this,
return gadget.jio_allDocs(param_list[0]) options = param_list[0];
return gadget.jio_allDocs(options)
.push(function (result) { .push(function (result) {
var i, date, len = result.data.total_rows; var i, date, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
...@@ -84,10 +86,19 @@ ...@@ -84,10 +86,19 @@
return gadget.updateHeader(header_dict); return gadget.updateHeader(header_dict);
}) })
.push(function () { .push(function () {
return gadget.getDeclaredGadget('form_list'); return RSVP.all([
gadget.getUrlParameter('extended_search'),
gadget.getDeclaredGadget('form_list'),
gadget.translate('What are you looking for?')
]);
}) })
.push(function (form_gadget) { .push(function (result_list) {
var column_list = [ var form_gadget = result_list[1],
extended_search = result_list[0],
translated_text = result_list[2],
group_list = [],
field_dict = {},
column_list = [
['translated_portal_type', 'Type'], ['translated_portal_type', 'Type'],
['modification_date', 'Modification Date'], ['modification_date', 'Modification Date'],
['title', 'Title'], ['title', 'Title'],
...@@ -95,9 +106,9 @@ ...@@ -95,9 +106,9 @@
['description', 'Description'], ['description', 'Description'],
['translated_validation_state_title', 'State'] ['translated_validation_state_title', 'State']
]; ];
return form_gadget.render({
erp5_document: {"_embedded": {"_view": { if (extended_search) {
"listbox": { field_dict.listbox = {
"column_list": column_list, "column_list": column_list,
"show_anchor": 0, "show_anchor": 0,
"default_params": {}, "default_params": {},
...@@ -110,24 +121,51 @@ ...@@ -110,24 +121,51 @@
"portal_type": [], "portal_type": [],
"search_column_list": column_list, "search_column_list": column_list,
"sort_column_list": column_list, "sort_column_list": column_list,
"sort": [['modification_date', 'descending']], "sort": [],
"title": "Documents", "title": "Documents",
"type": "ListBox" "type": "ListBox"
};
group_list.push([
"bottom",
[["listbox"]]
], [
"hidden", ["listbox_modification_date"]
]);
} else {
field_dict.message = {
default: translated_text,
css_class: "",
description: "",
editable: 0,
hidden: 0,
key: "message",
required: 0,
title: "",
type: "StringField"
};
group_list.push([
"bottom",
[["message"]]
]);
} }
}},
return form_gadget.render({
erp5_document: {
"_embedded": {
"_view": field_dict
},
"_links": { "_links": {
"type": { "type": {
// form_list display portal_type in header // form_list display portal_type in header
name: "" name: ""
} }
}}, }
},
form_definition: { form_definition: {
group_list: [[ group_list: group_list
"bottom",
[["listbox"]]
], ["hidden", ["listbox_modification_date"]]]
} }
}); });
}); });
}); });
}(window, rJS)); }(window, rJS, RSVP));
\ No newline at end of file \ No newline at end of file
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>972.18393.56130.7168</string> </value> <value> <string>977.27307.1528.37819</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1544717262.7</float> <float>1564472688.98</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -16,18 +16,41 @@ ...@@ -16,18 +16,41 @@
<td>${base_url}/web_site_module/renderjs_runner/#/?page=search</td> <td>${base_url}/web_site_module/renderjs_runner/#/?page=search</td>
<td></td> <td></td>
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<!-- Wait for gadget to be loaded --> <!-- Wait for gadget to be loaded -->
<tr> <tr>
<td>waitForElementPresent</td> <td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_search.html']</td> <td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_search.html']</td>
<td></td> <td></td>
</tr> </tr>
<tal:block tal:define="parsed_query python: '';
search_query python: ''">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_search_in_form_list" />
</tal:block>
<tr> <tr>
<td>waitForTextPresent</td> <td>assertTextPresent</td>
<td>Title 1</td> <td>What are you looking for?</td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_field_listbox.html']</td>
<td></td>
</tr>
<tal:block tal:define="search_query python: 'title:&quot;Title 1&quot;'">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
</tal:block>
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_field_listbox.html']</td>
<td></td> <td></td>
</tr> </tr>
<!-- Check the listbox cell -->
<tal:block tal:define="cell_configuration python: {'text': 'Title 1', 'line': 0, 'index': 2}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_cell_text" />
</tal:block>
<!-- Search with default sort on modification date --> <!-- Search with default sort on modification date -->
<tr> <tr>
......
...@@ -17,13 +17,16 @@ ...@@ -17,13 +17,16 @@
<td></td> <td></td>
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block tal:define="search_query python: 'title:&quot;Title 1&quot;'">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
</tal:block>
<!-- No default sort -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_sort" />
<tr><td>assertElementNotPresent</td>
<td>//div[@data-gadget-url='${renderjs_url}/gadget_erp5_sort_editor.html']//select</td><td></td></tr>
<!-- Change the default sort --> <!-- Change the default sort -->
<tr>
<td>assertElementPresent</td><!-- verification -->
<td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Modification Date']</td>
<td></td>
</tr>
<tr> <tr>
<td>click</td> <td>click</td>
<td>//th/a[text()='Type']</td> <td>//th/a[text()='Type']</td>
...@@ -31,7 +34,7 @@ ...@@ -31,7 +34,7 @@
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tr> <tr>
<td>assertElementPresent</td><!-- verification --> <td>waitForElementPresent</td><!-- verification -->
<td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Type']</td> <td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Type']</td>
<td></td> <td></td>
</tr> </tr>
...@@ -79,10 +82,15 @@ ...@@ -79,10 +82,15 @@
<!-- Check it's back to default sort --> <!-- Check it's back to default sort -->
<tr> <tr>
<td>assertElementPresent</td><!-- verification --> <td>assertElementNotPresent</td><!-- verification -->
<td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Modification Date']</td> <td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Type']</td>
<td></td> <td></td>
</tr> </tr>
<!-- No default sort -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_sort" />
<tr><td>assertElementNotPresent</td>
<td>//div[@data-gadget-url='${renderjs_url}/gadget_erp5_sort_editor.html']//select</td><td></td></tr>
</tbody></table> </tbody></table>
</body> </body>
......
...@@ -21,7 +21,11 @@ ...@@ -21,7 +21,11 @@
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_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" /> <tr>
<td>assertTextPresent</td>
<td>Ni zai zhao shenme?</td>
<td></td>
</tr>
<tal:block tal:define="search_query python: 'translated_portal_type: &#x22;Web Script&#x22;'"> <tal:block tal:define="search_query python: 'translated_portal_type: &#x22;Web Script&#x22;'">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
......
...@@ -56,24 +56,12 @@ ...@@ -56,24 +56,12 @@
<!-- Check sorted by modification date --> <!-- Check sorted by modification date -->
<tr> <tr>
<td colspan="3"><b>Check sorted by modification date</b></td> <td colspan="3"><b>Check no default sort</b></td>
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_sort" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_sort" />
<tr> <tr><td>assertElementNotPresent</td>
<td>waitForElementPresent</td> <td>//div[@data-gadget-url='${renderjs_url}/gadget_erp5_sort_editor.html']//select</td><td></td></tr>
<td>//div[@class='sort_item_container']//select</td>
<td></td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@class='sort_item_container']/div[1]//select[1]</td>
<td>modification_date</td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@class='sort_item_container']/div[1]//select[2]</td>
<td>descending</td>
</tr>
<!-- Go to another page than search --> <!-- Go to another page than search -->
<tr> <tr>
......
...@@ -76,7 +76,8 @@ param_dict = [ ...@@ -76,7 +76,8 @@ param_dict = [
{ 'message': 'Configure', 'translation': 'peizhi', 'language': 'wo'}, { 'message': 'Configure', 'translation': 'peizhi', 'language': 'wo'},
{ 'message': 'Configure Editor', 'translation': 'peizhibianjiqi', 'language': 'wo'}, { 'message': 'Configure Editor', 'translation': 'peizhibianjiqi', 'language': 'wo'},
{ 'message': 'List', 'translation': 'liebiao', 'language': 'wo'}, { 'message': 'List', 'translation': 'liebiao', 'language': 'wo'},
{ 'message': 'This page contains unsaved changes, do you really want to leave the page ?', 'translation': 'querenlikai?', 'language': 'wo'} { 'message': 'This page contains unsaved changes, do you really want to leave the page ?', 'translation': 'querenlikai?', 'language': 'wo'},
{ 'message': 'What are you looking for?', 'translation': 'Ni zai zhao shenme?', 'language': 'wo'}
] ]
for tmp in param_dict: for tmp in param_dict:
context.Base_addUITestTranslation(message = tmp['message'], translation = tmp['translation'], language = tmp['language']) context.Base_addUITestTranslation(message = tmp['message'], translation = tmp['translation'], language = tmp['language'])
......
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