Bug 21785: Add columns configuration to hold ratios report
authorOwen Leonard <oleonard@myacpl.org>
Wed, 7 Nov 2018 19:01:16 +0000 (19:01 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 11 Jan 2019 13:27:00 +0000 (13:27 +0000)
This patch adds column configuration to the hold ratios report
DataTable.

This patch also amends some JavaScript and markup related to some
obsolete jQuery syntax: A hover function was being used to change an
element's style on hover. It has been removed in favor of using a link
and CSS>

To test, apply the patch and view the hold ratios report using a ratio
which will return multiple results. Confirm that DataTables controls
work correctly: Paging, search, column visibility, export and print.

Click a number in the "hold ratio" column of the table and verify that
it populates the "hold ratio" field in the "refine results" form in the
sidebar.

Test setting default column configurations in Administration -> Columns
settings.

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

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

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

admin/columns_settings.yml
koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt

index 2235aff..c616851 100644 (file)
@@ -649,6 +649,29 @@ modules:
         -
           columnname: action
 
+    holdsratios:
+      holds-ratios:
+        -
+          columnname: holds
+        -
+          columnname: items
+        -
+          columnname: holds_ratio
+        -
+          columnname: title
+        -
+          columnname: home_libraries
+        -
+          columnname: holding_libraries
+        -
+          columnname: location
+        -
+          columnname: itemtype
+        -
+          columnname: call_numbers
+        -
+          columnname: items_needed
+
   opac:
     biblio-detail:
       holdingst:
index f17a3b2..2db6009 100644 (file)
@@ -4,6 +4,7 @@
 [% USE AuthorisedValues %]
 [% USE Branches %]
 [% USE ItemTypes %]
+[% USE ColumnsSettings %]
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Circulation &rsaquo; Hold ratios</title>
@@ -12,7 +13,8 @@
 <style>
     .sql { display: none; }
     .ulined { text-decoration: underline; }
-    .ratiolimit { color: blue; cursor: pointer; }
+    .ratiolimit:link { color: blue; cursor: pointer; }
+    .ratiolimit:hover { color: blue; text-decoration: underline; }
     #holdst ul li {  list-style: outside url("[% interface | html %]/[% theme | html %]/img/item-bullet.gif") disc; }
 </style>
 </head>
@@ -55,7 +57,7 @@
         <tr>
             <td><p>[% reserveloo.reservecount | html %]</p></td>
             <td><p>[% reserveloo.itemcount | html %]</p></td>
-            <td><p class="ratiolimit">[% reserveloo.thisratio | html %]</p></td>
+            <td><a href="#" class="ratiolimit">[% reserveloo.thisratio | html %]</a></td>
             <td> [% INCLUDE 'biblio-default-view.inc' biblionumber = reserveloo.biblionumber %][% reserveloo.title | html %] [% IF ( reserveloo.subtitle ) %][% FOREACH subtitl IN reserveloo.subtitle %][% subtitl.subfield | html %][% END %][% END %]</a>[% IF ( reserveloo.author ) %] by [% reserveloo.author | html %][% END %]
             </td>
             <td>
      </div> <!-- /.row -->
 
 [% MACRO jsinclude BLOCK %]
-  [% INCLUDE 'calendar.inc' %]
-  [% INCLUDE 'datatables.inc' %]
-  <script>
-       $(document).ready(function() {
-          $(".ratiolimit").click(function () {
-              $("#ratio").val($(this).html());
-          });
-          $(".ratiolimit").hover(
-              function () { $(this).toggleClass("ulined") },
-              function () { $(this).toggleClass("ulined") }
-          );
-          $("#holdst").dataTable($.extend(true, {}, dataTablesDefaults, {
-              "aaSorting": [ [2,'desc'], [3,'asc'] ],
-              "aoColumnDefs": [
-                  { "aTargets": [ 0,1,2,8 ], "sType": "natural" },
-                  { "aTargets": [ 3 ], "sType": "anti-the" },
-              ],
-              "sPaginationType": "four_button"
-          }));
+    [% INCLUDE 'calendar.inc' %]
+    [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
+    <script>
+        var columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'holdsratios', 'holds-ratios', 'json' ) | $raw %];
+        $(document).ready(function() {
+            $(".ratiolimit").on("click", function(e) {
+                e.preventDefault();
+                $("#ratio").val($(this).html());
+            });
+            KohaTable("holdst", {
+                "aaSorting": [ [2,'desc'], [3,'asc'] ],
+                  "aoColumnDefs": [
+                      { "aTargets": [ 0,1,2,8 ], "sType": "natural" },
+                      { "aTargets": [ 3 ], "sType": "anti-the" },
+                    ],
+                "sPaginationType": "four_button",
+                "autoWidth": false
+            }, columns_settings);
        });
   </script>
 [% END %]