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 @@
data-i18n=Reference
data-i18n=Description
data-i18n=State
data-i18n=What are you looking for?
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.5552.51560.44322</string> </value>
<value> <string>975.17545.20356.42120</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1534501341.4</float>
<float>1564471789.75</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS */
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) {
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
......@@ -11,13 +11,15 @@
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("translate", "translate")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
var gadget = this,
options = param_list[0];
return gadget.jio_allDocs(options)
.push(function (result) {
var i, date, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
......@@ -84,50 +86,86 @@
return gadget.updateHeader(header_dict);
})
.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) {
var column_list = [
['translated_portal_type', 'Type'],
['modification_date', 'Modification Date'],
['title', 'Title'],
['reference', 'Reference'],
['description', 'Description'],
['translated_validation_state_title', 'State']
];
.push(function (result_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'],
['modification_date', 'Modification Date'],
['title', 'Title'],
['reference', 'Reference'],
['description', 'Description'],
['translated_validation_state_title', 'State']
];
if (extended_search) {
field_dict.listbox = {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": "field_listbox",
"lines": 30,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [],
"title": "Documents",
"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": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": "field_listbox",
"lines": 30,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [['modification_date', 'descending']],
"title": "Documents",
"type": "ListBox"
}
}},
erp5_document: {
"_embedded": {
"_view": field_dict
},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}},
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
], ["hidden", ["listbox_modification_date"]]]
group_list: group_list
}
});
});
});
}(window, rJS));
\ No newline at end of file
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.18393.56130.7168</string> </value>
<value> <string>977.27307.1528.37819</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1544717262.7</float>
<float>1564472688.98</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -16,18 +16,41 @@
<td>${base_url}/web_site_module/renderjs_runner/#/?page=search</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<!-- Wait for gadget to be loaded -->
<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></td>
</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>
<td>waitForTextPresent</td>
<td>Title 1</td>
<td>assertTextPresent</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>
</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 -->
<tr>
......
......@@ -17,13 +17,16 @@
<td></td>
</tr>
<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 -->
<tr>
<td>assertElementPresent</td><!-- verification -->
<td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Modification Date']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//th/a[text()='Type']</td>
......@@ -31,7 +34,7 @@
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tr>
<td>assertElementPresent</td><!-- verification -->
<td>waitForElementPresent</td><!-- verification -->
<td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Type']</td>
<td></td>
</tr>
......@@ -79,10 +82,15 @@
<!-- Check it's back to default sort -->
<tr>
<td>assertElementPresent</td><!-- verification -->
<td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Modification Date']</td>
<td>assertElementNotPresent</td><!-- verification -->
<td>//th[@class='ui-icon ui-icon-sort-amount-desc']/a[text()='Type']</td>
<td></td>
</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>
</body>
......
......@@ -21,7 +21,11 @@
</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_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 metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
......
......@@ -56,24 +56,12 @@
<!-- Check sorted by modification date -->
<tr>
<td colspan="3"><b>Check sorted by modification date</b></td>
<td colspan="3"><b>Check no default sort</b></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_sort" />
<tr>
<td>waitForElementPresent</td>
<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>
<tr><td>assertElementNotPresent</td>
<td>//div[@data-gadget-url='${renderjs_url}/gadget_erp5_sort_editor.html']//select</td><td></td></tr>
<!-- Go to another page than search -->
<tr>
......
......@@ -76,7 +76,8 @@ param_dict = [
{ 'message': 'Configure', 'translation': 'peizhi', 'language': 'wo'},
{ 'message': 'Configure Editor', 'translation': 'peizhibianjiqi', '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:
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