Commit 9b51db3b authored by Jérome Perrin's avatar Jérome Perrin

Extends push and pop mecanism to both ReportSection selection and form
listbox's selection, as the listbox will edit the form's selection.
This is only usefull if the selection used in a ReportSection is not the same as
the selection used by the ERP5Form for this ReportSection.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3052 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d615a978
...@@ -203,11 +203,8 @@ class ReportSection: ...@@ -203,11 +203,8 @@ class ReportSection:
self.listbox_display_mode = listbox_display_mode self.listbox_display_mode = listbox_display_mode
self.selection_columns = selection_columns self.selection_columns = selection_columns
self.selection_sort_order = selection_sort_order self.selection_sort_order = selection_sort_order
self.saved_selections = {}
#security.declarePublic('__getitem__')
#def __getitem__(self, column_id):
# return self.__dict__[column_id]
security.declarePublic('getTitle') security.declarePublic('getTitle')
def getTitle(self): def getTitle(self):
return self.title return self.title
...@@ -234,33 +231,41 @@ class ReportSection: ...@@ -234,33 +231,41 @@ class ReportSection:
_no_parameter_ = [] _no_parameter_ = []
security.declarePublic('pushRequest') security.declarePublic('pushReport')
def pushReport(self, context): def pushReport(self, context):
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_)
REQUEST.form[k] = v REQUEST.form[k] = v
if self.selection_name is not None:
portal_selections = context.portal_selections portal_selections = context.portal_selections
if self.listbox_display_mode is not None: # save report's selection and orignal form's selection, as ListBox will overwrite it
self.saved_display_mode = portal_selections.getListboxDisplayMode(self.selection_name, REQUEST=REQUEST) for selection_name in [self.selection_name, context[self.form_id].listbox.get_value('selection_name')] :
portal_selections.setListboxDisplayMode(REQUEST, self.listbox_display_mode, if selection_name is not None:
selection_name=self.selection_name) if not self.saved_selections.has_key(selection_name) :
if self.selection_params is not None: self.saved_selections[selection_name] = {}
self.saved_params = portal_selections.getSelectionParams(self.selection_name, REQUEST=REQUEST) if self.listbox_display_mode is not None:
portal_selections.setSelectionParamsFor(self.selection_name, self.saved_selections[selection_name]['display_mode'] = \
self.selection_params, REQUEST=REQUEST) portal_selections.getListboxDisplayMode(selection_name, REQUEST=REQUEST)
if self.selection_columns is not None: portal_selections.setListboxDisplayMode(REQUEST, self.listbox_display_mode,
self.saved_columns = portal_selections.getSelectionColumns(self.selection_name, REQUEST=REQUEST) selection_name=selection_name)
portal_selections.setSelectionColumns(self.selection_name, self.selection_columns, if self.selection_params is not None:
REQUEST=REQUEST) self.saved_selections[selection_name]['params'] = \
if self.selection_sort_order is not None: portal_selections.getSelectionParams(selection_name, REQUEST=REQUEST)
self.saved_sort_order = portal_selections.getSelectionSortOrder(self.selection_name, REQUEST=REQUEST) portal_selections.setSelectionParamsFor(selection_name,
portal_selections.setSelectionSortOrder(self.selection_name, self.selection_sort_order, self.selection_params, REQUEST=REQUEST)
REQUEST=REQUEST) if self.selection_columns is not None:
self.saved_selections[selection_name]['columns'] = \
portal_selections.getSelectionColumns(selection_name, REQUEST=REQUEST)
security.declarePublic('popRequest') portal_selections.setSelectionColumns(selection_name, self.selection_columns,
REQUEST=REQUEST)
if self.selection_sort_order is not None:
self.saved_selections[selection_name]['sort_order'] = \
portal_selections.getSelectionSortOrder(selection_name, REQUEST=REQUEST)
portal_selections.setSelectionSortOrder(selection_name, self.selection_sort_order,
REQUEST=REQUEST)
security.declarePublic('popReport')
def popReport(self, context): def popReport(self, context):
REQUEST = get_request() REQUEST = get_request()
for k,v in self.param_dict.items(): for k,v in self.param_dict.items():
...@@ -268,20 +273,29 @@ class ReportSection: ...@@ -268,20 +273,29 @@ class ReportSection:
del REQUEST.form[k] del REQUEST.form[k]
else: else:
REQUEST.form[k] = self.saved_request[k] REQUEST.form[k] = self.saved_request[k]
if self.selection_name is not None:
portal_selections = context.portal_selections # restore report then form selection
if self.listbox_display_mode is not None: portal_selections = context.portal_selections
portal_selections.setListboxDisplayMode(REQUEST, self.saved_display_mode, for selection_name in [ context[self.form_id].listbox.get_value('selection_name'), self.selection_name] :
selection_name=self.selection_name) if selection_name is not None:
if self.param_dict is not None: if self.listbox_display_mode is not None:
portal_selections.setSelectionParamsFor(self.selection_name, portal_selections.setListboxDisplayMode(REQUEST,
self.saved_params, REQUEST=REQUEST) self.saved_selections[selection_name]['display_mode'],
if self.selection_columns is not None: selection_name=selection_name)
portal_selections.setSelectionColumns(self.selection_name, self.saved_columns, if self.selection_params is not None:
REQUEST=REQUEST) portal_selections.setSelectionParamsFor(selection_name,
if self.selection_sort_order is not None: self.saved_selections[selection_name]['params'],
portal_selections.setSelectionSortOrder(self.selection_name, self.saved_sort_order, REQUEST=REQUEST)
REQUEST=REQUEST) if self.selection_columns is not None:
portal_selections.setSelectionColumns(selection_name,
self.saved_selections[selection_name]['columns'],
REQUEST=REQUEST)
if self.selection_sort_order is not None:
portal_selections.setSelectionSortOrder(selection_name,
self.saved_selections[selection_name]['sort_order'],
REQUEST=REQUEST)
InitializeClass(ReportSection) InitializeClass(ReportSection)
allow_class(ReportSection) allow_class(ReportSection)
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