From 33d0cd431749491689af43e19f232ab0678ca586 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Tue, 21 Apr 2009 18:17:11 +0000 Subject: [PATCH] accept page_start param in nextPage, previousPage and setPage to specify the page number instead of specifying starting line number of the page. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26571 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/SelectionTool.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/product/ERP5Form/SelectionTool.py b/product/ERP5Form/SelectionTool.py index 708d1daf48..9b10726bb4 100644 --- a/product/ERP5Form/SelectionTool.py +++ b/product/ERP5Form/SelectionTool.py @@ -674,9 +674,13 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): selection = self.getSelectionFor(list_selection_name, REQUEST) if selection is not None: params = selection.getParams() - lines = params.get('list_lines', 0) - start = REQUEST.form.pop('list_start', 0) - params['list_start'] = int(start) + int(lines) + lines = int(params.get('list_lines', 0)) + form = REQUEST.form + if form.has_key('page_start'): + list_start = (int(form.pop('page_start', 0)) - 1) * lines + else: + list_start = int(form.pop('list_start', 0)) + params['list_start'] = list_start + lines selection.edit(params=params) self.uncheckAll(list_selection_name, listbox_uid) return self.checkAll(list_selection_name, uids, REQUEST=REQUEST) @@ -690,9 +694,13 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): selection = self.getSelectionFor(list_selection_name, REQUEST) if selection is not None: params = selection.getParams() - lines = params.get('list_lines', 0) - start = REQUEST.form.pop('list_start', 0) - params['list_start'] = max(int(start) - int(lines), 0) + lines = int(params.get('list_lines', 0)) + form = REQUEST.form + if form.has_key('page_start'): + list_start = (int(form.pop('page_start', 0)) - 1) * lines + else: + list_start = int(form.pop('list_start', 0)) + params['list_start'] = max(list_start - lines, 0) selection.edit(params=params) self.uncheckAll(list_selection_name, listbox_uid) return self.checkAll(list_selection_name, uids, REQUEST=REQUEST) @@ -706,7 +714,13 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): selection = self.getSelectionFor(list_selection_name, REQUEST) if selection is not None: params = selection.getParams() - params['list_start'] = int(REQUEST.form.pop('list_start', 0)) + lines = int(params.get('list_lines', 0)) + form = REQUEST.form + if form.has_key('page_start'): + list_start = (int(form.pop('page_start', 0)) - 1) * lines + else: + list_start = int(form.pop('list_start', 0)) + params['list_start'] = list_start selection.edit(params=params) self.uncheckAll(list_selection_name, listbox_uid) return self.checkAll(list_selection_name, uids, REQUEST=REQUEST, query_string=query_string) -- 2.30.9