From 4acb8bc1be95c7baa6ef7e197aad53875597d737 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Fri, 22 Nov 2019 18:41:28 +0000
Subject: [PATCH] Bug 24093: Sorting indicators broken on list contents view

This patch updates the table markup for the lists contents view so that
the table sort state is correctly indicated by arrows in the table
headers. The markup changes allow the standard DataTables CSS to apply
to this table even though it is not a DataTable.

To test, apply the patch, go to Lists, and view any list with multiple
titles attached.

 - The list should be sorted by default according to the list's
   settings, and the arrow in the header row should correctly reflect
   the sorting column and direction.
 - Test re-sorting the table by each of the different sortable columns,
   confirming each time that the sorting arrows are correct.

Signed-off-by: Maryse Simard <maryse.simard@inlibro.com>
---
 .../prog/en/modules/virtualshelves/shelves.tt      | 50 +++++++++++-----------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
index 57f5e24..72420dd 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
@@ -159,44 +159,42 @@
     </div>
 [% END %]
 
-    <table id="searchresults">
+    <table id="searchresults" class="dataTable">
+        <thead>
             <tr>
                 [% IF ( itemsloop ) %]<th class="checkall">&nbsp;</th>[% END %]
 
                 [% UNLESS ( item_level_itypes ) %]<th>Item type</th>[% END %]
-                <th>
+                [% IF sortfield == 'title' %]
+                    <th class="sorting_[% direction | html %]">
+                [% ELSE %]
+                    <th class="sorting">
+                [% END %]
                     <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;sortfield=title&amp;direction=[% IF sortfield != 'title' %]asc[% ELSE %][% new_direction | uri %][% END %]">Title</a>
-                    [% IF sortfield == 'title' %]
-                        <img src="[% interface | html %]/[% theme | html %]/img/[% direction | html %].gif" alt="[% direction | html %] sort" />
-                    [% ELSE %]
-                        <img src="[% interface | html %]/[% theme | html %]/img/ascdesc.gif" alt="" />
-                    [% END %]
                 </th>
-                <th>
+                [% IF sortfield == 'author' %]
+                    <th class="sorting_[% direction | html %]">
+                [% ELSE %]
+                    <th class="sorting">
+                [% END %]
                     <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;sortfield=author&amp;direction=[% IF sortfield != 'author' %]asc[% ELSE %][% new_direction | uri %][% END %]">Author</a>
-                   [% IF sortfield == 'author' %]
-                        <img src="[% interface | html %]/[% theme | html %]/img/[% direction | html %].gif" alt="[% direction | html %] sort" />
-                   [% ELSE %]
-                       <img src="[% interface | html %]/[% theme | html %]/img/ascdesc.gif" alt="" />
-                   [% END %]
-                 </th>
-                <th>
+                </th>
+                [% IF sortfield == 'dateadded' %]
+                    <th class="sorting_[% direction | html %]">
+                [% ELSE %]
+                    <th class="sorting">
+                [% END %]
                     <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;sortfield=dateadded&amp;direction=[% IF sortfield != 'dateadded' %]asc[% ELSE %][% new_direction | uri %][% END %]">Date added</a>
-                    [% IF sortfield == 'dateadded' %]
-                        <img src="[% interface | html %]/[% theme | html %]/img/[% direction | html %].gif" alt="[% direction | html %] sort" />
-                    [% ELSE %]
-                        <img src="[% interface | html %]/[% theme | html %]/img/ascdesc.gif" alt="" />
-                    [% END %]
                 </th>
-                <th>
+                [% IF sortfield == 'itemcallnumber' %]
+                     <th class="sorting_[% direction | html %]">
+                [% ELSE %]
+                    <th class="sorting">
+                [% END %]
                     <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;sortfield=itemcallnumber&amp;direction=[% IF sortfield != 'itemcallnumber' %]asc[% ELSE %][% new_direction | uri %][% END %]">Call number</a>
-                   [% IF sortfield == 'itemcallnumber' %]
-                        <img src="[% interface | html %]/[% theme | html %]/img/[% direction | html %].gif" alt="[% direction | html %] sort" />
-                   [% ELSE %]
-                       <img src="[% interface | html %]/[% theme | html %]/img/ascdesc.gif" alt="" />
-                   [% END %]
                  </th>
             </tr>
+        </thead>
         [% FOREACH itemsloo IN itemsloop %]
                 <tr>
             [% IF itemsloop %]
-- 
2.7.4