Commit e9f712d8 authored by Jean-Paul Smets's avatar Jean-Paul Smets

first working implementation of multipage checked uids


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@362 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d253b686
...@@ -392,6 +392,18 @@ class ListBoxWidget(Widget.Widget): ...@@ -392,6 +392,18 @@ class ListBoxWidget(Widget.Widget):
elif not params.has_key(k): elif not params.has_key(k):
params[k] = eval(v) params[k] = eval(v)
# Allow overriding list_method and stat_method by params
if params.has_key('list_method_id'):
#try:
list_method = getattr(here.portal_skins.local_list_method , params['list_method_id']) # Coramy specific
#except:
# list_method = list_method
if params.has_key('stat_method_id'):
#try:
list_method = getattr(here.portal_skins.local_list_method , params['stat_method_id']) # Coramy specific
#except:
# list_method = list_method
# Set the params spec (this should change in the future) # Set the params spec (this should change in the future)
params['meta_type'] = filtered_meta_types params['meta_type'] = filtered_meta_types
params['portal_type'] = filtered_portal_types params['portal_type'] = filtered_portal_types
...@@ -759,10 +771,10 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -759,10 +771,10 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
list_header = """\ list_header = """\
<tr >%s <tr >%s
<td class="Data" width="50" align="center" valign="middle"> <td class="Data" width="50" align="center" valign="middle">
<input type="image" name="Select All" <input type="image" name="portal_selections/checkAll:method" value="1"
src="/images/pro/images/checkall.png" border="0" alt="Select All" src="/images/pro/images/checkall.png" border="0" alt="Check All" />
onClick="SelectAll()" /> <input type="image" name="portal_selections/uncheckAll:method" value="1"
<img src="/images/pro/images/decheckall.png" border="0" alt="img"/></td> src="/images/pro/images/decheckall.png" border="0" alt="Uncheck All" />
""" % report_popup """ % report_popup
else: else:
list_header = """\ list_header = """\
......
...@@ -186,6 +186,56 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -186,6 +186,56 @@ class SelectionTool( UniqueObject, SimpleItem ):
selection_object = Selection(checked_uids=checked_uids) selection_object = Selection(checked_uids=checked_uids)
self.setSelectionFor(selection_name, selection_object, REQUEST) self.setSelectionFor(selection_name, selection_object, REQUEST)
security.declareProtected(ERP5Permissions.View, 'getSelectionCheckedUidsFor')
def getSelectionCheckedUidsFor(self, selection_name, REQUEST=None):
"""
Sets the selection params for a given selection_name
"""
selection_object = self.getSelectionFor(selection_name, REQUEST)
if selection_object:
return selection_object.selection_checked_uids
return []
security.declareProtected(ERP5Permissions.View, 'checkAll')
def checkAll(self, selection_name, listbox_uid, REQUEST=None):
"""
Sets the selection params for a given selection_name
"""
selection_object = self.getSelectionFor(selection_name, REQUEST)
if selection_object:
selection_uid_dict = {}
for uid in selection_object.selection_checked_uids:
selection_uid_dict[uid] = 1
for uid in listbox_uid:
selection_uid_dict[int(uid)] = 1
self.setSelectionCheckedUidsFor(selection_name, selection_uid_dict.keys(), REQUEST=REQUEST)
request = REQUEST
if request:
referer = request['HTTP_REFERER']
referer = referer.replace('reset=', 'noreset=')
referer = referer.replace('reset:int=', 'noreset:int=')
return request.RESPONSE.redirect(referer)
security.declareProtected(ERP5Permissions.View, 'uncheckAll')
def uncheckAll(self, selection_name, listbox_uid, REQUEST=None):
"""
Sets the selection params for a given selection_name
"""
selection_object = self.getSelectionFor(selection_name, REQUEST)
if selection_object:
selection_uid_dict = {}
for uid in selection_object.selection_checked_uids:
selection_uid_dict[uid] = 1
for uid in listbox_uid:
if selection_uid_dict.has_key(int(uid)): del selection_uid_dict[int(uid)]
self.setSelectionCheckedUidsFor(selection_name, selection_uid_dict.keys(), REQUEST=REQUEST)
request = REQUEST
if request:
referer = request['HTTP_REFERER']
referer = referer.replace('reset=', 'noreset=')
referer = referer.replace('reset:int=', 'noreset:int=')
return request.RESPONSE.redirect(referer)
security.declareProtected(ERP5Permissions.View, 'getSelectionListUrlFor') security.declareProtected(ERP5Permissions.View, 'getSelectionListUrlFor')
def getSelectionListUrlFor(self, selection_name, REQUEST=None): def getSelectionListUrlFor(self, selection_name, REQUEST=None):
""" """
...@@ -213,7 +263,7 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -213,7 +263,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
""" """
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST) selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None: if selection is not None:
selection.edit(invert_mode=0, params={}) selection.edit(invert_mode=0, params={}, checked_uids=[])
security.declareProtected(ERP5Permissions.View, 'setSelectionSortOrder') security.declareProtected(ERP5Permissions.View, 'setSelectionSortOrder')
def setSelectionSortOrder(self, selection_name, sort_on, REQUEST=None): def setSelectionSortOrder(self, selection_name, sort_on, REQUEST=None):
...@@ -253,6 +303,7 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -253,6 +303,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
request = REQUEST request = REQUEST
referer = request['HTTP_REFERER'] referer = request['HTTP_REFERER']
referer = referer.replace('reset=', 'noreset=') referer = referer.replace('reset=', 'noreset=')
referer = referer.replace('reset:int=', 'noreset:int=')
return request.RESPONSE.redirect(referer) return request.RESPONSE.redirect(referer)
security.declareProtected(ERP5Permissions.View, 'getSelectionSortOrder') security.declareProtected(ERP5Permissions.View, 'getSelectionSortOrder')
...@@ -385,7 +436,7 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -385,7 +436,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
# ListBox related methods # ListBox related methods
security.declareProtected(ERP5Permissions.View, 'nextPage') security.declareProtected(ERP5Permissions.View, 'nextPage')
def nextPage(self, REQUEST=None): def nextPage(self, listbox_uid, uids=[], REQUEST=None):
""" """
Access the next page of a list Access the next page of a list
""" """
...@@ -399,16 +450,11 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -399,16 +450,11 @@ class SelectionTool( UniqueObject, SimpleItem ):
params['list_start'] = int(start) + int(lines) params['list_start'] = int(start) + int(lines)
selection.edit(params= params) selection.edit(params= params)
# We must cancel the reset in this case self.uncheckAll(selection_name, listbox_uid)
# since we need to change page return self.checkAll(selection_name, uids, REQUEST=REQUEST)
# we replace the keyword reset by noreset
# This must be documented in the keywords
referer = request['HTTP_REFERER']
referer = referer.replace('reset=', 'noreset=')
return request.RESPONSE.redirect(referer)
security.declareProtected(ERP5Permissions.View, 'previousPage') security.declareProtected(ERP5Permissions.View, 'previousPage')
def previousPage(self, REQUEST): def previousPage(self, listbox_uid, uids=[], REQUEST=None):
""" """
Access the previous page of a list Access the previous page of a list
""" """
...@@ -422,16 +468,11 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -422,16 +468,11 @@ class SelectionTool( UniqueObject, SimpleItem ):
params['list_start'] = max(int(start) - int(lines), 0) params['list_start'] = max(int(start) - int(lines), 0)
selection.edit(params= selection.selection_params) selection.edit(params= selection.selection_params)
# We must cancel the reset in this case self.uncheckAll(selection_name, listbox_uid)
# since we need to change page return self.checkAll(selection_name, uids, REQUEST=REQUEST)
# we replace the keyword reset by noreset
# This must be documented in the keywords
referer = request['HTTP_REFERER']
referer = referer.replace('reset=', 'noreset=')
return request.RESPONSE.redirect(referer)
security.declareProtected(ERP5Permissions.View, 'setPage') security.declareProtected(ERP5Permissions.View, 'setPage')
def setPage(self, REQUEST): def setPage(self, listbox_uid, uids=[], REQUEST=None):
""" """
Access the previous page of a list Access the previous page of a list
""" """
...@@ -447,14 +488,8 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -447,14 +488,8 @@ class SelectionTool( UniqueObject, SimpleItem ):
params['list_start'] = start params['list_start'] = start
selection.edit(params= selection.selection_params) selection.edit(params= selection.selection_params)
# We must cancel the reset in this case self.uncheckAll(selection_name, listbox_uid)
# since we need to change page return self.checkAll(selection_name, uids, REQUEST=REQUEST)
# we replace the keyword reset by noreset
# This must be documented in the keywords
referer = request['HTTP_REFERER']
referer = referer.replace('reset=', 'noreset=')
return request.RESPONSE.redirect(referer)
security.declareProtected(ERP5Permissions.View, 'setDomainRoot') security.declareProtected(ERP5Permissions.View, 'setDomainRoot')
def setDomainRoot(self, REQUEST): def setDomainRoot(self, REQUEST):
...@@ -574,6 +609,7 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -574,6 +609,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
referer = request['HTTP_REFERER'] referer = request['HTTP_REFERER']
referer = referer.replace('reset=', 'noreset=') referer = referer.replace('reset=', 'noreset=')
referer = referer.replace('reset:int=', 'noreset:int=')
return request.RESPONSE.redirect(referer) return request.RESPONSE.redirect(referer)
......
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