From 914e9c49a06b9ca9d90251c713530ec639cf1076 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Fri, 14 May 2010 14:58:02 +0000 Subject: [PATCH] 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 --- product/ERP5Form/ListBox.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py index 0b3d70bd95..a5204a2ee5 100644 --- a/product/ERP5Form/ListBox.py +++ b/product/ERP5Form/ListBox.py @@ -477,6 +477,7 @@ class ListBoxRenderer: self.field = field self.request = REQUEST self.render_prefix = render_prefix + self.displayed_column_id_list = None def getPhysicalPath(self): """ @@ -1030,13 +1031,46 @@ class ListBoxRenderer: return set(self.getCheckedUidList()) 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): """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(), REQUEST = self.request) + return column_list getSelectedColumnList = lazyMethod(getSelectedColumnList) -- 2.30.9