Commit 914e9c49 authored by Romain Courteaud's avatar Romain Courteaud

Add setDisplayedColumnIdList to allow the page template to display only some

specific columns.
Work by FX Algrain.

TODO: a functional test is needed


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35359 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f4cae2a6
...@@ -477,6 +477,7 @@ class ListBoxRenderer: ...@@ -477,6 +477,7 @@ class ListBoxRenderer:
self.field = field self.field = field
self.request = REQUEST self.request = REQUEST
self.render_prefix = render_prefix self.render_prefix = render_prefix
self.displayed_column_id_list = None
def getPhysicalPath(self): def getPhysicalPath(self):
""" """
...@@ -1031,12 +1032,45 @@ class ListBoxRenderer: ...@@ -1031,12 +1032,45 @@ class ListBoxRenderer:
getCheckedUidSet = lazyMethod(getCheckedUidSet) getCheckedUidSet = lazyMethod(getCheckedUidSet)
def setDisplayedColumnIdList(self, displayed_column_id_list):
"""Set the column to be displayed.
Impact the result of getSelectedColumnList.
Parameter :
displayed_column_id_list : List of id. Exemple : ('id', 'title')
"""
self.displayed_column_id_list = displayed_column_id_list
def getDisplayedColumnIdList(self):
"""Return the list of displayed column id
"""
return self.displayed_column_id_list
def getSelectedColumnList(self): def getSelectedColumnList(self):
"""Return the list of selected columns. """Return the list of selected columns.
""" """
return self.getSelectionTool().getSelectionColumns(self.getSelectionName(), column_list = []
#Parameter allow to select column temporary
if self.getDisplayedColumnIdList() != None:
available_column = self.getAllColumnList()
#Create a dict to make a easy search
available_column_dict = dict()
for id,title in available_column:
available_column_dict[id] = (id,title)
#We check columns are present
for id in self.getDisplayedColumnIdList():
if available_column_dict.has_key(id):
column_list.append(available_column_dict[id])
else:
raise AttributeError, "Column %s is not avaible" % id
else:
column_list = self.getSelectionTool().getSelectionColumns(self.getSelectionName(),
columns = self.getColumnList(), columns = self.getColumnList(),
REQUEST = self.request) REQUEST = self.request)
return column_list
getSelectedColumnList = lazyMethod(getSelectedColumnList) getSelectedColumnList = lazyMethod(getSelectedColumnList)
......
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