Commit 77bf8a66 authored by Romain Courteaud's avatar Romain Courteaud

erp5_osoe_web_renderjs_ui: access tab

parent e4320405
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_onlyjio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_onlyjio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>list_all_portal_type_to_create</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>5.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>New Document</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/TypesTool_viewAllPortalTypeDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_onlyjio_jump</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_onlyjio_jump</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>list_all_report</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>4.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Site Reports</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/TypesTool_viewAllReportDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<!--
data-i18n=List All Report
data-i18n=Contribute File
data-i18n=New
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Osoe Access</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_erp5_page_osoe_access.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_page_access.html"
data-gadget-scope="access" />
</body>
</html>
\ No newline at end of file
/*jslint indent: 2, maxerr: 3, maxlen: 80 */
/*global window, rJS, RSVP */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
.declareAcquiredMethod("getTranslationDict", "getTranslationDict")
.declareMethod('render', function (options) {
return new RSVP.Queue(RSVP.hash({
access_gadget: this.getDeclaredGadget('access'),
translation_dict: this.getTranslationDict([
'Site Reports',
'Contribute File',
'New'
])
}))
.push(function (result_dict) {
return result_dict.access_gadget.render(options, [{
title: result_dict.translation_dict['Site Reports'],
jio_key: 'portal_types',
erp5_action: 'list_all_report'
}, {
title: result_dict.translation_dict.New,
jio_key: 'portal_types',
erp5_action: 'list_all_portal_type_to_create'
}, {
title: result_dict.translation_dict['Contribute File'],
jio_key: 'document_module',
erp5_action: 'contribute_file'
}]);
});
});
}(window, rJS, RSVP));
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Site Documents Creator</title>
<!--link rel="http://www.renderjs.org/rel/interface" href="interface_page.html"-->
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="gadget_erp5_site_document_creator.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*global domsugar, window, rJS */
(function (domsugar, window, rJS) {
"use strict";
rJS(window)
.declareAcquiredMethod("notifySubmit", "notifySubmit")
.declareMethod('render', function (options) {
return this.changeState({
key: options.key,
erp5_add_list: JSON.stringify(options.erp5_add_list)
});
})
.onStateChange(function () {
var gadget = this,
erp5_add_list = JSON.parse(gadget.state.erp5_add_list),
i,
j,
k,
business_application_element_list = [],
module_element_list;
for (i = 0; i < erp5_add_list.length; i += 1) {
module_element_list = [];
for (j = 0; j < erp5_add_list[i][1].length; j += 1) {
for (k = 0; k < erp5_add_list[i][1][j][2].length; k += 1) {
module_element_list.push(
domsugar('li', [domsugar('button', {
type: 'submit',
'data-value': erp5_add_list[i][1][j][1] + ' ' +
erp5_add_list[i][1][j][2][k][1],
text: erp5_add_list[i][1][j][2][k][0]
})])
);
}
}
business_application_element_list.push(domsugar('li', [
domsugar('h2', {
text: erp5_add_list[i][0]
}),
domsugar('ul', module_element_list)
]));
}
domsugar(gadget.element, [
domsugar('ul', {'class': 'ui-list-grid'},
business_application_element_list)
]);
})
.declareMethod('getContent', function () {
var result = {};
if (this.state.value !== undefined) {
result[this.state.key] = this.state.value;
}
return result;
}, {mutex: 'changestate'})
.declareMethod('checkValidity', function () {
return (this.state.value !== undefined);
}, {mutex: 'changestate'})
.onEvent('click', function (evt) {
if (evt.target.tagName === 'BUTTON') {
this.state.value = evt.target.getAttribute('data-value');
}
return this.notifySubmit();
}, false);
}(domsugar, window, rJS));
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Site Reports</title>
<!--link rel="http://www.renderjs.org/rel/interface" href="interface_page.html"-->
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="gadget_erp5_site_report_viewer.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*global domsugar, window, rJS, RSVP */
(function (domsugar, window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getTranslationDict", "getTranslationDict")
.declareAcquiredMethod("getUrlForDict", "getUrlForDict")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareMethod('triggerSubmit', function () {
return;
})
.allowPublicAcquisition('updateHeader', function () {
return;
})
.allowPublicAcquisition('updatePanel', function () {
return;
})
////////////////////////////////////////////////////////////////////
// Go
////////////////////////////////////////////////////////////////////
.declareMethod('render', function (options) {
var gadget = this,
erp5_report_list = options.erp5_report_list,
i,
j,
k,
business_application_element_list = [],
module_element_list,
url_for_dict = {};
for (i = 0; i < erp5_report_list.length; i += 1) {
for (j = 0; j < erp5_report_list[i][1].length; j += 1) {
for (k = 0; k < erp5_report_list[i][1][j][2].length; k += 1) {
url_for_dict[erp5_report_list[i][1][j][1] +
erp5_report_list[i][1][j][2][k][1]] = {
command: 'display_erp5_action_with_history',
options: {
jio_key: erp5_report_list[i][1][j][1],
page: erp5_report_list[i][1][j][2][k][1]
}
};
}
}
}
return new RSVP.Queue(gadget.getUrlForDict(url_for_dict))
.push(function (url_dict) {
for (i = 0; i < erp5_report_list.length; i += 1) {
module_element_list = [];
for (j = 0; j < erp5_report_list[i][1].length; j += 1) {
module_element_list.push(
domsugar('li', [domsugar('h3', {
text: erp5_report_list[i][1][j][0]
})])
);
for (k = 0; k < erp5_report_list[i][1][j][2].length; k += 1) {
module_element_list.push(
domsugar('li', [domsugar('a', {
href: url_dict[erp5_report_list[i][1][j][1] +
erp5_report_list[i][1][j][2][k][1]],
text: erp5_report_list[i][1][j][2][k][0]
})])
);
}
}
business_application_element_list.push(domsugar('li', [
domsugar('h2', {
text: erp5_report_list[i][0]
}),
domsugar('ul', module_element_list)
]));
}
domsugar(gadget.element, [
domsugar('ul', {'class': 'ui-list-grid'},
business_application_element_list)
]);
});
});
}(domsugar, window, rJS, RSVP));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_osoe_web_renderjs</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
module_id, select_action = select_action.split(' ', 1)
module = portal.restrictedTraverse(module_id)
return module.Base_doAction(select_action, dialog_id, **kw)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</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>_params</string> </key>
<value> <string>select_action, dialog_id, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_doSiteAction</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.Cache import CachingMethod
portal = context.getPortalObject()
def getModuleActionInformationDict(**kw):
Base_translateString = portal.Base_translateString
result_dict = {}
# If the user is not allowed to get the category, return immediately.
business_application = portal.restrictedTraverse('portal_categories/business_application',
None)
if business_application is None:
return result_dict
listFilteredActionsFor = portal.portal_actions.listFilteredActionsFor
# Use searchFolder, because security checks are required, and sorting
# is not supported by listFolderContents.
for o in business_application.searchFolder(sort_on='int_index'):
module_category = o.getObject()
module_list = module_category.getBusinessApplicationRelatedValueList(
checked_permission='View',
portal_type=portal.getPortalModuleTypeList())
# It is necessary to sort the modules by translated titles for convenience.
titled_module_list = [(module.getTranslatedTitle(), module) for module in module_list]
titled_module_list.sort(key=lambda x: x[0])
view_list = []
add_list = []
search_list = []
exchange_list = []
report_list = []
print_list = []
for translated_title, module in titled_module_list:
action_dict = module.Base_filterDuplicateActions(listFilteredActionsFor(module))
# Collect view actions.
# view_list.append((translated_title, module.getId()))
# Collect add actions.
module_add_list = []
for content_type in module.getVisibleAllowedContentTypeList():
action = 'add %s' % content_type
module_add_list.append((Base_translateString(content_type), action))
for template in module.getDocumentTemplateList():
action = 'template %s' % template.getRelativeUrl()
template_name = Base_translateString('${template_title} (Template)',
mapping=dict(template_title=template.getTitle()))
module_add_list.append((template_name, action))
if module_add_list:
add_list.append((translated_title, module.getId(), module_add_list))
"""
# Collect exchange actions.
module_exchange_list = []
for exchange_action in action_dict.get('object_exchange', ()):
url = renderCustomLink(exchange_action['url'],
dict(cancel_url=cancel_url,
form_id=form_id,
selection_name=selection_name,
dialog_category='object_exchange')).strip()
module_exchange_list.append((Base_translateString(exchange_action['name']), url))
if module_exchange_list:
exchange_list.append((translated_title, module_exchange_list))
"""
# Collect report actions.
module_report_list = []
for report_action in action_dict.get('object_jio_report', ()):
module_report_list.append((Base_translateString(report_action['name']), report_action['id']))
if module_report_list:
report_list.append((translated_title, module.getId(), module_report_list))
"""
# Collect print actions.
module_print_list = []
for print_action in action_dict.get('object_print', ()):
url = renderCustomLink(print_action['url'],
dict(cancel_url=cancel_url,
form_id=form_id,
selection_name=selection_name,
dialog_category='object_print')).strip()
module_print_list.append((Base_translateString(print_action['name']), url))
if module_print_list:
print_list.append((translated_title, module_print_list))
"""
# Add the actions, only if they are not empty.
for k, v in (('add', add_list),
('exchange', exchange_list), ('report', report_list),
('print', print_list), ('view', view_list)):
if v:
result_dict.setdefault(k, []).append((module_category.getTranslatedTitle(), v))