Commit 10540a3c authored by Vincent Pelletier's avatar Vincent Pelletier

Unify page changes (next/previous/set) in listbox: make selection tool update the selection.

Remove parameter from request as it has been handled. This is needed because when there will be multiple listboxes on the same page with their subfields prefixed, updating the selection would not know which prefix to use, and would overwrite the value computed from selection tool with bare transmited value.
Not updating first/last variants since they are broken.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21999 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b4b92a1f
...@@ -2213,18 +2213,7 @@ class ListBoxHTMLRenderer(ListBoxRenderer): ...@@ -2213,18 +2213,7 @@ class ListBoxHTMLRenderer(ListBoxRenderer):
def getLineStart(self): def getLineStart(self):
"""Return a requested start number. """Return a requested start number.
""" """
try: return int(self.getParamDict().get('list_start', 0))
start = self.request.get('list_start')
start = int(start)
except (TypeError, KeyError):
param_dict = self.getParamDict()
start = param_dict.get('list_start', 0)
if isinstance(start, list):
start = start[0]
start = int(start)
start = max(start, 0)
return start
getLineStart = lazyMethod(getLineStart) getLineStart = lazyMethod(getLineStart)
......
...@@ -672,8 +672,9 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -672,8 +672,9 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
selection = self.getSelectionFor(list_selection_name, REQUEST) selection = self.getSelectionFor(list_selection_name, REQUEST)
params = selection.getParams() params = selection.getParams()
lines = params.get('list_lines', 0) lines = params.get('list_lines', 0)
start = params.get('list_start', 0) start = REQUEST.form.pop('list_start', 0)
REQUEST.form['list_start'] = int(start) + int(lines) params['list_start'] = int(start) + int(lines)
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)
...@@ -686,8 +687,9 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -686,8 +687,9 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
selection = self.getSelectionFor(list_selection_name, REQUEST) selection = self.getSelectionFor(list_selection_name, REQUEST)
params = selection.getParams() params = selection.getParams()
lines = params.get('list_lines', 0) lines = params.get('list_lines', 0)
start = params.get('list_start', 0) start = REQUEST.form.pop('list_start', 0)
REQUEST.form['list_start'] = max(int(start) - int(lines), 0) params['list_start'] = max(int(start) - int(lines), 0)
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)
...@@ -699,7 +701,7 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -699,7 +701,7 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
if uids is None: uids = [] if uids is None: uids = []
selection = self.getSelectionFor(list_selection_name, REQUEST) selection = self.getSelectionFor(list_selection_name, REQUEST)
params = selection.getParams() params = selection.getParams()
params['list_start'] = REQUEST.form.get('list_start', 0) params['list_start'] = int(REQUEST.form.pop('list_start', 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, query_string=query_string) return self.checkAll(list_selection_name, uids, REQUEST=REQUEST, query_string=query_string)
......
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