[Koha-patches] [PATCH] Bug 11719 - Use new DataTables include in serials templates

Owen Leonard oleonard at myacpl.org
Mon Feb 10 18:01:02 CET 2014


Bug 10649 introduced a new include file for adding DataTables-related
JavaScript assets. This patch adds use of this include file to all
serials-related pages which use DataTables.

Apply the patch and test the following pages to confirm that table
sorting works correctly:

- Serials search results (serials/serials-search.pl): Perform a search
  which will return more than one subscription. The expiration date
  column is now sorted using the "title-string" filter for sorting based
  on the unformatted date. The "anti-the" filter has been added to the
  title column to exclude articles when sorting.

- Serials collection (serials/serials-collection.pl): View the serial
  colection page for an existing subscription. The table of issues
  should be sorted correctly.

- Serial claims (serials/claims.pl): The "since" and
  "claim date" columns have been modified to use the title-string filter
  for sorting based on the unformatted date.
  C4::Serials.pm::GetLateOrMissingIssues has been modified to pass an
  unformatted date along with the formatted date. The "anti-the" filter
  has been added to the title column to exclude articles when sorting.
---
 C4/Serials.pm                                      |    2 ++
 .../prog/en/modules/serials/claims.tt              |   34 ++++++++++++++------
 .../prog/en/modules/serials/serials-collection.tt  |    6 ++--
 .../prog/en/modules/serials/serials-search.tt      |   30 ++++++++++++-----
 4 files changed, 50 insertions(+), 22 deletions(-)

diff --git a/C4/Serials.pm b/C4/Serials.pm
index 2fb639b..554f244 100644
--- a/C4/Serials.pm
+++ b/C4/Serials.pm
@@ -2062,9 +2062,11 @@ sub GetLateOrMissingIssues {
     while ( my $line = $sth->fetchrow_hashref ) {
 
         if ($line->{planneddate} && $line->{planneddate} !~/^0+\-/) {
+            $line->{planneddateISO} = $line->{planneddate};
             $line->{planneddate} = format_date( $line->{planneddate} );
         }
         if ($line->{claimdate} && $line->{claimdate} !~/^0+\-/) {
+            $line->{claimdateISO} = $line->{claimdate};
             $line->{claimdate}   = format_date( $line->{claimdate} );
         }
         $line->{"status".$line->{status}}   = 1;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt
index 288620b..24c8ca7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt
@@ -4,20 +4,26 @@
     <title>Koha › Serials › Claims</title>
     [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
-<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
-<script type="text/javascript" src="[% interface %]/[% theme %]/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 //<![CDATA[
-    [% IF (dateformat == 'metric') %]dt_add_type_uk_date();[% END %]
 	 $(document).ready(function() {
         [% UNLESS ( preview ) %]
          var sTable = $("#claimst").dataTable($.extend(true, {}, dataTablesDefaults, {
             "sDom": 't',
-            "aoColumnDefs": [
-                { "aTargets": [ 0,1 ], "bSortable": false, "bSearchable": false }
-            ],
+            [% IF ( letter ) %]
+                "aoColumnDefs": [
+                    { "aTargets": [ 0,1 ], "bSortable": false, "bSearchable": false }
+                ],
+            [% ELSE %]
+                "aoColumnDefs": [
+                    { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }
+                ],
+            [% END %]
+            "aoColumns": [
+                [% IF ( letter ) %]null,[% END %]null,null,{ "sType": "anti-the" },null,null,{ "sType": "title-string" },{ "sType": "title-string" }
+        ],
             "bPaginate": false
         }));
         [% END %]
@@ -300,10 +306,18 @@
                             [% IF ( missingissue.status7 ) %]<span class="status-claimed">Claimed</span>[% END %]
                         </td>
                         <td class="planneddate">
-                        [% missingissue.planneddate %]
+                            [% IF ( missingissue.planneddate ) %]
+                                <span title="[% missingissue.planneddateISO %]">[% missingissue.planneddate %]</span>
+                            [% ELSE %]
+                                <span title="0000-00-00"></span>
+                            [% END %]
                         </td>
                         <td>
-                        [% missingissue.claimdate %]
+                            [% IF ( missingissue.claimdate ) %]
+                                <span title="[% missingissue.claimdateISO %]">[% missingissue.claimdate %]</span>
+                            [% ELSE %]
+                                <span title="0000-00-00"></span>
+                            [% END %]
                         </td>
                     </tr>
                 [% END %]</tbody>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt
index ed1dc39..8743c18 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt
@@ -2,11 +2,9 @@
 [% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha › Serials › Serial collection information for [% bibliotitle %]</title>
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'doc-head-close.inc' %]
-<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>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
 
 <script type="text/javascript">
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
index f570669..e88533b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
@@ -3,12 +3,10 @@
 [% USE KohaDates %]
 [% USE AuthorisedValues %]
 <title>Koha › Serials [% biblionumber %]</title>
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
-<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>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
 //<![CDATA[
  $(document).ready(function() {
@@ -16,9 +14,18 @@
         dt_add_type_uk_date();
     [% END %]
     var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
-
-        "aoColumnDefs": [
-            { "aTargets": [ -1, -2, -3 ], "bSortable": false, "bSearchable": false },
+        [% IF ( routing && CAN_user_serials_routing ) %]
+            "aoColumnDefs": [
+                { "aTargets": [ -1, -2, -3 ], "bSortable": false, "bSearchable": false },
+            ],
+        [% ELSE %]
+            "aoColumnDefs": [
+                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
+            ],
+        [% END %]
+        "aoColumns": [
+            null,{ "sType": "anti-the" },null,null,null,{ "sType": "title-string" },
+            [% IF ( routing && CAN_user_serials_routing ) %],null[% END %],null,null
         ],
         "sPaginationType": "four_button"
     } ) );
@@ -27,6 +34,9 @@
         "aoColumnDefs": [
             { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
         ],
+        "aoColumns": [
+            null,{ "sType": "anti-the" },null,null,null,null,null,null
+        ],
         "sPaginationType": "four_button"
     } ) );
 
@@ -190,7 +200,11 @@
                           [% IF ( subscription.callnumber ) %][% subscription.callnumber %][% END %]
                         </td>
                         <td>
-                          [% IF ( subscription.enddate ) %][% subscription.enddate | $KohaDates %][% END %]
+                            [% IF ( subscription.enddate ) %]
+                                <span title="[% subscription.enddate %]">[% subscription.enddate | $KohaDates %]</span>
+                            [% ELSE %]
+                                <span title="0000-00-00"></span>
+                            [% END %]
                         </td>
                         [% IF ( routing && CAN_user_serials_routing ) %]
                         <td>
-- 
1.7.9.5


More information about the Koha-patches mailing list