Commit cd1fe297 authored by Vincent Pelletier's avatar Vincent Pelletier

Add an optional parameter to push and pop methods. This allow generation of...

Add an optional parameter to push and pop methods. This allow generation of the right selection name when a listbox in a report mode is to be rendered with a prefix. As the renderer is not instanciated yet, it's not possible to just use it to retrieve the prefix.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22002 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a999c9f5
...@@ -266,7 +266,7 @@ class ReportSection: ...@@ -266,7 +266,7 @@ class ReportSection:
_no_parameter_ = [] _no_parameter_ = []
security.declarePublic('pushReport') security.declarePublic('pushReport')
def pushReport(self, context): def pushReport(self, context, field_prefix=None):
REQUEST = get_request() REQUEST = get_request()
for k,v in self.param_dict.items(): for k,v in self.param_dict.items():
self.saved_request[k] = REQUEST.form.get(k, self._no_parameter_) self.saved_request[k] = REQUEST.form.get(k, self._no_parameter_)
...@@ -275,8 +275,10 @@ class ReportSection: ...@@ -275,8 +275,10 @@ class ReportSection:
portal_selections = context.portal_selections portal_selections = context.portal_selections
selection_list = [self.selection_name] selection_list = [self.selection_name]
if self.getFormId() and hasattr(context[self.getFormId()], 'listbox') : if self.getFormId() and hasattr(context[self.getFormId()], 'listbox') :
selection_list += [ selection_name = context[self.getFormId()].listbox.get_value('selection_name')
context[self.getFormId()].listbox.get_value('selection_name') ] if field_prefix is not None:
selection_name = '%s_%s' % (field_prefix, selection_name)
selection_list += [selection_name]
# save report's selection and orignal form's selection, # save report's selection and orignal form's selection,
#as ListBox will overwrite it #as ListBox will overwrite it
for selection_name in selection_list : for selection_name in selection_list :
...@@ -305,11 +307,12 @@ class ReportSection: ...@@ -305,11 +307,12 @@ class ReportSection:
REQUEST, self.listbox_display_mode, REQUEST, self.listbox_display_mode,
selection_name=selection_name) selection_name=selection_name)
if self.selection_params is not None: if self.selection_params is not None:
self.saved_selections[selection_name]['params'] = \ params = portal_selections.getSelectionParams(
portal_selections.getSelectionParams(
selection_name, REQUEST=REQUEST) selection_name, REQUEST=REQUEST)
self.saved_selections[selection_name]['params'] = params.copy()
params.update(self.selection_params)
portal_selections.setSelectionParamsFor(selection_name, portal_selections.setSelectionParamsFor(selection_name,
self.selection_params, REQUEST=REQUEST) params, REQUEST=REQUEST)
if self.selection_columns is not None: if self.selection_columns is not None:
self.saved_selections[selection_name]['columns'] = \ self.saved_selections[selection_name]['columns'] = \
portal_selections.getSelectionColumns(selection_name, portal_selections.getSelectionColumns(selection_name,
...@@ -327,7 +330,7 @@ class ReportSection: ...@@ -327,7 +330,7 @@ class ReportSection:
REQUEST.form = {} REQUEST.form = {}
security.declarePublic('popReport') security.declarePublic('popReport')
def popReport(self, context): def popReport(self, context, field_prefix=None):
REQUEST = get_request() REQUEST = get_request()
for k,v in self.param_dict.items(): for k,v in self.param_dict.items():
if self.saved_request[k] is self._no_parameter_: if self.saved_request[k] is self._no_parameter_:
...@@ -338,8 +341,12 @@ class ReportSection: ...@@ -338,8 +341,12 @@ class ReportSection:
portal_selections = context.portal_selections portal_selections = context.portal_selections
selection_list = [] selection_list = []
if self.getFormId() and hasattr(context[self.getFormId()], 'listbox') : if self.getFormId() and hasattr(context[self.getFormId()], 'listbox') :
selection_list += [ selection_name = context[self.getFormId()].listbox.get_value('selection_name')
context[self.getFormId()].listbox.get_value('selection_name') ] if field_prefix is not None:
# Return before cleanup, because there is no interest in cleaning up
# what won't be shared.
return
selection_list += [selection_name]
selection_list += [self.selection_name] selection_list += [self.selection_name]
# restore report then form selection # restore report then form selection
for selection_name in selection_list: for selection_name in selection_list:
......
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