Bug 25471: Add DataTables to MARC subfield structure admin page
authorOwen Leonard <oleonard@myacpl.org>
Tue, 12 May 2020 21:27:05 +0000 (21:27 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 24 Jun 2020 13:05:02 +0000 (15:05 +0200)
This patch adds DataTables sorting and filtering to the table of
subfields shown on the MARC subfield structure administration page.

To test, apply the patch and go to Administration -> MARC bibliographic
framework.

 - From the 'Actions' menu, select 'MARC structure.'
 - From the 'Actions' menu, select the 'View 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: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

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

koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt
koha-tmpl/intranet-tmpl/prog/js/marc_subfields_structure.js

index 77b1708..7736f1f 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>
+<table id="table_marcsubfieldstructure">
+    <thead>
 <tr>
     <th>Subfield</th>
     <th>Text</th>
     <th>Constraints</th>
-    <th>Actions</th>
+    <th class="NoSort">Actions</th>
 </tr>
+    </thead>
+    <tbody>
 [% FOREACH loo IN loop %]
 <tr>
     <td><a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&amp;tagfield=[% loo.tagfield | uri %]&amp;frameworkcode=[% frameworkcode | uri %]#sub[% loo.tagsubfield | uri %]field">[% loo.tagsubfield | html %]</a></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 %]
     [% Asset.js("js/marc_subfields_structure.js") | $raw %]
 [% END %]
index 1f1cc90..aa90be6 100644 (file)
@@ -1,10 +1,16 @@
+/* global dataTablesDefaults */
 $(document).ready(function() {
     $('#subfieldtabs').tabs();
     $("input[id^='hidden_']").click(setHiddenValue);
     $("input[id^='hidden-']").each(function() {
         populateHiddenCheckboxes($(this).attr('id').split('-')[1]);
     });
-
+    $("#table_marcsubfieldstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
+        "columnDefs": [
+            { 'sortable': false, 'targets': [ 'NoSort' ] }
+        ],
+        paginate: false
+    }));
 });
 
 /* Function to enable/disable hidden values checkboxes when Flag is (de)selected */