Owen Leonard
a54eb7fd5c
This patch revises our custom DataTables CSS to give a more colorful style to the columns configuration and export menus. The primary goal of this change is to make it easier to tell which columns are visible and which are hidden. To test, apply the patch and clear your browser cache if necessary. View a table with columns configuration and export options, e.e. Tools -> Notices & slip. Test the DataTables menus and confirm that they work as expected. Signed-off-by: Liz Rea <wizzyrea@gmail.com> This is a nice update to the styles. Signed-off-by: Jose-Mario Monteiro-Santos <jose-mario.monteiro-santos@inLibro.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
114 lines
3.2 KiB
PHP
114 lines
3.2 KiB
PHP
[% USE ColumnsSettings %]
|
|
|
|
<script>
|
|
function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
|
|
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 : counter;
|
|
if ( used_id == -1 ) return;
|
|
|
|
if ( this['is_hidden'] == "1" ) {
|
|
hidden_ids.push( used_id );
|
|
}
|
|
if ( this['cannot_be_toggled'] == "0" ) {
|
|
included_ids.push( used_id );
|
|
}
|
|
counter++;
|
|
});
|
|
|
|
var exportColumns = ":visible";
|
|
if( dt_parameters.hasOwnProperty("exportColumns") ){
|
|
// A custom buttons configuration has been passed from the page
|
|
exportColumns = dt_parameters["exportColumns"];
|
|
}
|
|
|
|
var export_buttons = [
|
|
{
|
|
extend: 'excelHtml5',
|
|
text: _("Excel"),
|
|
exportOptions: {
|
|
columns: exportColumns
|
|
},
|
|
},
|
|
{
|
|
extend: 'csvHtml5',
|
|
text: _("CSV"),
|
|
exportOptions: {
|
|
columns: exportColumns
|
|
},
|
|
},
|
|
{
|
|
extend: 'copyHtml5',
|
|
text: _("Copy"),
|
|
exportOptions: {
|
|
columns: exportColumns
|
|
},
|
|
},
|
|
{
|
|
extend: 'print',
|
|
text: _("Print"),
|
|
exportOptions: {
|
|
columns: exportColumns
|
|
},
|
|
}
|
|
];
|
|
|
|
dt_parameters[ "buttons" ] = [
|
|
{
|
|
extend: 'colvis',
|
|
fade: 100,
|
|
columns: included_ids,
|
|
className: "columns_controls",
|
|
titleAttr: _("Columns settings"),
|
|
text: '<i class="fa fa-lg fa-gear"></i> <span class="dt-button-text">' + _("Columns") + '</span>',
|
|
exportOptions: {
|
|
columns: exportColumns
|
|
},
|
|
},
|
|
{
|
|
extend: 'collection',
|
|
autoClose: true,
|
|
fade: 100,
|
|
className: "export_controls",
|
|
titleAttr: _("Export or print"),
|
|
text: '<i class="fa fa-lg fa-download"></i> <span class="dt-button-text">' + _("Export") + '</span>',
|
|
buttons: export_buttons
|
|
}
|
|
|
|
];
|
|
|
|
var table = $(selector);
|
|
if ( add_filters ) {
|
|
// Duplicate the table header row for columnFilter
|
|
thead_row = table.find('thead tr');
|
|
clone = thead_row.clone().addClass('filters_row');
|
|
clone.find("th.NoSort").html('');
|
|
thead_row.before(clone);
|
|
}
|
|
|
|
table.dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
|
|
|
|
$(hidden_ids).each(function(index, value) {
|
|
table.fnSetColumnVis( value, false );
|
|
});
|
|
|
|
if ( add_filters ) {
|
|
// show a link to activate filtering
|
|
link = $('<a>')
|
|
.attr('href', '#')
|
|
.attr('id', id_selector + '_activate_filters');
|
|
$("." + id_selector + "_table_controls").prepend(link);
|
|
deactivate_filters(id_selector);
|
|
}
|
|
|
|
$(".columns_controls,.export_controls").tooltip();
|
|
|
|
return table;
|
|
}
|
|
|
|
</script>
|