[facets] on the way to vidargs removal
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 14 Oct 2011 08:49:58 +0200
changeset 7949 ce64860b3cdc
parent 7946 72d60e921341
child 7950 99ae8c883ad3
[facets] on the way to vidargs removal our roving on the table view, which leads to introduction of this feature, proved it was not the way to go.
web/data/cubicweb.facets.js
web/views/facets.py
--- a/web/data/cubicweb.facets.js	Tue Oct 11 18:16:52 2011 +0200
+++ b/web/data/cubicweb.facets.js	Fri Oct 14 08:49:58 2011 +0200
@@ -49,6 +49,7 @@
 }
 
 
+// XXX deprecate vidargs once TableView is gone
 function buildRQL(divid, vid, paginate, vidargs) {
     jQuery(CubicWeb).trigger('facets-content-loading', [divid, vid, paginate, vidargs]);
     var $form = $('#' + divid + 'Form');
@@ -77,7 +78,7 @@
         copyParam(zipped, extraparams, 'vid');
         extraparams['divid'] = divid;
         copyParam(zipped, extraparams, 'divid');
-        copyParam(zipped, extraparams, 'subvid');
+        copyParam(zipped, extraparams, 'subvid'); // XXX deprecate once TableView is gone
         copyParam(zipped, extraparams, 'fromformfilter');
         // paginate used to know if the filter box is acting, in which case we
         // want to reload action box to match current selection (we don't want
--- a/web/views/facets.py	Tue Oct 11 18:16:52 2011 +0200
+++ b/web/views/facets.py	Fri Oct 14 08:49:58 2011 +0200
@@ -128,7 +128,7 @@
     needs_css = ['cubicweb.facets.css']
     roundcorners = True
 
-    def generate_form(self, w, rset, divid, vid, vidargs,
+    def generate_form(self, w, rset, divid, vid, vidargs=None,
                       paginate=False, cssclass='', **hiddens):
         """display a form to filter some view's content
 
@@ -161,7 +161,11 @@
         if self.roundcorners:
             self._cw.html_headers.add_onload(
                 'jQuery(".facet").corner("tl br 10px");')
-        # drop False / None values from vidargs
+        if vidargs is not None:
+            warn("[3.14] vidargs is deprecated. Maybe you're using some TableView?",
+                 DeprecationWarning, stacklevel=2)
+        else:
+            vidargs = {}
         vidargs = dict((k, v) for k, v in vidargs.iteritems() if v)
         facetargs = xml_escape(json_dumps([divid, vid, paginate, vidargs]))
         w(u'<form id="%sForm" class="%s" method="post" action="" '
@@ -213,8 +217,7 @@
         for param in ('subvid', 'vtitle'):
             if param in req.form:
                 hiddens[param] = req.form[param]
-        self.generate_form(w, rset, divid, vid, self.vidargs(),
-                           paginate=paginate, **hiddens)
+        self.generate_form(w, rset, divid, vid, paginate=paginate, **hiddens)
 
     def _get_context(self):
         view = self.cw_extra_kwargs.get('view')
@@ -244,12 +247,6 @@
                 req._('bookmark this search'))
         return self.bk_linkbox_template % bk_link
 
-    def vidargs(self):
-        """this method returns the list of extra arguments that should be used
-        by the filter or the view using it
-        """
-        return {}
-
 
 from cubicweb.view import AnyRsetView
 
@@ -258,11 +255,9 @@
     __select__ = has_facets()
     compact_layout_threshold = 5
 
-    def call(self, vid, divid, vidargs, cssclass=''):
-        self.generate_form(self.w, self.cw_rset, divid, vid, vidargs,
-                           cssclass=cssclass, fromformfilter='1',
-                           # divid=divid XXX
-                           )
+    def call(self, vid, divid, vidargs=None, cssclass=''):
+        self.generate_form(self.w, self.cw_rset, divid, vid, vidargs=vidargs,
+                           cssclass=cssclass, fromformfilter='1')
 
     def _simple_horizontal_layout(self, w, wdgs):
         w(u'<table class="filter">\n')