Commit 1dcdeece authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: Query and display tools by catalog if access tool is activated

To activate it, we have a preference to allow users display or not ERP5 tools
parent a3585730
portal = context.getPortalObject()
is_access_tool_enabled = (portal.portal_preferences
.getPreferredHtmlStyleAccessTool())
sql_catalog = portal.portal_catalog.getSQLCatalog()
query = sql_catalog.buildQuery({
"id": "%\\_module",
"meta_type": "ERP5 Folder"
})
if is_access_tool_enabled:
query = sql_catalog.buildQuery({
"id": "portal\\_%",
"query": query
}, operator="or")
return sql_catalog.buildQuery({
"id": value,
"parent_uid": 0,
"query": query
})
<?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 @@ ...@@ -2,6 +2,7 @@
<html> <html>
<!-- <!--
data-i18n=Others data-i18n=Others
data-i18n=Tools
--> -->
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>989.60433.59989.54698</string> </value> <value> <string>986.51245.10858.8089</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1612969553.17</float> <float>1605547612.43</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
// Acquired methods // Acquired methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("getUrlForList", "getUrlForList") .declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
// First, get the list of modules // First, get the list of modules
return gadget.jio_allDocs({ return gadget.jio_allDocs({
select_list: select_list, select_list: select_list,
query: '(parent_uid:"0" AND meta_type:"ERP5 Folder" AND id:"%_module")', query: 'module_id:%',
limit: 1000 limit: 1000
}) })
.push(function (result_list) { .push(function (result_list) {
...@@ -96,19 +96,21 @@ ...@@ -96,19 +96,21 @@
url_dict_list.push({command: 'display', options: {page: 'language'}}); url_dict_list.push({command: 'display', options: {page: 'language'}});
return RSVP.all([ return RSVP.all([
document_list, document_list,
gadget.translate('Others'), gadget.getTranslationList(['Others', 'Tools']),
gadget.getUrlForList(url_dict_list) gadget.getUrlForList(url_dict_list)
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
var document_list = result_list[0], 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], url_list = result_list[2],
len = document_list.length, len = document_list.length,
i, i,
card_list = [], card_list = [],
module_list = [], module_list = [],
other_module_list = [], other_module_list = [],
tool_list = [],
current_business_application_title = ''; current_business_application_title = '';
function pushNewCard() { function pushNewCard() {
...@@ -128,15 +130,21 @@ ...@@ -128,15 +130,21 @@
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
// Inject the module url into the document // Inject the module url into the document
document_list[i].link = url_list[i]; document_list[i].link = url_list[i];
// Create card if needed // Tools do not have any business application
if (document_list[i].business_application_translated_title !== // Workaround this limitation
current_business_application_title) { if (document_list[i].id.indexOf('portal_') === 0) {
pushNewCard(); tool_list.push(document_list[i]);
module_list = []; } else {
current_business_application_title = // Create card if needed
document_list[i].business_application_translated_title; 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(); pushNewCard();
if (other_module_list.length) { if (other_module_list.length) {
...@@ -145,6 +153,12 @@ ...@@ -145,6 +153,12 @@
module_list: other_module_list 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); generateCardList(gadget.element.querySelector('ul'), card_list);
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>986.54125.60966.30924</string> </value> <value> <string>991.59254.15114.55603</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>1600957441.42</float> <float>1620402959.3</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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_access_tool" />
<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_access_tool"]</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
...@@ -1808,4 +1808,25 @@ ...@@ -1808,4 +1808,25 @@
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
</tal:block> </tal:block>
<tal:block metal:define-macro="enable_access_tool">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/toggle_editable_mode" />
<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>waitForElementPresent</td>
<td>//input[@id="field_my_preferred_html_style_access_tool"]</td>
<td></td>
</tr>
<tr>
<td>check</td>
<td>//input[@id="field_my_preferred_html_style_access_tool"]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
</tal:block>
</tal:block> </tal:block>
\ No newline at end of file
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
<string>my_preferred_date_order</string> <string>my_preferred_date_order</string>
<string>my_preferred_html_style_unsaved_form_warning</string> <string>my_preferred_html_style_unsaved_form_warning</string>
<string>my_preferred_html_style_developper_mode</string> <string>my_preferred_html_style_developper_mode</string>
<string>my_preferred_html_style_access_tool</string>
<string>my_preferred_html_style_contextual_help</string> <string>my_preferred_html_style_contextual_help</string>
<string>my_preferred_html_style_translator_mode</string> <string>my_preferred_html_style_translator_mode</string>
<string>my_preferred_html_style_access_tab</string> <string>my_preferred_html_style_access_tab</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="CheckBoxField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_html_style_access_tool</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Indicate if we display useful links to access ERP5 tools in interface or not</string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Access Tool</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.getPortalObject().portal_membership.checkPermission("Manage portal", here)</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/boolean</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>When true, tools will be displayed.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_html_style_access_tool_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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