web/views/treeview.py
branchtls-sprint
changeset 688 cddfbdee0eb3
parent 472 958805c342b6
child 692 800592b8d39b
equal deleted inserted replaced
687:c23315c11185 688:cddfbdee0eb3
     6 
     6 
     7 from cubicweb.web.views.baseviews import OneLineView
     7 from cubicweb.web.views.baseviews import OneLineView
     8 
     8 
     9 class TreeView(EntityView):
     9 class TreeView(EntityView):
    10     id = 'treeview'
    10     id = 'treeview'
    11     accepts = ('Any',)
       
    12     itemvid = 'treeitemview'
    11     itemvid = 'treeitemview'
    13     css_classes = 'treeview widget'
    12     css_classes = 'treeview widget'
    14     title = _('tree view')
    13     title = _('tree view')
    15     
    14     
    16     def call(self, subvid=None):
    15     def call(self, subvid=None):
    65 
    64 
    66 class DefaultTreeViewItemView(EntityView):
    65 class DefaultTreeViewItemView(EntityView):
    67     """default treeitem view for entities which don't implement ITree
    66     """default treeitem view for entities which don't implement ITree
    68     """
    67     """
    69     id = 'treeitemview'
    68     id = 'treeitemview'
    70     accepts = ('Any',)
       
    71     
    69     
    72     def cell_call(self, row, col, vid='oneline', parentvid='treeview'):
    70     def cell_call(self, row, col, vid='oneline', parentvid='treeview'):
    73         entity = self.entity(row, col)
    71         entity = self.entity(row, col)
    74         itemview = self.view(vid, self.rset, row=row, col=col)
    72         itemview = self.view(vid, self.rset, row=row, col=col)
    75         if row == len(self.rset) - 1:
    73         if row == len(self.rset) - 1:
    82     """specific treeitem view for entities which implement ITree
    80     """specific treeitem view for entities which implement ITree
    83     
    81     
    84     (each item should be exandable if it's not a tree leaf)
    82     (each item should be exandable if it's not a tree leaf)
    85     """
    83     """
    86     id = 'treeitemview'
    84     id = 'treeitemview'
    87     # XXX append yes to make sure we get an higher score than
    85     __selectors__ = implements(ITree)
    88     #     the default treeitem view
       
    89     __selectors__ = (implement_interface, yes)
       
    90     accepts_interfaces = (ITree,)
       
    91     
    86     
    92     def cell_call(self, row, col, vid='oneline', parentvid='treeview'):
    87     def cell_call(self, row, col, vid='oneline', parentvid='treeview'):
    93         entity = self.entity(row, col)
    88         entity = self.entity(row, col)
    94         cssclasses = []
    89         cssclasses = []
    95         is_leaf = False
    90         is_leaf = False