Commit 8329e8a6 authored by Nicolas Delaby's avatar Nicolas Delaby

Allow to call nextPage and previousPage without REQUEST parameter

if REQUEST exists then redirection is performed. So listbox is rendered
uselessly.
parent c15cd672
...@@ -793,7 +793,8 @@ class SelectionTool( BaseTool, SimpleItem ): ...@@ -793,7 +793,8 @@ class SelectionTool( BaseTool, SimpleItem ):
return self.checkAll(list_selection_name, uids, REQUEST=REQUEST) return self.checkAll(list_selection_name, uids, REQUEST=REQUEST)
security.declareProtected(ERP5Permissions.View, 'nextPage') security.declareProtected(ERP5Permissions.View, 'nextPage')
def nextPage(self, list_selection_name, listbox_uid, uids=None, REQUEST=None): def nextPage(self, list_selection_name, listbox_uid, uids=None,
list_start=0, REQUEST=None):
""" """
Access the next page of a list Access the next page of a list
""" """
...@@ -802,21 +803,23 @@ class SelectionTool( BaseTool, SimpleItem ): ...@@ -802,21 +803,23 @@ class SelectionTool( BaseTool, SimpleItem ):
if selection is not None: if selection is not None:
params = selection.getParams() params = selection.getParams()
lines = int(params.get('list_lines', 0)) lines = int(params.get('list_lines', 0))
form = REQUEST.form if REQUEST is not None:
if form.has_key('page_start'): form = REQUEST.form
try: if form.has_key('page_start'):
list_start = (int(form.pop('page_start', 0)) - 1) * lines try:
except (ValueError, TypeError): list_start = (int(form.pop('page_start', 0)) - 1) * lines
list_start = 0 except (ValueError, TypeError):
else: list_start = 0
list_start = int(form.pop('list_start', 0)) else:
list_start = int(form.pop('list_start', 0))
params['list_start'] = max(list_start + lines, 0) params['list_start'] = max(list_start + lines, 0)
selection.edit(params=params) selection.edit(params=params)
self.uncheckAll(list_selection_name, listbox_uid) self.uncheckAll(list_selection_name, listbox_uid)
return self.checkAll(list_selection_name, uids, REQUEST=REQUEST) return self.checkAll(list_selection_name, uids, REQUEST=REQUEST)
security.declareProtected(ERP5Permissions.View, 'previousPage') security.declareProtected(ERP5Permissions.View, 'previousPage')
def previousPage(self, list_selection_name, listbox_uid, uids=None, REQUEST=None): def previousPage(self, list_selection_name, listbox_uid, uids=None,
list_start=0, REQUEST=None):
""" """
Access the previous page of a list Access the previous page of a list
""" """
...@@ -825,14 +828,15 @@ class SelectionTool( BaseTool, SimpleItem ): ...@@ -825,14 +828,15 @@ class SelectionTool( BaseTool, SimpleItem ):
if selection is not None: if selection is not None:
params = selection.getParams() params = selection.getParams()
lines = int(params.get('list_lines', 0)) lines = int(params.get('list_lines', 0))
form = REQUEST.form if REQUEST is not None:
if form.has_key('page_start'): form = REQUEST.form
try: if form.has_key('page_start'):
list_start = (int(form.pop('page_start', 0)) - 1) * lines try:
except (ValueError, TypeError): list_start = (int(form.pop('page_start', 0)) - 1) * lines
list_start = 0 except (ValueError, TypeError):
else: list_start = 0
list_start = int(form.pop('list_start', 0)) else:
list_start = int(form.pop('list_start', 0))
params['list_start'] = max(list_start - lines, 0) params['list_start'] = max(list_start - lines, 0)
selection.edit(params=params) selection.edit(params=params)
self.uncheckAll(list_selection_name, listbox_uid) self.uncheckAll(list_selection_name, listbox_uid)
......
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