# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1233156541 -3600 # Node ID 14befdd50126546a16b45ae72bc8dc81444c3d40 # Parent 68d4211518c50567078b662c2b0488ec171e044c# Parent ad3de58a8e308d501797e5e66caf866e5888195b merge diff -r ad3de58a8e30 -r 14befdd50126 common/view.py --- a/common/view.py Wed Jan 28 15:52:45 2009 +0100 +++ b/common/view.py Wed Jan 28 16:29:01 2009 +0100 @@ -2,7 +2,7 @@ :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" diff -r ad3de58a8e30 -r 14befdd50126 web/views/tableview.py --- a/web/views/tableview.py Wed Jan 28 15:52:45 2009 +0100 +++ b/web/views/tableview.py Wed Jan 28 16:29:01 2009 +0100 @@ -24,11 +24,35 @@ id = 'table' title = _('table') finalview = 'final' + + def form_filter(self, divid, displaycols, displayactions, displayfilter, + hidden=True): + rqlst = self.rset.syntax_tree() + # union not yet supported + if len(rqlst.children) != 1: + return () + rqlst.save_state() + mainvar, baserql = prepare_facets_rqlst(rqlst, self.rset.args) + facets = [facet for facet in self.vreg.possible_vobjects( + 'facets', self.req, self.rset, context='tablefilter', + filtered_variable=mainvar) + if facet.get_widget()] + rqlst.recover() + if facets: + self._generate_form(divid, baserql, facets, hidden, + vidargs={'displaycols': displaycols, + 'displayactions': displayactions, + 'displayfilter': displayfilter}) + return self.show_hide_actions(divid, not hidden) + return () - def generate_form(self, divid, baserql, facets, hidden=True, vidargs={}): + def _generate_form(self, divid, baserql, facets, hidden=True, vidargs={}): """display a form to filter table's content. This should only occurs when a context eid is given """ + wdgs = [facet.get_widget() for facet in facets] + if not wdgs: + return self.req.add_js( ('cubicweb.ajax.js', 'cubicweb.formfilter.js')) # drop False / None values from vidargs vidargs = dict((k, v) for k, v in vidargs.iteritems() if v) @@ -40,11 +64,9 @@ self.w(u'
') - wdg.render(w=self.w) - self.w(u' | \n') + self.w(u'') + facet.get_widget().render(w=self.w) + self.w(u' | \n') self.w(u'