Commit 5d149e64 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Added getCategoryChildIndentedTitleItemList and getIndentedTitle.

It allows to display hierarchical data in much less horizontal space than
getCategoryChildLogicalPathItemList.


example :

getCategoryChildLogicalPathItemList :
Foooooooo
Foooooooo/Baaaaaaaar
Foooooooo/Baaaaaaaar/Baaaaaaaaz
Foooooooo/Baaaaaaaar/Baaaaaaaaz/Quuuuuuuux

getCategoryChildIndentedTitleItemList :
Foooooooo
  Baaaaaaaar
    Baaaaaaaaz
      Quuuuuuuux


Possible improvements :
for now, I just add some " " before the title, but it breaks the mozilla
  "type and search" feature. Maybe it is possible to use CSS to get the same
  visual result ...


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4253 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 30447ae1
...@@ -170,6 +170,31 @@ class Category(Folder): ...@@ -170,6 +170,31 @@ class Category(Folder):
logical_title_list.append(logical_title) logical_title_list.append(logical_title)
return '/'.join(logical_title_list) return '/'.join(logical_title_list)
security.declareProtected(Permissions.AccessContentsInformation,
'getIndentedTitle')
def getIndentedTitle(self):
"""
Returns title or id, indented from base_category.
"""
path_len = 0
base = self.getBaseCategory()
current = self
while not current is base :
path_len += 1
current = aq_parent(current)
# it s better for the user to display something than only ''...
logical_title_list = []
if path_len >= 2:
logical_title_list.append(' ' * 4 * (path_len - 1))
logical_title = self.getTitle()
if logical_title in [None, '']:
logical_title = object.getId()
logical_title_list.append(logical_title)
return ''.join(logical_title_list)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildValueList') 'getCategoryChildValueList')
def getCategoryChildValueList(self, recursive=1, include_if_child=1, sort_on=None, sort_order=None, **kw): def getCategoryChildValueList(self, recursive=1, include_if_child=1, sort_on=None, sort_order=None, **kw):
...@@ -253,6 +278,16 @@ class Category(Folder): ...@@ -253,6 +278,16 @@ class Category(Folder):
""" """
return self.getCategoryChildItemList(recursive = recursive, display_id='logical_path', base=base, **kw) return self.getCategoryChildItemList(recursive = recursive, display_id='logical_path', base=base, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildIndentedTitleItemList')
def getCategoryChildIndentedTitleItemList(self, recursive=1, base=0, **kw):
"""
Returns a list of tuples by parsing recursively all categories in a
given list of base categories. Uses getIndentedTitle as default method
"""
return self.getCategoryChildItemList(recursive = recursive,
display_id='indented_title', base=base, **kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildIdItemList') 'getCategoryChildIdItemList')
def getCategoryChildIdItemList(self, recursive=1, base=0, **kw): def getCategoryChildIdItemList(self, recursive=1, base=0, **kw):
......
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