Bug 15285: Update common files
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 14 Dec 2015 12:17:43 +0000 (12:17 +0000)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Wed, 24 Feb 2016 00:02:49 +0000 (00:02 +0000)
This patch moves the Button area all tables which does not redefine the
dom/sDom DT parameter.

Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
C4/Utils/DataTables/ColumnsSettings.pm
koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc
koha-tmpl/intranet-tmpl/prog/en/js/datatables.js

index eb0ca54..6a804c4 100644 (file)
@@ -44,7 +44,18 @@ sub get_columns {
         $column->{cannot_be_toggled} = $c->cannot_be_toggled;
     }
 
-    return $list->{modules}{$module}{$page}{$tablename} || [];
+    my $columns = $list->{modules}{$module}{$page}{$tablename} || [];
+
+    # Assign default value if does not exist
+    $columns = [ map {
+        {
+            cannot_be_toggled => exists $_->{cannot_be_toggled} ? $_->{cannot_be_toggled} : 0,
+            is_hidden => exists $_->{is_hidden} ? $_->{is_hidden} : 0,
+            columnname => $_->{columnname},
+        }
+    } @$columns ];
+
+    return $columns;
 }
 
 sub get_modules {
index ec86690..7d80435 100644 (file)
@@ -1,13 +1,14 @@
 [% USE ColumnsSettings %]
 
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.colvis.css" />
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.colvis.js"></script>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/buttons.dataTables.min.css" />
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/dataTables.buttons.min.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/buttons.colVis.min.js"></script>
 
 <script type="text/javascript">
 function KohaTable(selector, dt_parameters, columns_settings) {
     var id = 0;
     var hidden_ids = [];
-    var excluded_ids = [];
+    var included_ids = [];
     $(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;
@@ -16,12 +17,17 @@ function KohaTable(selector, dt_parameters, columns_settings) {
         if ( this['is_hidden'] == "1" ) {
             hidden_ids.push( used_id );
         }
-        if ( this['cannot_be_toggled'] == "1" ) {
-            excluded_ids.push( used_id );
+        if ( this['cannot_be_toggled'] == "0" ) {
+            included_ids.push( used_id );
         }
         id++;
     });
-    dt_parameters[ "oColVis" ] = { "aiExclude": excluded_ids };
+    dt_parameters[ "buttons" ] = [
+        {
+            extend: 'colvis',
+            columns: included_ids,
+        }
+    ];
     var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
 
     $(hidden_ids).each(function(index, value) {
index 4381b01..590fae5 100644 (file)
@@ -1,5 +1,7 @@
 [% INCLUDE 'format_price.inc' %]
 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/dataTables.buttons.min.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/buttons.colVis.min.js"></script>
 <script type="text/javascript">
 //<![CDATA[
     var MSG_DT_FIRST = _("First");
index f1623dc..71185c6 100644 (file)
@@ -23,7 +23,7 @@ var dataTablesDefaults = {
         "sSearch"           : window.MSG_DT_SEARCH || "Search:",
         "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found"
     },
-    "sDom": 'C<"top pager"ilpf>tr<"bottom pager"ip>',
+    "dom": '<"top pager"ilpfB>tr<"bottom pager"ip>',
     "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
     "iDisplayLength": 20
 };