[table view] properly handle show/hide filter actions so we get proper action displayed even when recalled from pagination
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 04 Nov 2011 13:03:52 +0100
changeset 8055 368d8902e597
parent 8054 11b6589352b6
child 8056 8909800a8c51
[table view] properly handle show/hide filter actions so we get proper action displayed even when recalled from pagination
web/views/tableview.py
--- a/web/views/tableview.py	Fri Nov 04 13:03:35 2011 +0100
+++ b/web/views/tableview.py	Fri Nov 04 13:03:52 2011 +0100
@@ -292,16 +292,18 @@
         showhide = u';'.join(toggle_action('%s%s' % (divid, what))[11:]
                              for what in ('Form', 'Show', 'Hide', 'Actions'))
         showhide = 'javascript:' + showhide
+        self._cw.add_onload(u'''\
+$(document).ready(function() {
+  if ($('#%(id)sForm[class=\"hidden\"]').length) {
+    $('#%(id)sHide').attr('class', 'hidden');
+  } else {
+    $('#%(id)sShow').attr('class', 'hidden');
+  }
+});''' % {'id': divid})
         showlabel = self._cw._('show filter form')
         hidelabel = self._cw._('hide filter form')
-        if currentlydisplayed:
-            c1, d1 = 'hidden', '%sShow' % divid
-            c2, d2 = None, '%sHide' % divid
-        else:
-            c1, d1 = None, '%sShow' % divid
-            c2, d2 = 'hidden', '%sHide' % divid
-        return [component.Link(showhide, showlabel, klass=c1, id=d1),
-                component.Link(showhide, hidelabel, klass=c2, id=d2)]
+        return [component.Link(showhide, showlabel, id='%sShow' % divid),
+                component.Link(showhide, hidelabel, id='%sHide' % divid)]
 
 
 class AbstractColumnRenderer(object):