Bug 9573: Lost items report - add KohaTable to itemlost
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 5 Oct 2017 17:35:24 +0000 (14:35 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sat, 17 Feb 2018 21:32:14 +0000 (18:32 -0300)
Before this patch set, we used KohaTable to display a table with the
column visibility plugin, and an usual dataTable initialisation for the
filters.
For the lost items report table we will need both.
To do so we need to reorganize the code a bit

We cannot pass a selector but the id of the node which represents the
table. Indeed it is how works currently the filters (we may want to
improve that later)

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

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

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

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

13 files changed:
koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt
koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt
koha-tmpl/intranet-tmpl/prog/js/table_filters.js

index 5d674bc..1ee31b0 100644 (file)
@@ -2,12 +2,14 @@
 
 <script type="text/javascript">
 function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
-    var id = 0;
+    var counter = 0;
     var hidden_ids = [];
     var included_ids = [];
+    var selector = '#' + id_selector;
+
     $(columns_settings).each( function() {
         var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', selector ).index( 'th' );
-        var used_id = dt_parameters.bKohaColumnsUseNames ? named_id : id;
+        var used_id = dt_parameters.bKohaColumnsUseNames ? named_id : counter;
         if ( used_id == -1 ) return;
 
         if ( this['is_hidden'] == "1" ) {
@@ -16,7 +18,7 @@ function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
         if ( this['cannot_be_toggled'] == "0" ) {
             included_ids.push( used_id );
         }
-        id++;
+        counter++;
     });
     dt_parameters[ "buttons" ] = [
         {
@@ -26,7 +28,7 @@ function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
         }
     ];
 
-    var table = $('#' + id_selector + ' table');
+    var table = $(selector);
     if ( add_filters ) {
         // Duplicate the table header row for columnFilter
         thead_row = table.find('thead tr');
@@ -46,7 +48,7 @@ function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
         link = $('<a>')
             .attr('href', '#')
             .attr('id', id_selector + '_activate_filters');
-        $("." + id_selector + "_table_controls").prepend(link);
+        $("." + id_selector  + "_table_controls").prepend(link);
         deactivate_filters(id_selector);
     }
 
index 3b9e221..94ccbf3 100644 (file)
         var MSG_REMOVE_PATRON = _("Remove");
         $(document).ready(function() {
             var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'histsearch', 'histsearcht', 'json' ) %];
-            KohaTable("#histsearcht", {
+            KohaTable("histsearcht", {
                 "aoColumnDefs": [
                     { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
index 9c4b622..97797ad 100644 (file)
@@ -26,7 +26,7 @@ function check_uncheck() {
 $(document).ready(function() {
 
     var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'lateorders', 'late_orders', 'json' ) %];
-    late_orderst = KohaTable("#late_orders", {
+    late_orderst = KohaTable("late_orders", {
         "aoColumnDefs": [
             { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
             { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
index 4308b40..6441f95 100644 (file)
 
         $(document).ready(function() {
             columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'currency', 'currencies-table', 'json' ) %]
-            var issuest = KohaTable("#currencies-table", {
+            var issuest = KohaTable("currencies-table", {
                 dom: 'B<"clearfix">t',
                 "columnDefs": [
                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
index a990c80..1cf0f81 100644 (file)
 [% items_table_block_iter = 0 %]
 [% BLOCK items_table %]
     [% items_table_block_iter = items_table_block_iter + 1 %]
-    <div class="[% tab %]_table_controls">
+    <div class="[% tab %]_table_table_controls">
         [% IF (StaffDetailItemSelection) %]
             | <a href="#" class="SelectAll" data-tab="[% tab %]"><i class="fa fa-check"></i> Select all</a> |
             <a href="#" class="ClearAll" data-tab="[% tab %]"><i class="fa fa-remove"></i> Clear all</a>
             </span>
         [% END %]
     </div>
-    <table class="items_table">
+    <table class="items_table" id="[% tab %]_table">
         <thead>
             <tr>
                 [% IF (StaffDetailItemSelection) %]<th class="NoSort"></th>[% END %]
         browser.show();
 
         $(document).ready(function() {
-            var ids = ['holdings', 'otherholdings'];
+            var ids = ['holdings_table', 'otherholdings_table'];
 
             for (var i in ids) {
                 var id = ids[i];
index 5b90d9a..8df082e 100644 (file)
@@ -58,7 +58,7 @@ $(document).ready(function(){
     // Skip the first column
     columns_settings.unshift( { cannot_be_toggled: "1" } );
 
-    var itemst = KohaTable("#itemst", {
+    var itemst = KohaTable("itemst", {
         "aoColumnDefs": [
           { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
         ],
index 200f95c..b706e8f 100644 (file)
     <script type="text/javascript">
         $(document).ready(function() {
           var columns_settings = [% ColumnsSettings.GetColumns('circ', 'holds', 'holds-to-pull', 'json') %];
-          var holdst = KohaTable("#holdst", {
+          var holdst = KohaTable("holdst", {
             "aoColumnDefs": [
                 { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
                 { "sType": "title-string", "aTargets" : [ "title-string" ] },
index 2d4f805..f18ea69 100644 (file)
             [% END %]
 
             var columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'returns', 'checkedintable', 'json' ) %]
-            var returns_table = KohaTable("#checkedintable", {
+            var returns_table = KohaTable("checkedintable", {
                     "bFilter":false,
                     "bPaginate":false,
                     "bInfo":false,
index ca497e7..80ff386 100644 (file)
             $('#holdst thead input').on('change keyup keydown', filterColumn);
 
             var columns_settings = [% ColumnsSettings.GetColumns('circ', 'view_holdsqueue', 'holds-table', 'json') %];
-            var holdst = KohaTable("#holdst", {
+            var holdst = KohaTable("holdst", {
                 "aaSorting": [[ 3, "asc" ]],
                 "aoColumns": [
                     { "sType": "anti-the" },null,null,null,null,null,null,null,null,{ "sType": "title-string" },null
index c13bbbb..158470f 100644 (file)
             var txtActivefilter = _("Filter paid transactions");
             var txtInactivefilter = _("Show all transactions");
             var columns_settings = [% ColumnsSettings.GetColumns('members', 'fines', 'account-fines', 'json') %];
-            var table_account_fines = KohaTable("#table_account_fines", {
+            var table_account_fines = KohaTable("table_account_fines", {
                 "sPaginationType": "four_button",
                 'aaSorting': [[0, 'desc']],
                 "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
index efa97c1..ad73084 100644 (file)
@@ -5,7 +5,6 @@
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
-[% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
 </head>
 
                 [%# Remove the first column if we do not display the checkbox %]
                 columns_settings.splice(0, 1);
             [% END %]
-            dtMemberResults = KohaTable("#memberresultst", {
+            dtMemberResults = KohaTable("memberresultst", {
                 'bServerSide': true,
                 'sAjaxSource': "/cgi-bin/koha/svc/members/search",
                 'fnServerData': function(sSource, aoData, fnCallback) {
index b88ead7..e5e3866 100644 (file)
 
 [% MACRO jsinclude BLOCK %]
     [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
     [% INCLUDE 'columns_settings.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/table_filters.js"></script>
     <script type='text/javascript'>
         $(document).ready(function() {
             var columns_settings = [% ColumnsSettings.GetColumns( 'reports', 'lostitems', 'lostitems-table', 'json' ) %];
-            var lostitems_table = KohaTable("#lostitems-table", {
+            var lostitems_table = KohaTable("lostitems-table", {
                 "dom": 'B<"clearfix">t',
                 "aaSorting": [],
                 "aoColumnDefs": [
                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
                 ],
+                'bAutoWidth': false,
                 "bPaginate": false,
-            }, columns_settings);
-
+            }, columns_settings, 'with_filters');
         });
     </script>
 [% END %]
index a1a914a..6607120 100644 (file)
@@ -1,5 +1,5 @@
 function activate_filters(id) {
-    var table = $("#" + id + " table");
+    var table = $("#" + id );
     if (table.length == 1) {
         filters_row = table.find('thead tr.filters_row');
 
@@ -32,7 +32,7 @@ function activate_filters(id) {
 }
 
 function deactivate_filters(id) {
-    filters_row = $("#" + id + " table").find('thead tr.filters_row');
+    filters_row = $("#" + id ).find('thead tr.filters_row');
 
     filters_row.find('input[type="text"]')
         .val('')            // Empty filter text boxes