Commit 0af640e1 authored by Kevin Deldycke's avatar Kevin Deldycke

Add two new listbox related method to get the first page and the last page of...

Add two new listbox related method to get the first page and the last page of a multiple-page listbox.
Auto-delete of trailing spaces.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8679 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9eaeb22a
......@@ -26,8 +26,8 @@
#
##############################################################################
"""\
ERP portal_selection tool.
"""
ERP5 portal_selection tool.
"""
from OFS.Traversable import NotFound
......@@ -504,6 +504,48 @@ class SelectionTool( UniqueObject, SimpleItem ):
# ListBox related methods
security.declareProtected(ERP5Permissions.View, 'firstPage')
def firstPage(self, listbox_uid, uids=None, REQUEST=None):
"""
Access the first page of a list
"""
if uids is None: uids = []
request = REQUEST
#form_id = request.form_id
selection_name = request.list_selection_name
selection = self.getSelectionFor(selection_name, REQUEST)
params = selection.getParams()
params['list_start'] = 0
selection.edit(params=params)
self.uncheckAll(selection_name, listbox_uid)
return self.checkAll(selection_name, uids, REQUEST=REQUEST)
security.declareProtected(ERP5Permissions.View, 'lastPage')
def lastPage(self, listbox_uid, uids=None, REQUEST=None):
"""
Access the last page of a list
"""
if uids is None: uids = []
request = REQUEST
#form_id = request.form_id
selection_name = request.list_selection_name
selection = self.getSelectionFor(selection_name, REQUEST)
params = selection.getParams()
# XXX This will not work if the number of lines shown in the listbox is greater
# than the BIG_INT constan. Such a case has low probability but is not
# impossible. If you are in this case, send me a mail ! -- Kev
BIG_INT = 10000000
last_page_start = BIG_INT
total_lines = request.form.get('total_size', BIG_INT)
if total_lines != BIG_INT:
lines_per_page = params.get('list_lines', 1)
last_page_start = int(total_lines) - (int(total_lines) % int(lines_per_page))
params['list_start'] = last_page_start
selection.edit(params=params)
self.uncheckAll(selection_name, listbox_uid)
return self.checkAll(selection_name, uids, REQUEST=REQUEST)
security.declareProtected(ERP5Permissions.View, 'nextPage')
def nextPage(self, listbox_uid, uids=None, REQUEST=None):
"""
......@@ -518,8 +560,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
lines = params.get('list_lines',0)
start = params.get('list_start', 0)
params['list_start'] = int(start) + int(lines)
selection.edit(params= params)
selection.edit(params=params)
self.uncheckAll(selection_name, listbox_uid)
return self.checkAll(selection_name, uids, REQUEST=REQUEST)
......@@ -537,8 +578,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
lines = params.get('list_lines',0)
start = params.get('list_start', 0)
params['list_start'] = max(int(start) - int(lines), 0)
selection.edit(params= selection.params)
selection.edit(params=selection.params)
self.uncheckAll(selection_name, listbox_uid)
return self.checkAll(selection_name, uids, REQUEST=REQUEST)
......@@ -551,21 +591,19 @@ class SelectionTool( UniqueObject, SimpleItem ):
request = REQUEST
#form_id = request.form_id
selection_name = request.list_selection_name
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None:
params = selection.getParams()
lines = params.get('list_lines',0)
start = request.form.get('list_start',0)
params['list_start'] = start
selection.edit(params= selection.params)
self.uncheckAll(selection_name, listbox_uid)
return self.checkAll(selection_name, uids, REQUEST=REQUEST, query_string=query_string)
# PlanningBox related methods
security.declareProtected(ERP5Permissions.View, 'setZoomLevel')
def setZoomLevel(self, uids=None, REQUEST=None):
"""
......
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