View | Details | Raw Unified | Return to bug 27005
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/columns_settings.inc (-7 / +97 lines)
Lines 19-36 function KohaTable(selector, dt_parameters, columns_settings) { Link Here
19
        }
19
        }
20
        id++;
20
        id++;
21
    });
21
    });
22
23
    // By default we include all visible columns in exports and print unless they have the "noExport" class
24
    var exportColumns = ":visible:not(.noExport)";
25
    if( dt_parameters.hasOwnProperty("exportColumns") ){
26
        // A custom buttons configuration has been passed from the page
27
        exportColumns = dt_parameters["exportColumns"];
28
    }
29
    // Data which has the "noExport" class should not appear in print or export
30
    var export_format = {
31
        body: function ( data, row, column, node ) {
32
            var newnode = $(node);
33
34
            if ( newnode.find(".noExport").length > 0 ) {
35
                newnode = newnode.clone();
36
                newnode.find(".noExport").remove();
37
            }
38
39
            return newnode.text().replace( /\n/g, ' ' ).trim();
40
        }
41
    }
42
43
    // Add a "Clear filter" button to table filter form field
22
    dt_parameters[ "buttons" ] = [
44
    dt_parameters[ "buttons" ] = [
23
        {
45
        {
24
            extend: 'colvis',
46
            fade: 100,
25
            columns: included_ids,
47
            className: "dt_button_clear_filter",
26
            text: _("Column visibility"),
48
            titleAttr: _("Clear filter"),
49
            enabled: false,
50
            text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + _("Clear filter") + '</span>',
51
            action: function ( e, dt, node, config ) {
52
                dt.search( "" ).draw("page");
53
                node.addClass("disabled");
54
            }
55
        },
56
        {
57
            extend: 'csvHtml5',
58
            text: _("CSV"),
59
            exportOptions: {
60
                columns: exportColumns,
61
                format: export_format
62
            },
63
        },
64
        {
65
            extend: 'copyHtml5',
66
            text: _("Copy"),
67
            exportOptions: {
68
                columns: exportColumns,
69
                format: export_format
70
            },
71
        },
72
        {
73
            extend: 'print',
74
            text: _("Print"),
75
            exportOptions: {
76
                columns: exportColumns,
77
                format: export_format
78
            },
27
        }
79
        }
28
    ];
80
    ];
29
    var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
30
81
31
    $(hidden_ids).each(function(index, value) {
82
    if( included_ids.length > 0 ){
32
        table.fnSetColumnVis( value, false );
83
        dt_parameters[ "buttons" ].push(
33
    });
84
            {
85
                extend: 'colvis',
86
                fade: 100,
87
                columns: included_ids,
88
                className: "columns_controls",
89
                titleAttr: _("Columns settings"),
90
                text: '<i class="fa fa-lg fa-gear"></i> <span class="dt-button-text">' + _("Columns") + '</span>',
91
                exportOptions: {
92
                    columns: exportColumns
93
                }
94
            }
95
        );
96
    }
97
98
    var table = $(selector);
99
    var new_parameters = {}
100
    $.extend(true, new_parameters, dataTablesDefaults, dt_parameters);
101
    var default_column_defs = [
102
        { "aTargets": ["title-string"], "sType": "title-string" },
103
        { "aTargets": ["string-sort"], "sType": "string" },
104
        { "aTargets": ["anti-the"], "sType": "anti-the" },
105
        { "aTargets": ["NoSort"], "bSortable": false, "bSearchable": false },
106
    ];
107
    if (new_parameters["aoColumnDefs"] === undefined) {
108
        new_parameters["aoColumnDefs"] = default_column_defs;
109
    } else {
110
        $.extend(true, new_parameters, default_column_defs);
111
    }
112
113
    table.dataTable(new_parameters);
114
    table.DataTable().on("column-visibility.dt", function () {
115
        if (typeof columnsInit == 'function') {
116
            // This function can be created separately and used to trigger
117
            // an event after the DataTable has loaded AND column visibility
118
            // has been updated according to the table's configuration
119
            columnsInit();
120
        }
121
    }).columns(hidden_ids).visible(false);
122
123
    $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip();
34
124
35
    return table;
125
    return table;
36
}
126
}
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt (-12 / +7 lines)
Lines 1-6 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE TablesSettings %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your checkout history</title>
6
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your checkout history</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
Lines 85-92 Link Here
85
                                    <table id="readingrec" class="table table-bordered table-striped">
86
                                    <table id="readingrec" class="table table-bordered table-striped">
86
                                        <thead>
87
                                        <thead>
87
                                            <tr>
88
                                            <tr>
88
                                                <th style="display:none;">Type</th>
89
                                                <th style="display:none;" class="noExport">Type</th>
89
                                                <th class="nosort"></th>
90
                                                <th class="NoSort noExport"></th>
90
                                                <th class="anti-the">Title</th>
91
                                                <th class="anti-the">Title</th>
91
                                                <th>Item type</th>
92
                                                <th>Item type</th>
92
                                                <th>Call no.</th>
93
                                                <th>Call no.</th>
Lines 202-207 Link Here
202
[% INCLUDE 'opac-bottom.inc' %]
203
[% INCLUDE 'opac-bottom.inc' %]
203
[% BLOCK jsinclude %]
204
[% BLOCK jsinclude %]
204
[% INCLUDE 'datatables.inc' %]
205
[% INCLUDE 'datatables.inc' %]
206
[% INCLUDE 'columns_settings.inc' %]
205
<script>
207
<script>
206
    $(document).ready(function(){
208
    $(document).ready(function(){
207
        [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
209
        [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
Lines 209-229 Link Here
209
            $('#sortform').submit();
211
            $('#sortform').submit();
210
        });
212
        });
211
213
212
        var table = $("#readingrec").dataTable($.extend(true, {}, dataTablesDefaults, {
214
        var columns_settings = []; // Empty because there are no columns we want to be configurable
215
        var table = KohaTable("#readingrec", {
213
            "dom": '<"top"<"table_entries"i><"table_controls"fB>>t',
216
            "dom": '<"top"<"table_entries"i><"table_controls"fB>>t',
214
            "sorting": [[ 1, "asc" ]],
215
            "autoWidth": false,
217
            "autoWidth": false,
216
217
            "columnDefs": [
218
                { "targets": [ "nosort" ],"sortable": false,"searchable": false },
219
                { "type": "anti-the", "targets" : [ "anti-the" ] },
220
                { "type": "title-string", "targets" : [ "title-string" ] }
221
            ],
222
            "language": {
218
            "language": {
223
                "search": "_INPUT_",
219
                "search": "_INPUT_",
224
                "searchPlaceholder": _("Search")
220
                "searchPlaceholder": _("Search")
225
            }
221
            }
226
        }));
222
        }, columns_settings);
227
223
228
        var tabs = $("#tabs").tabs({
224
        var tabs = $("#tabs").tabs({
229
            activate: function(e, ui) {
225
            activate: function(e, ui) {
230
- 

Return to bug 27005