Commit 0cd2099e authored by Vincent Pelletier's avatar Vincent Pelletier

Make SelectionTool methods available on Folder documents to avoid a redirect...

Make SelectionTool methods available on Folder documents to avoid a redirect after selection modification. This should fix listbox page changes failing on big listboxes.
Update default listbox rendering page template.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11833 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d8c8e865
...@@ -92,6 +92,8 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -92,6 +92,8 @@ class SelectionTool( UniqueObject, SimpleItem ):
no_reset=False, no_report_depth=False): no_reset=False, no_report_depth=False):
"""Redirect to the original form or dialog, using the information given """Redirect to the original form or dialog, using the information given
as parameters. as parameters.
(Actually does not redirect in the HTTP meaning because of URL
limitation problems.)
DEPRECATED parameters : DEPRECATED parameters :
query_string is used to transmit parameters from caller to callee. query_string is used to transmit parameters from caller to callee.
...@@ -102,25 +104,19 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -102,25 +104,19 @@ class SelectionTool( UniqueObject, SimpleItem ):
if REQUEST is None: if REQUEST is None:
return return
parameter_list = REQUEST.form.copy() if no_reset and REQUEST.form.has_key('reset'):
if no_reset and parameter_list.has_key('reset'): REQUEST.form['noreset'] = REQUEST.form['reset'] # Kept for compatibility - might no be used anymore
parameter_list['noreset'] = parameter_list['reset'] # Kept for compatibility - might no be used anymore del REQUEST.form['reset']
del parameter_list['reset'] if no_report_depth and REQUEST.form.has_key('report_depth'):
if no_report_depth and parameter_list.has_key('report_depth'): REQUEST.form['noreport_depth'] = REQUEST.form['report_depth'] # Kept for compatibility - might no be used anymore
parameter_list['noreport_depth'] = parameter_list['report_depth'] # Kept for compatibility - might no be used anymore del REQUEST.form['report_depth']
del parameter_list['report_depth']
rendered_parameter_list = make_query(dict([(k, v) for k, v in REQUEST.form.iteritems() if v is not None]))
if query_string is not None: if query_string is not None:
LOG('SelectionTool', 0, 'DEPRECATED: _redirectToOriginalForm got called with a query_string. The variables must be passed in REQUEST.form.') LOG('SelectionTool', 0, 'DEPRECATED: _redirectToOriginalForm got called with a query_string. The variables must be passed in REQUEST.form.')
context = self.aq_parent context = REQUEST['PARENTS'][0]
form_id = dialog_id or REQUEST.get('dialog_id', None) or form_id or REQUEST.get('form_id', 'view') form_id = dialog_id or REQUEST.get('dialog_id', None) or form_id or REQUEST.get('form_id', 'view')
url = context.absolute_url() + '/' + form_id return getattr(context, form_id)()
if len(rendered_parameter_list) > 0:
url = '%s?%s' % (url, rendered_parameter_list)
return REQUEST.RESPONSE.redirect(url)
security.declareProtected(ERP5Permissions.View, 'getSelectionNames') security.declareProtected(ERP5Permissions.View, 'getSelectionNames')
def getSelectionNames(self, context=None, REQUEST=None): def getSelectionNames(self, context=None, REQUEST=None):
...@@ -1336,3 +1332,31 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol ...@@ -1336,3 +1332,31 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol
return tree_list return tree_list
# Monkeypatch Folder so it can access portal_activities
# Cannot be done in ERP5Type/Document/Folder.py because ERP5Type must not
# depend on ERP5Form
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Document.Folder import Folder
from ZPublisher.mapply import mapply
method_id_filter_list = [x for x in dir(Folder) if getattr(Folder, x, None) is not None and callable(getattr(Folder, x))]
method_id_filter_list.extend(['_aq_dynamic', ])
candidate_method_id_list = [x for x in dir(SelectionTool) if getattr(SelectionTool, x, None) is not None and callable(getattr(SelectionTool, x)) and not x.startswith('_') and not x.endswith('__roles__') and x not in method_id_filter_list]
for property_id in candidate_method_id_list:
def portal_selection_wrapper(self, wrapper_property_id=property_id, *args, **kw):
"""
Wrapper method for SelectionTool.
"""
portal_selection = getToolByName(self, 'portal_selections')
request = self.REQUEST
method = getattr(portal_selection, wrapper_property_id)
return mapply(method, positional=args, keyword=request,
context=self, bind=1)
setattr(Folder, property_id, portal_selection_wrapper)
security_property_id = '%s__roles__' % (property_id, )
security_property = getattr(SelectionTool, security_property_id, None)
if security_property is not None:
setattr(Folder, security_property_id, security_property)
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
tal:define="selected_domain_path here/getSelectedDomainPath"> tal:define="selected_domain_path here/getSelectedDomainPath">
<tr> <tr>
<td valign="top"> <td valign="top">
<select name="domain_root_url" onChange="submitAction(this.form, 'context/portal_selections/setDomainRoot')" <select name="domain_root_url"
tal:attributes="onChange string:submitAction(this.form, '${context_url}/portal_selections/setDomainRoot')"> tal:attributes="onChange string:submitAction(this.form, '${context_url}/setDomainRoot')">
<tal:block tal:repeat="c here/getDomainRootList"> <tal:block tal:repeat="c here/getDomainRootList">
<option value="base_domain" <option value="base_domain"
tal:define="path python: c[0]; title python: c[1]" tal:define="path python: c[0]; title python: c[1]"
...@@ -60,10 +60,10 @@ ...@@ -60,10 +60,10 @@
tal:attributes="colspan python: total_depth - report_tree.depth + 1"> tal:attributes="colspan python: total_depth - report_tree.depth + 1">
<a href="method" <a href="method"
tal:condition="report_tree/is_open" tal:condition="report_tree/is_open"
tal:attributes="href string:portal_selections/foldDomain?domain_url=${report_tree/domain_url}&form_id=${form_id}&list_selection_name=${selection_name}&domain_depth:int=${report_tree/depth}">-&nbsp;<b tal:content="report_tree/obj/getTranslatedTitleOrId">Domain</b></a> tal:attributes="href string:foldDomain?domain_url=${report_tree/domain_url}&form_id=${form_id}&list_selection_name=${selection_name}&domain_depth:int=${report_tree/depth}">-&nbsp;<b tal:content="report_tree/obj/getTranslatedTitleOrId">Domain</b></a>
<a href="method" <a href="method"
tal:condition="not: report_tree/is_open" tal:condition="not: report_tree/is_open"
tal:attributes="href string:portal_selections/unfoldDomain?domain_url=${report_tree/domain_url}&form_id=${form_id}&list_selection_name=${selection_name}&domain_depth:int=${report_tree/depth}">+&nbsp;<tal:block tal:content="report_tree/obj/getTranslatedTitleOrId">Domain</tal:block></a> tal:attributes="href string:unfoldDomain?domain_url=${report_tree/domain_url}&form_id=${form_id}&list_selection_name=${selection_name}&domain_depth:int=${report_tree/depth}">+&nbsp;<tal:block tal:content="report_tree/obj/getTranslatedTitleOrId">Domain</tal:block></a>
</td> </td>
</tr> </tr>
</table> </table>
...@@ -107,21 +107,21 @@ ...@@ -107,21 +107,21 @@
<td style="white-space: nowrap; vertical-align: middle"> <td style="white-space: nowrap; vertical-align: middle">
<input tal:condition="python: is_domain_tree_supported or is_report_tree_supported" <input tal:condition="python: is_domain_tree_supported or is_report_tree_supported"
type="image" src="text_block.png" id="listbox_flat_list_mode" type="image" src="text_block.png" id="listbox_flat_list_mode"
title="Flat List" name="portal_selections/setFlatListMode:method" title="Flat List" name="setFlatListMode:method"
value="1" alt="Flat List" value="1" alt="Flat List"
tal:attributes="src string:${portal_url_string}/images/text_block.png; tal:attributes="src string:${portal_url_string}/images/text_block.png;
id string:${field_id}_flat_list_mode" id string:${field_id}_flat_list_mode"
i18n:domain="ui" i18n:attributes="title" /> i18n:domain="ui" i18n:attributes="title" />
<input tal:condition="is_report_tree_supported" <input tal:condition="is_report_tree_supported"
type="image" src="view_tree.png" id="listbox_report_tree_mode" type="image" src="view_tree.png" id="listbox_report_tree_mode"
title="Report Tree" name="portal_selections/setReportTreeMode:method" title="Report Tree" name="setReportTreeMode:method"
value="1" alt="Report Tree" value="1" alt="Report Tree"
tal:attributes="src string:${portal_url_string}/images/view_tree.png; tal:attributes="src string:${portal_url_string}/images/view_tree.png;
id string:${field_id}_report_tree_mode" id string:${field_id}_report_tree_mode"
i18n:domain="ui" i18n:attributes="title" /> i18n:domain="ui" i18n:attributes="title" />
<input tal:condition="is_domain_tree_supported" <input tal:condition="is_domain_tree_supported"
type="image" src="view_choose.png" id="listbox_domain_tree_mode" type="image" src="view_choose.png" id="listbox_domain_tree_mode"
title="Domain Tree" name="portal_selections/setDomainTreeMode:method" title="Domain Tree" name="setDomainTreeMode:method"
value="1" alt="Domain Tree" value="1" alt="Domain Tree"
tal:attributes="src string:${portal_url_string}/images/view_choose.png; tal:attributes="src string:${portal_url_string}/images/view_choose.png;
id string:${field_id}_domain_tree_mode" id string:${field_id}_domain_tree_mode"
...@@ -142,17 +142,16 @@ ...@@ -142,17 +142,16 @@
<td style="white-space: nowrap; vertical-align: middle; text-align: center;"> <td style="white-space: nowrap; vertical-align: middle; text-align: center;">
<input tal:condition="python: here.current_page > 0" <input tal:condition="python: here.current_page > 0"
id="listbox_previous_page" type="image" src="1leftarrowv.png" id="listbox_previous_page" type="image" src="1leftarrowv.png"
title="Previous Page" name="portal_selections/previousPage:method" title="Previous Page" name="previousPage:method"
tal:attributes="id string:${field_id}_previous_page; tal:attributes="id string:${field_id}_previous_page;
src string:${portal_url_string}/images/1leftarrowv.png" src string:${portal_url_string}/images/1leftarrowv.png"
i18n:domain="ui" i18n:attributes="title" /> i18n:domain="ui" i18n:attributes="title" />
</td> </td>
<td style="white-space: nowrap; vertical-align: middle; text-align: center"> <td style="white-space: nowrap; vertical-align: middle; text-align: center">
<select id="listbox_page_selection" name="list_start" title="Change Page" size="1" <select id="listbox_page_selection" name="list_start" title="Change Page" size="1"
onChange="submitAction(this.form, 'context/portal_selections/setPage')"
tal:define="lines here/getMaxLineNumber" tal:define="lines here/getMaxLineNumber"
tal:attributes="id string:${field_id}_page_selection; tal:attributes="id string:${field_id}_page_selection;
onChange string:submitAction(this.form, '${context_url}/portal_selections/setPage')" onChange string:submitAction(this.form, '${context_url}/setPage')"
i18n:domain="ui" i18n:attributes="title"> i18n:domain="ui" i18n:attributes="title">
<option value="0" <option value="0"
tal:repeat="p python: range(0, here.total_pages)" tal:repeat="p python: range(0, here.total_pages)"
...@@ -164,7 +163,7 @@ ...@@ -164,7 +163,7 @@
<td style="white-space: nowrap; vertical-align: middle; text-align: center"> <td style="white-space: nowrap; vertical-align: middle; text-align: center">
<input tal:condition="python: here.current_page < here.total_pages - 1" <input tal:condition="python: here.current_page < here.total_pages - 1"
id="listbox_next_page" type="image" src="1rightarrowv.png" id="listbox_next_page" type="image" src="1rightarrowv.png"
title="Next Page" name="portal_selections/nextPage:method" title="Next Page" name="nextPage:method"
tal:attributes="id string:${field_id}_next_page; tal:attributes="id string:${field_id}_next_page;
src string:${portal_url_string}/images/1rightarrowv.png" src string:${portal_url_string}/images/1rightarrowv.png"
i18n:domain="ui" i18n:attributes="title" /> i18n:domain="ui" i18n:attributes="title" />
...@@ -178,8 +177,7 @@ ...@@ -178,8 +177,7 @@
<td tal:condition="is_report_tree_mode" <td tal:condition="is_report_tree_mode"
class="Data" style="width: 50px; text-align: left; vertical-align: middle"> class="Data" style="width: 50px; text-align: left; vertical-align: middle">
<select name="report_root_url" <select name="report_root_url"
onChange="submitAction(this.form, 'context/portal_selections/setReportRoot')" tal:attributes="onChange string:submitAction(this.form, '${context_url}/setReportRoot')">
tal:attributes="onChange string:submitAction(this.form, '${context_url}/portal_selections/setReportRoot')">
<tal:block tal:repeat="c here/getReportRootList"> <tal:block tal:repeat="c here/getReportRootList">
<option value="base_domain" <option value="base_domain"
tal:define="path python: c[0]; title python: c[1]" tal:define="path python: c[0]; title python: c[1]"
...@@ -191,11 +189,11 @@ ...@@ -191,11 +189,11 @@
<td tal:condition="show_select_column" <td tal:condition="show_select_column"
class="Data" style="width: 50px; text-align: center; vertical-align: middle"> class="Data" style="width: 50px; text-align: center; vertical-align: middle">
<input id="listbox_check_all" type="image" <input id="listbox_check_all" type="image"
name="portal_selections/checkAll:method" value="1" name="checkAll:method" value="1"
src="checkall.png" alt="Check All" title="Check All" src="checkall.png" alt="Check All" title="Check All"
tal:attributes="id string:${field_id}_check_all; tal:attributes="id string:${field_id}_check_all;
src string:${portal_url_string}/images/checkall.png" src string:${portal_url_string}/images/checkall.png"
i18n:domain="ui" i18n:attributes="title" />&nbsp;<input id="listbox_uncheck_all" type="image" name="portal_selections/uncheckAll:method" value="1" i18n:domain="ui" i18n:attributes="title" />&nbsp;<input id="listbox_uncheck_all" type="image" name="uncheckAll:method" value="1"
src="%(portal_url_string)s/images/decheckall.png" style="border: 0" alt="Uncheck All" title="Uncheck All" src="%(portal_url_string)s/images/decheckall.png" style="border: 0" alt="Uncheck All" title="Uncheck All"
tal:attributes="id string:${field_id}_uncheck_all; tal:attributes="id string:${field_id}_uncheck_all;
src string:${portal_url_string}/images/decheckall.png" src string:${portal_url_string}/images/decheckall.png"
...@@ -206,8 +204,7 @@ ...@@ -206,8 +204,7 @@
title python: value[1]; title python: value[1];
sort_order python: value[2]"> sort_order python: value[2]">
<td tal:condition="sql" class="Data"> <td tal:condition="sql" class="Data">
<a href="portal_selections/setSelectionQuickSortOrder?selection_name=default&amp;sort_on=id&amp;form_id=view" <a tal:attributes="href string:setSelectionQuickSortOrder?selection_name=${selection_name}&amp;sort_on=${sql}&amp;form_id=${form_id}"
tal:attributes="href string:portal_selections/setSelectionQuickSortOrder?selection_name=${selection_name}&amp;sort_on=${sql}&amp;form_id=${form_id}"
tal:content="title" i18n:domain="ui" i18n:translate="">ID</a> tal:content="title" i18n:domain="ui" i18n:translate="">ID</a>
<img tal:condition="python: sort_order == 'ascending'" <img tal:condition="python: sort_order == 'ascending'"
src="1bottomarrow.png" alt="Ascending Display" title="Ascending Display" src="1bottomarrow.png" alt="Ascending Display" title="Ascending Display"
...@@ -274,9 +271,8 @@ ...@@ -274,9 +271,8 @@
tal:attributes="class css" tal:attributes="class css"
tal:define="section_name python: line.getContext() is not None and line.getContext().getTitleOrId() or ''"> tal:define="section_name python: line.getContext() is not None and line.getContext().getTitleOrId() or ''">
<a tal:condition="section_name" <a tal:condition="section_name"
href="portal_selections/foldReport?report_url=base_domain&amp;form_id=form&amp;list_selection_name=default"
tal:define="method_id python: line.isOpen() and 'foldReport' or 'unfoldReport'" tal:define="method_id python: line.isOpen() and 'foldReport' or 'unfoldReport'"
tal:attributes="href string:portal_selections/${method_id}?report_url=${line/getDomainUrl}&amp;form_id=${form_id}&amp;list_selection_name=${selection_name}" tal:attributes="href string:${method_id}?report_url=${line/getDomainUrl}&amp;form_id=${form_id}&amp;list_selection_name=${selection_name}"
tal:content="structure python: '%s%s&nbsp;%s' % ('&nbsp;&nbsp;' * line.getDepth(), line.isOpen() and '-' or '+', section_name)" /> tal:content="structure python: '%s%s&nbsp;%s' % ('&nbsp;&nbsp;' * line.getDepth(), line.isOpen() and '-' or '+', section_name)" />
</td> </td>
<td tal:condition="here/showSelectColumn" <td tal:condition="here/showSelectColumn"
......
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