Bug 9446 [Revised] Use DataTables on Z39.50 servers administration page
authorOwen Leonard <oleonard@myacpl.org>
Wed, 13 Mar 2013 16:42:01 +0000 (12:42 -0400)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 20 Mar 2013 19:27:49 +0000 (15:27 -0400)
Replace the tablesorter plugin with the DataTables plugin on the
Z39.50 servers administration page. Structural changes were made to
deal with a DataTables bug which prevents it from properly parsing a
<th> with a colspan.

This patch also moves embedding of the toolbar and table-sorting JS from
within the body of the page to the <head> for sake of consistency.

To test, open the Z39.50 servers administration page (Administration ->
Z39.50 client targets). Confirm that table sorting works
correctly.

Revision corrects template path to datatables assets.
Further revision fixes conflict with Bug 9647.

Signed-off-by: Frederic Durand <frederic.durand@unilim.fr>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt

index adf707d..18f92fc 100644 (file)
@@ -5,7 +5,12 @@
 [% IF ( add_validate ) %]Z39.50 servers &rsaquo; Z39.50 server added[% END %]
 [% IF ( delete_confirmed ) %]Z39.50 servers &rsaquo; Z39.50 server deleted[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-
+[% IF ( else ) %]
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
+[% INCLUDE 'datatables-strings.inc' %]
+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
+[% END %]
 [% IF ( add_form ) %]
 <script type="text/javascript">
 //<![CDATA[
 </script>
 [% END %]
 [% IF ( else ) %]
-    <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
     <script type="text/javascript">
     //<![CDATA[
      $(document).ready(function() {
-        [% IF ( loop ) %]$.tablesorter.defaults.widgets = ['zebra'];
-        $("#serverst").tablesorter({
-            sortList: [[0,0]],
-            headers: { 2: {sorter:false},3: { sorter: false },4: { sorter: false },7: { sorter: false },8: { sorter: false },9: { sorter: false },10: { sorter: false }}
-        });[% END %]
+        [% IF ( loop ) %]$("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "aoColumnDefs": [
+                { "aTargets": [ 2,3,4,7,8,9,10,11 ], "bSortable": false, "bSearchable": false },
+            ],
+            "iDisplayLength": 20,
+            "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
+            "sPaginationType": "four_button"
+        }));[% END %]
      });
     //]]>
     </script>
                 You searched for [% searchfield %]
         [% END %]              
 <table id="serverst">
-                <thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Checked</th><th>Rank</th>                         <th>Syntax</th><th>Encoding</th><th>Timeout</th><th colspan="2">&nbsp;</th>
+                <thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Checked</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>&nbsp;</th><th>&nbsp;</th>
                 </tr></thead>
                 <tbody>[% FOREACH loo IN loop %]
                 [% UNLESS ( loop.odd ) %]