Commit e25887c4 authored by Romain Courteaud's avatar Romain Courteaud Committed by Gabriel Monnerat

erp5_web_renderjs_ui: Query and display tools by catalog if developer mode is activated

parent b1dfe137
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery, SimpleQuery
is_developer_mode = (context.getPortalObject().portal_preferences
.getPreferredHtmlStyleDevelopperMode())
simple_query = SimpleQuery(parent_uid=0)
module_query = ComplexQuery(
SimpleQuery(id="%\\_module", comparison_operator="like"),
SimpleQuery(meta_type="ERP5 Folder"),
logical_operator='AND'
)
if is_developer_mode:
query = ComplexQuery(
simple_query,
ComplexQuery(
module_query,
SimpleQuery(id="portal\\_%", comparison_operator="like"),
logical_operator='OR'
),
logical_operator='AND')
else:
query = ComplexQuery(
simple_query,
module_query,
logical_operator='AND')
return ComplexQuery(
query,
SimpleQuery(id=value, comparison_operator="like"),
logical_operator='AND')
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Python Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>reference</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>value</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SQLCatalog_makeModuleListQuery</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Python Script</string> </value>
</item>
<item>
<key> <string>reference</string> </key>
<value> <string>SQLCatalog_makeModuleListQuery</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>SQLCatalog_makeModuleListQuery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<key_list>
<key>module_id | SQLCatalog_makeModuleListQuery</key>
</key_list>
\ No newline at end of file
......@@ -2,6 +2,7 @@
<html>
<!--
data-i18n=Others
data-i18n=Tools
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.60433.59989.54698</string> </value>
<value> <string>986.51245.10858.8089</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1612969553.17</float>
<float>1605547612.43</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -38,7 +38,7 @@
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
......@@ -52,7 +52,7 @@
// First, get the list of modules
return gadget.jio_allDocs({
select_list: select_list,
query: '(parent_uid:"0" AND meta_type:"ERP5 Folder" AND id:"%_module")',
query: 'module_id:%',
limit: 1000
})
.push(function (result_list) {
......@@ -96,19 +96,21 @@
url_dict_list.push({command: 'display', options: {page: 'language'}});
return RSVP.all([
document_list,
gadget.translate('Others'),
gadget.getTranslationList(['Others', 'Tools']),
gadget.getUrlForList(url_dict_list)
]);
})
.push(function (result_list) {
var document_list = result_list[0],
translated_other_title = result_list[1],
translated_other_title = result_list[1][0],
translated_tool_title = result_list[1][1],
url_list = result_list[2],
len = document_list.length,
i,
card_list = [],
module_list = [],
other_module_list = [],
tool_list = [],
current_business_application_title = '';
function pushNewCard() {
......@@ -128,15 +130,21 @@
for (i = 0; i < len; i += 1) {
// Inject the module url into the document
document_list[i].link = url_list[i];
// Create card if needed
if (document_list[i].business_application_translated_title !==
current_business_application_title) {
pushNewCard();
module_list = [];
current_business_application_title =
document_list[i].business_application_translated_title;
// Tools do not have any business application
// Workaround this limitation
if (document_list[i].id.indexOf('portal_') === 0) {
tool_list.push(document_list[i]);
} else {
// Create card if needed
if (document_list[i].business_application_translated_title !==
current_business_application_title) {
pushNewCard();
module_list = [];
current_business_application_title =
document_list[i].business_application_translated_title;
}
module_list.push(document_list[i]);
}
module_list.push(document_list[i]);
}
pushNewCard();
if (other_module_list.length) {
......@@ -145,6 +153,12 @@
module_list: other_module_list
});
}
if (tool_list.length) {
card_list.push({
business_application_translated_title: translated_tool_title,
module_list: tool_list
});
}
generateCardList(gadget.element.querySelector('ul'), card_list);
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>986.54125.60966.30924</string> </value>
<value> <string>991.59254.15114.55603</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1600957441.42</float>
<float>1620402959.3</float>
<string>UTC</string>
</tuple>
</state>
......
erp5_mysql_innodb/SQLCatalog_makeModuleListQuery
\ No newline at end of file
module_id | SQLCatalog_makeModuleListQuery
\ 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>testDisplayToolsSection</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>Test Display Tools Section</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">
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Display Tools Section</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/?page=preference</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/enable_developer_mode" />
<tal:block tal:define="click_configuration python: {'text': 'Modules'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_panel_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertElementPresent</td>
<td>//ul[@class="ui-list-grid"]/li[2]/h2[text()="Tools"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//a[text()="Business Templates" and href=contains(text(), "n.jio_key=portal_templates")]</td>
<td></td>
</tr>
<tal:block tal:define="click_configuration python: {'text': 'Preferences'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_panel_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'User Interface'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_panel_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>uncheck</td>
<td>//input[@id="field_my_preferred_html_style_developper_mode"]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tal:block tal:define="click_configuration python: {'text': 'Modules'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_panel_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertElementNotPresent</td>
<td>//ul[@class="ui-list-grid"]/li[2]/h2[text()="Tools"]</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