Bug 25832: Add DataTables to MARC subfield structure admin page for authorities
authorOwen Leonard <oleonard@myacpl.org>
Tue, 23 Jun 2020 11:52:20 +0000 (11:52 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 18 Aug 2020 15:39:48 +0000 (17:39 +0200)
This patch adds DataTables sorting and filtering to the table of
subfields shown on the Authority MARC subfield structure administration
page.

To test, apply the patch and go to Administration -> Authority types.

 - From the 'Actions' menu, select 'MARC structure.'
 - From the 'Actions' menu, select the 'Subfields' link for a tag
   with multiple subfields.
   - On the page showing all the subfields for the tag, confirm that
     the table is sorted by default by subfield and that sorting works
     correctly.
   - Confirm that the search form at the top of the table works.

Signed-off-by: Katrin <katrin.fischer@bsz-bw.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt

index 33d7670..4e9f929 100644 (file)
 <p>This screen shows the subfields associated with the selected tag. You can edit subfields or add a new one by clicking on edit.</p>
 <p>The column 'Koha field' shows that the subfield is linked with a Koha field.</p>
 
-<table>
-    <tr>
-        <th>Subfield</th>
-        <th>Text</th>
-        <th>Constraints</th>
-        <th>&nbsp;</th>
-    </tr>
+<table id="table_authsubfieldstructure">
+    <thead>
+        <tr>
+            <th>Subfield</th>
+            <th>Text</th>
+            <th>Constraints</th>
+            <th class="NoSort">&nbsp;</th>
+        </tr>
+    </thead>
+    <tbody>
     [% FOREACH loo IN loop %]
     <tr>
         <td>
         </td>
     </tr>
     [% END %]
+    </tbody>
 </table>
 
     <form action="[% script_name | html %]" method="get">
      </div> <!-- /.row -->
 
 [% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
     [% Asset.js("js/admin-menu.js") | $raw %]
     <script>
-     $(document).ready(function() {
-        $('#subfieldtabs').tabs();
-     });
+        $(document).ready(function() {
+            $('#subfieldtabs').tabs();
+            $("#table_authsubfieldstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "columnDefs": [
+                    { 'sortable': false, 'targets': [ 'NoSort' ] }
+                ],
+                paginate: false
+            }));
+        });
     </script>
 [% END %]
 [% INCLUDE 'intranet-bottom.inc' %]