[web/view/treeview] add a 'selected' class on <li> if the entity's url is the currently displayed url
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 16 Apr 2015 18:59:12 +0200
changeset 10299 4f3b6dad5084
parent 10298 e52efb73f9ee
child 10300 bfe33b5710d1
[web/view/treeview] add a 'selected' class on <li> if the entity's url is the currently displayed url An alternative would be to refactor the corresponding view so that controlling css classes wouldn't require overriding a 5O-lines method. Notice by default there is no associated class in the CSS so there is no rendering difference unless one explicitly add rule in his CSS file.
web/views/treeview.py
--- a/web/views/treeview.py	Thu Apr 02 13:54:00 2015 +0200
+++ b/web/views/treeview.py	Thu Apr 16 18:59:12 2015 +0200
@@ -244,6 +244,8 @@
         entity = self.cw_rset.get_entity(row, col)
         itree = entity.cw_adapt_to('ITree')
         liclasses = []
+        if self._cw.url(includeparams=False) == entity.absolute_url():
+            liclasses.append(u'selected')
         is_open = self.open_state(entity.eid, treeid)
         is_leaf = itree is None or itree.is_leaf()
         if is_leaf: