Commit 6daac17e authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Module list: manually filter/sort the modules

parent a75086f3
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<html> <html>
<!-- <!--
data-i18n=Title data-i18n=Title
data-i18n=Domain
--> -->
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<!-- custom script --> <!-- custom script -->
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script> <script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_front.js" type="text/javascript"></script> <script src="gadget_erp5_page_front.js" type="text/javascript"></script>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.5909.42680.32921</string> </value> <value> <string>965.28992.43927.42052</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1474563730.2</float> <float>1518424688.54</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS */ /*global window, rJS, jIO, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
(function (window, rJS) { (function (window, rJS, jIO, RSVP) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -19,19 +20,67 @@ ...@@ -19,19 +20,67 @@
}) })
.allowPublicAcquisition('getUrlFor', function (argument_list) { .allowPublicAcquisition('getUrlFor', function (argument_list) {
if (argument_list[0].command === 'index') { if (argument_list[0].command === 'index') {
return this.getUrlFor({command: 'display_stored_state', options: {jio_key: argument_list[0].options.jio_key}}); return this.getUrlFor({
command: 'display_stored_state',
options: {jio_key: argument_list[0].options.jio_key}
});
} }
return this.getUrlFor.apply(this, argument_list); return this.getUrlFor.apply(this, argument_list);
}) })
.allowPublicAcquisition('getUrlParameter', function (argument_list) {
return this.getUrlParameter(argument_list) .allowPublicAcquisition('jio_allDocs', function (argument_list) {
.push(function (result) { // ERP5 does not support filtering/sorting on translated properties
if ((result === undefined) && (argument_list[0] === 'field_listbox_sort_list:json')) { // Fetch the list of all modules from ERP5
return [['title', 'ascending']]; // and filter/sort it manually after
var allDocs_options = argument_list[0],
select_list = ['translated_title',
'business_application_translated_title', 'uid', 'id',
'title', '__id'],
new_allDocs_options = {
limit: allDocs_options.limit,
query:
'(parent_uid:"0" AND meta_type:"ERP5 Folder" AND id:"%_module")',
select_list: select_list,
sort_on: []
},
context = this;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
context.jio_allDocs(new_allDocs_options),
context.getUrlParameter('extended_search')
]);
})
.push(function (result_list) {
var data_rows = [],
i,
len = result_list[0].data.total_rows,
query = result_list[1] || "";
for (i = 0; i < len; i += 1) {
// queries do not accept null value
result_list[0].data.rows[i].value
.business_application_translated_title =
result_list[0].data.rows[i].value
.business_application_translated_title || '';
result_list[0].data.rows[i].value.id =
result_list[0].data.rows[i].id;
data_rows.push(result_list[0].data.rows[i].value);
} }
return result; return jIO.QueryFactory.create(query)
.exec(data_rows, {query: query, select_list: select_list,
sort_on: allDocs_options.sort_on});
})
.push(function (document_list) {
var len = document_list.length,
i,
result = [];
for (i = 0; i < len; i += 1) {
result.push({id: document_list[i].id, value: document_list[i]});
}
return {data: {rows: result, total_rows: len}};
}); });
}) })
.declareMethod("triggerSubmit", function () { .declareMethod("triggerSubmit", function () {
var argument_list = arguments; var argument_list = arguments;
return this.getDeclaredGadget('form_list') return this.getDeclaredGadget('form_list')
...@@ -53,7 +102,9 @@ ...@@ -53,7 +102,9 @@
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
var column_list = [ var column_list = [
['translated_title', 'Title']]; ['translated_title', 'Title'],
['business_application_translated_title', 'Domain']
];
return form_gadget.render({ return form_gadget.render({
erp5_document: {"_embedded": {"_view": { erp5_document: {"_embedded": {"_view": {
"listbox": { "listbox": {
...@@ -65,10 +116,13 @@ ...@@ -65,10 +116,13 @@
"key": "field_listbox", "key": "field_listbox",
"lines": 1000, "lines": 1000,
"list_method": "portal_catalog", "list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=parent_uid%3A%220%22%20AND%20meta_type%3A%22ERP5%20Folder%22%20AND%20id%3A%22%25_module%22", "query": "urn:jio:allDocs?query=parent_uid%3A%220%22%20AND" +
"%20meta_type%3A%22ERP5%20Folder%22%20AND" +
"%20id%3A%22%25_module%22",
"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": [["translated_title", "ASC"]],
"title": "Modules", "title": "Modules",
"type": "ListBox" "type": "ListBox"
} }
...@@ -88,4 +142,4 @@ ...@@ -88,4 +142,4 @@
}); });
}); });
}); });
}(window, rJS)); }(window, rJS, jIO, RSVP));
\ No newline at end of file \ No newline at end of file
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.26374.14159.14984</string> </value> <value> <string>965.29083.22768.16418</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1497280148.2</float> <float>1518429915.13</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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>testPageFrontSearchModuleList</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 Page Front</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Page Front</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<!-- Go to the list of modules and check that it is possible to search -->
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/?page=front</td>
<td></td>
</tr>
<!-- 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 metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<!-- All entries to module -->
<tr>
<td>assertElementPresent</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></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></td>
</tr>
<tal:block tal:define="search_query python: 'Foos'">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
</tal:block>
<!-- Less entries to module -->
<tr>
<td>assertElementNotPresent</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></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></td>
</tr>
</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