[facets] fix context passing + a note for later
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 21 Oct 2011 17:42:56 +0200
changeset 8000 9a73d5e762b0
parent 7999 ea012d90825d
child 8001 35d673b05e84
[facets] fix context passing + a note for later
web/data/cubicweb.js
web/data/jquery.tablesorter.js
web/views/facets.py
web/views/tableview.py
--- a/web/data/cubicweb.js	Fri Oct 21 17:14:05 2011 +0200
+++ b/web/data/cubicweb.js	Fri Oct 21 17:42:56 2011 +0200
@@ -85,7 +85,7 @@
 
     sortValueExtraction: function (node) {
 	var sortvalue = jQuery(node).attr('cubicweb:sortvalue');
-	if (sortvalue === undefined) {
+ 	if (sortvalue === undefined) {
 	    return '';
 	}
 	return sortvalue;
--- a/web/data/jquery.tablesorter.js	Fri Oct 21 17:14:05 2011 +0200
+++ b/web/data/jquery.tablesorter.js	Fri Oct 21 17:42:56 2011 +0200
@@ -684,7 +684,7 @@
             function getCachedSortType(parsers, i) {
                 return parsers[i].type;
             }; /* public methods */
-            this.construct = function (settings) {
+            this.construct = function (settings) { cw.log(settings);
                 return this.each(function () {
                     // if no thead or tbody quit.
                     if (!this.tHead || !this.tBodies) return;
--- a/web/views/facets.py	Fri Oct 21 17:14:05 2011 +0200
+++ b/web/views/facets.py	Fri Oct 21 17:42:56 2011 +0200
@@ -160,6 +160,10 @@
         :param hiddens:  other hidden parametters to include in the forms.
         :type hiddens:   dict from extra keyword argument
         """
+        # XXX Facet.context property hijacks an otherwise well-behaved
+        #     vocabulary with its own notions
+        #     Hence we whack here to avoid a clash
+        kwargs.pop('context', None)
         baserql, wdgs = facets(self._cw, rset, context=self.__regid__,
                                mainvar=mainvar, **kwargs)
         assert wdgs
--- a/web/views/tableview.py	Fri Oct 21 17:14:05 2011 +0200
+++ b/web/views/tableview.py	Fri Oct 21 17:42:56 2011 +0200
@@ -147,9 +147,9 @@
     def _setup_tablesorter(self, divid):
         self._cw.add_css('cubicweb.tablesorter.css')
         self._cw.add_js('jquery.tablesorter.js')
-        self._cw.add_onload('''$(document).ready(function() {
-    $("#%s table").tablesorter(%s);
-});''' % (divid, js_dumps(self.tablesorter_settings)))
+        print '$("#%s table").tablesorter(%s);' % (divid, js_dumps(self.tablesorter_settings))
+        self._cw.add_onload('$("#%s table").tablesorter(%s);cw.log("done");' %
+                            (divid, js_dumps(self.tablesorter_settings)))
 
     def __init__(self, req, view, **kwargs):
         super(TableLayout, self).__init__(req, **kwargs)
@@ -177,6 +177,7 @@
             self._cw.add_css(self.needs_css)
         if self.needs_js:
             self._cw.add_js(self.needs_js)
+        print self.enable_sorting
         if self.enable_sorting:
             self._setup_tablesorter(self.view.domid)
         # Notice facets form must be rendered **outside** the main div as it