Commit dbc494db authored by Ivan Tyagov's avatar Ivan Tyagov

Use 'More Columns' to provide columns definitions for different listbox styles.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37996 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3b216ea8
...@@ -893,6 +893,7 @@ class ListBoxRenderer: ...@@ -893,6 +893,7 @@ class ListBoxRenderer:
def getAllColumnList(self): def getAllColumnList(self):
"""Return the all columns. Make sure that the titles are in unicode. """Return the all columns. Make sure that the titles are in unicode.
Make sure there is no duplicates.
""" """
all_column_list = list(self.getColumnList()) all_column_list = list(self.getColumnList())
all_column_id_set = set([c[0] for c in all_column_list]) all_column_id_set = set([c[0] for c in all_column_list])
...@@ -903,6 +904,13 @@ class ListBoxRenderer: ...@@ -903,6 +904,13 @@ class ListBoxRenderer:
getAllColumnList = lazyMethod(getAllColumnList) getAllColumnList = lazyMethod(getAllColumnList)
def getRawAllColumnList(self):
""" Return the raw content of 'all_columns' listbox attribute
"""
return self.field.get_value('all_columns')
getRawAllColumnList = lazyMethod(getRawAllColumnList)
def getStatColumnList(self): def getStatColumnList(self):
"""Return the stat columns. Fall back to all the columns if empty. """Return the stat columns. Fall back to all the columns if empty.
""" """
...@@ -1115,27 +1123,44 @@ class ListBoxRenderer: ...@@ -1115,27 +1123,44 @@ class ListBoxRenderer:
""" """
return self.displayed_column_id_list return self.displayed_column_id_list
def getListboxDisplayStyle(self):
"""Return the current listbox display style.
"""
request = self.request
selection = self.getSelection()
return request.get('list_style', \
selection.getParams().get('list_style', self.getDefaultDisplayStyle()))
def getSelectedColumnList(self): def getSelectedColumnList(self):
"""Return the list of selected columns. """Return the list of selected columns.
""" """
column_list = [] column_list = []
default_listbox_display_style = self.getDefaultDisplayStyle()
#Parameter allow to select column temporary listbox_display_style = self.getListboxDisplayStyle()
if self.getDisplayedColumnIdList() != None: dynamic_column_list_override = (self.getDisplayedColumnIdList() != None)
list_style_column_change_required = (default_listbox_display_style != listbox_display_style)
if dynamic_column_list_override:
# dynamically setting columns is supported
available_column = self.getAllColumnList() available_column = self.getAllColumnList()
#Create a dict to make a easy search #Create a dict to make a easy search
available_column_dict = dict() available_column_dict = dict()
for id,title in available_column: for id,title in available_column:
available_column_dict[id] = (id,title) available_column_dict[id] = (id,title)
#We check columns are present # We check columns are present
for id in self.getDisplayedColumnIdList(): for id in self.getDisplayedColumnIdList():
if available_column_dict.has_key(id): if available_column_dict.has_key(id):
column_list.append(available_column_dict[id]) column_list.append(available_column_dict[id])
else: else:
raise AttributeError, "Column %s is not avaible" % id raise AttributeError, "Column %s is not avaible" % id
elif list_style_column_change_required and not dynamic_column_list_override:
# no dynamically setting of columns happens , still we have different than default
# listbox list style so try to get columns from 'More columns'
list_style_prefix = "%s_" %listbox_display_style
for column in self.getRawAllColumnList():
if column[1].startswith(list_style_prefix):
column_list.append((column[0],column[1].replace(list_style_prefix, '',)))
else: else:
column_list = self.getSelectionTool().getSelectionColumns(self.getSelectionName(), column_list = self.getSelectionTool().getSelectionColumns(self.getSelectionName(),
columns = self.getColumnList(), columns = self.getColumnList(),
......
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