Browse Source

Bug 15285: Update common files

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
new_12478_elasticsearch
Jonathan Druart 6 years ago
committed by Brendan Gallagher
parent
commit
243b797dd1
  1. 13
      C4/Utils/DataTables/ColumnsSettings.pm
  2. 18
      koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
  3. 2
      koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc
  4. 2
      koha-tmpl/intranet-tmpl/prog/en/js/datatables.js

13
C4/Utils/DataTables/ColumnsSettings.pm

@ -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 {

18
koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc

@ -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) {

2
koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc

@ -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");

2
koha-tmpl/intranet-tmpl/prog/en/js/datatables.js

@ -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
};

Loading…
Cancel
Save