additional datatables_options can be passed to hazelnut from the view for any fine...
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 27 Mar 2013 11:34:17 +0000 (12:34 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 27 Mar 2013 11:34:17 +0000 (12:34 +0100)
we use this to remove sorting arrows on the checkbox column for now

plugins/hazelnut/hazelnut.css
plugins/hazelnut/hazelnut.js
plugins/hazelnut/hazelnut.py
trash/sliceview.py

index 2439bd1..a72e6a0 100644 (file)
@@ -14,7 +14,7 @@ div.Hazelnut table.dataTable th {
     text-align: left;
     padding: 8px 12px 4px 20px;
     vertical-align:middle;
-    background: #CAE8EA url(../img/tablesort-header.jpg) no-repeat;
+/*    background: #CAE8EA url(../img/tablesort-header.jpg) no-repeat; */
 }
 
 div.Hazelnut table.dataTable td, div.Hazelnut table.dataTable textarea, div.Hazelnut table.dataTable input [type="text"] {
@@ -35,9 +35,16 @@ div.Hazelnut div.dataTables_info {
     font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
 }
 
+/* one could think or using repeat-x here but that's not working because of the arrows
+ * we might need to make these wider some day */
 div.Hazelnut table.dataTable thead .sorting { background: url('../img/tablesort-header-sortable.png') no-repeat; }
 div.Hazelnut table.dataTable thead .sorting_asc { background: url('../img/tablesort-header-up.png') no-repeat; }
 div.Hazelnut table.dataTable thead .sorting_desc { background: url('../img/tablesort-header-down.png') no-repeat; }
-/* former set did not have that exact equivalent - using an approximation for now */
-div.Hazelnut table.dataTable thead .sorting_asc_disabled { background: url('../img/tablesort-header-sortable.png') no-repeat; }
-div.Hazelnut table.dataTable thead .sorting_desc_disabled { background: url('../img/tablesort-header-sortable.png') no-repeat; }
+/* this icons set does not have that exact equivalent - using an approximation for now */
+div.Hazelnut table.dataTable thead .sorting_asc_disabled { background: url('../img/tablesort-header.png') no-repeat; }
+div.Hazelnut table.dataTable thead .sorting_desc_disabled { background: url('../img/tablesort-header.png') no-repeat; }
+
+/* the footers are not active */
+div.Hazelnut table.dataTable tfoot { background: url('../img/tablesort-header.png') no-repeat; }
+/* and when sorting is turned off it's useful to set this on header too */
+div.Hazelnut table.dataTable thead { background: url('../img/tablesort-header.png') no-repeat; }
index a5a9ad8..99e9b96 100644 (file)
         var object = this;
 
         /* Transforms the table into DataTable, and keep a pointer to it */
-        this.table = $('#hazelnut-' + options.plugin_uuid).dataTable({
+       actual_options = {
             // Customize the position of Datatables elements (length,filter,button,...)
-            // inspired from : 
             // http://datatables.net/release-datatables/examples/advanced_init/dom_toolbar.html
             // http://www.datatables.net/forums/discussion/3914/adding-buttons-to-header-or-footer/p1
-            //"sDom": 'lf<"#datatableSelectAll-'+ options.plugin_uuid+'">rtip',
            sDom: "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
             sPaginationType: 'bootstrap',
             // Handle the null values & the error : Datatables warning Requested unknown parameter
             // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
             aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
-//            bRetrieve: true,
            // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
             // sScrollX: '100%',       /* Horizontal scrolling */
             bProcessing: true,      /* Loading */
-// this looks like just another ugly hack
-//            fnRowCallback: function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
-//                $(nRow).attr('id', unfold.get_value(aData[3]));
-//                return nRow;
-//            },
             fnDrawCallback: function() { hazelnut_draw_callback.call(object, options); }
-        });
+        };
+       // the intention here is that options.datatables_options as coming from the python object take precedence
+       $.extend(actual_options, options.datatables_options );
+        this.table = $('#hazelnut-' + options.plugin_uuid).dataTable(actual_options);
 
         /* Setup the SelectAll button in the dataTable header */
         var oSelectAll = $('#datatableSelectAll-'+ options.plugin_uuid);
index b69bcc9..e2b3a7c 100644 (file)
@@ -5,7 +5,7 @@ class Hazelnut (Plugin):
     # set checkboxes if a final column with checkboxes is desired
     # pass columns as the initial set of columns
     #   if None then this is taken from the query's fields
-    def __init__ (self, query, checkboxes=False, columns=None, **settings):
+    def __init__ (self, query, checkboxes=False, columns=None, datatables_options={}, **settings):
         Plugin.__init__ (self, **settings)
         self.query=query
         self.checkboxes=checkboxes
@@ -13,6 +13,7 @@ class Hazelnut (Plugin):
             self.columns=columns
         else:
             self.columns=self.query.fields
+        self.datatables_options=datatables_options
 
     def template_file (self):
         return "hazelnut.html"
@@ -38,4 +39,4 @@ class Hazelnut (Plugin):
         return reqs
 
     # the list of things passed to the js plugin
-    def json_settings_list (self): return ['plugin_uuid','query_uuid','checkboxes']
+    def json_settings_list (self): return ['plugin_uuid','query_uuid','checkboxes','datatables_options']
index d1c93dd..2811bb6 100644 (file)
@@ -62,6 +62,9 @@ def slice_view (request, slicename=tmp_default_slice):
                         checkboxes=True,
                         # this is the query at the core of the slice list
                         query=main_query,
+                        # this of course should be automatic in hazelnut
+                        # for now we turn off sorting on the checkboxes columns this way
+                        datatables_options = { 'aoColumns' : [ None, None, None, None, {'bSortable': False} ] },
                         ),
                     ]),
               Hazelnut (