quick hack to fix treeview double toggling bug
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 08 Dec 2008 17:48:20 +0100
changeset 187 cae87ca76f02
parent 186 5e550c6e554c
child 193 cd9cc0153835
quick hack to fix treeview double toggling bug
web/views/treeview.py
--- a/web/views/treeview.py	Mon Dec 08 14:47:07 2008 +0100
+++ b/web/views/treeview.py	Mon Dec 08 17:48:20 2008 +0100
@@ -22,8 +22,14 @@
         css_classes = 'treeview widget'
         if self.fstree:
             css_classes += ' filetree'
-        self.w(u'<ul class="%s" cubicweb:loadtype="auto" cubicweb:wdgtype="TreeView">'
-               % css_classes)
+        # XXX noautoload is a quick hack to avoid treeview to be rebuilt
+        #     after a json query and avoid double toggling bugs.
+        #     Need to find a way to do that cleanly.
+        if 'noautoload' in self.req.form:
+            self.w(u'<ul class="%s" cubicweb:wdgtype="TreeView">' % css_classes)
+        else:
+            self.w(u'<ul class="%s" cubicweb:loadtype="auto" cubicweb:wdgtype="TreeView">'
+                   % css_classes)
         for rowidx in xrange(len(self.rset)):
             self.wview(self.itemvid, self.rset, row=rowidx, col=0,
                        vid=subvid, parentvid=self.id)
@@ -97,7 +103,8 @@
             rql = entity.children_rql() % {'x': entity.eid}
             url = html_escape(self.build_url('json', rql=rql, vid=parentvid,
                                              pageid=self.req.pageid,
-                                             subvid=vid))
+                                             subvid=vid,
+                                             noautoload=True))
             cssclasses.append('expandable')
             divclasses = ['hitarea expandable-hitarea']
             if is_leaf :