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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc (-2 / +21 lines)
Lines 1-7 Link Here
1
[% USE ColumnsSettings %]
1
[% USE ColumnsSettings %]
2
2
3
<script type="text/javascript">
3
<script type="text/javascript">
4
function KohaTable(selector, dt_parameters, columns_settings) {
4
function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
5
    var id = 0;
5
    var id = 0;
6
    var hidden_ids = [];
6
    var hidden_ids = [];
7
    var included_ids = [];
7
    var included_ids = [];
Lines 25-36 function KohaTable(selector, dt_parameters, columns_settings) { Link Here
25
            text: _("Column visibility"),
25
            text: _("Column visibility"),
26
        }
26
        }
27
    ];
27
    ];
28
    var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
28
29
    var table = $('#' + id_selector + ' table');
30
    if ( add_filters ) {
31
        // Duplicate the table header row for columnFilter
32
        thead_row = table.find('thead tr');
33
        clone = thead_row.clone().addClass('filters_row');
34
        clone.find("th.NoSort").html('');
35
        thead_row.before(clone);
36
    }
37
38
    table.dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters));
29
39
30
    $(hidden_ids).each(function(index, value) {
40
    $(hidden_ids).each(function(index, value) {
31
        table.fnSetColumnVis( value, false );
41
        table.fnSetColumnVis( value, false );
32
    });
42
    });
33
43
44
    if ( add_filters ) {
45
        // show a link to activate filtering
46
        link = $('<a>')
47
            .attr('href', '#')
48
            .attr('id', id_selector + '_activate_filters');
49
        $("." + id_selector + "_table_controls").prepend(link);
50
        deactivate_filters(id_selector);
51
    }
52
34
    return table;
53
    return table;
35
}
54
}
36
55
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-69 / +7 lines)
Lines 1031-1121 Link Here
1031
    [% INCLUDE 'datatables.inc' %]
1031
    [% INCLUDE 'datatables.inc' %]
1032
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter_[% KOHA_VERSION %].js"></script>
1032
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.columnFilter_[% KOHA_VERSION %].js"></script>
1033
    [% INCLUDE 'browser-strings.inc' %]
1033
    [% INCLUDE 'browser-strings.inc' %]
1034
    [% INCLUDE 'columns_settings.inc' %]
1034
    <script type="text/javascript" src="[% interface %]/js/browser_[% KOHA_VERSION %].js"></script>
1035
    <script type="text/javascript" src="[% interface %]/js/browser_[% KOHA_VERSION %].js"></script>
1036
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/table_filters_[% KOHA_VERSION %].js"></script>
1035
    <script type="text/javascript">
1037
    <script type="text/javascript">
1036
        var browser = KOHA.browser('[% searchid %]', parseInt(biblionumber, 10));
1038
        var browser = KOHA.browser('[% searchid %]', parseInt(biblionumber, 10));
1037
        browser.show();
1039
        browser.show();
1038
1040
1039
        function activate_filters(id) {
1040
            var table = $("#" + id + " table");
1041
            if (table.length == 1) {
1042
                filters_row = table.find('thead tr.filters_row');
1043
1044
                var aoColumns = [];
1045
                filters_row.find('th').each(function() {
1046
                    if(this.className === "NoSort"){
1047
                        aoColumns.push(null);
1048
                    } else {
1049
                        aoColumns.push('text');
1050
                    }
1051
                });
1052
1053
                if (table.find('thead tr.columnFilter').length == 0) {
1054
                    table.dataTable().columnFilter({
1055
                        'sPlaceHolder': 'head:after'
1056
                        ,   'aoColumns': aoColumns
1057
                    });
1058
                    filters_row.addClass('columnFilter');
1059
                }
1060
                filters_row.show();
1061
            }
1062
1063
            $('#' + id + '_activate_filters')
1064
                .html('<i class="fa fa-filter"></i> ' + _("Deactivate filters") )
1065
                .unbind('click')
1066
                .click(function() {
1067
                    deactivate_filters(id);
1068
                    return false;
1069
                });
1070
        }
1071
1072
        function deactivate_filters(id) {
1073
            filters_row = $("#" + id + " table").find('thead tr.filters_row');
1074
1075
            filters_row.find('input[type="text"]')
1076
                .val('')            // Empty filter text boxes
1077
                .trigger('keyup')   // Filter (display all rows)
1078
                .trigger('blur');   // Reset value to the column name
1079
            filters_row.hide();
1080
1081
            $('#' + id + '_activate_filters')
1082
                .html('<i class="fa fa-filter"></i> ' + _("Activate filters") )
1083
                .unbind('click')
1084
                .click(function() {
1085
                    activate_filters(id);
1086
                    return false;
1087
                });
1088
        }
1089
1090
        $(document).ready(function() {
1041
        $(document).ready(function() {
1091
            var ids = ['holdings', 'otherholdings'];
1042
            var ids = ['holdings', 'otherholdings'];
1043
1092
            for (var i in ids) {
1044
            for (var i in ids) {
1093
                var id = ids[i];
1045
                var id = ids[i];
1094
                var table = $('#' + id + ' table');
1046
                var dt_parameters = {
1095
1096
                // Duplicate the table header row for columnFilter
1097
                thead_row = table.find('thead tr');
1098
                clone = thead_row.clone().addClass('filters_row');
1099
                clone.find("th.NoSort").html('');
1100
                thead_row.before(clone);
1101
1102
                // Enable sorting
1103
                table.dataTable($.extend(true, {}, dataTablesDefaults, {
1104
                    'sDom': 't',
1047
                    'sDom': 't',
1105
                    'bPaginate': false,
1048
                    'bPaginate': false,
1106
                    'bAutoWidth': false,
1049
                    'bAutoWidth': false,
1107
                    "aoColumnDefs": [
1050
                    "aoColumnDefs": [
1108
                        { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }
1051
                        { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }
1109
                    ]
1052
                    ]
1110
                }));
1053
                };
1111
1054
                var table = KohaTable(id, dt_parameters, null, 'with_filters');
1112
                // Show a link to activate filtering
1113
                link = $('<a>')
1114
                    .attr('href', '#')
1115
                    .attr('id', id + '_activate_filters');
1116
                $("." + id + "_table_controls").prepend(link);
1117
                deactivate_filters(id);
1118
            }
1055
            }
1056
1119
            [% IF Koha.Preference('AcquisitionDetails') %]
1057
            [% IF Koha.Preference('AcquisitionDetails') %]
1120
                $("#orders").dataTable($.extend(true, {}, dataTablesDefaults, {
1058
                $("#orders").dataTable($.extend(true, {}, dataTablesDefaults, {
1121
                    'sDom': 't',
1059
                    'sDom': 't',
(-)a/koha-tmpl/intranet-tmpl/prog/js/table_filters.js (-1 / +50 lines)
Line 0 Link Here
0
- 
1
function activate_filters(id) {
2
    var table = $("#" + id + " table");
3
    if (table.length == 1) {
4
        filters_row = table.find('thead tr.filters_row');
5
6
        var aoColumns = [];
7
        filters_row.find('th').each(function() {
8
            if(this.className === "NoSort"){
9
                aoColumns.push(null);
10
            } else {
11
                aoColumns.push('text');
12
            }
13
        });
14
15
        if (table.find('thead tr.columnFilter').length == 0) {
16
            table.dataTable().columnFilter({
17
                'sPlaceHolder': 'head:after'
18
                ,   'aoColumns': aoColumns
19
            });
20
            filters_row.addClass('columnFilter');
21
        }
22
        filters_row.show();
23
    }
24
25
    $('#' + id + '_activate_filters')
26
        .html('<i class="fa fa-filter"></i> ' + _("Deactivate filters") )
27
        .unbind('click')
28
        .click(function() {
29
            deactivate_filters(id);
30
            return false;
31
        });
32
}
33
34
function deactivate_filters(id) {
35
    filters_row = $("#" + id + " table").find('thead tr.filters_row');
36
37
    filters_row.find('input[type="text"]')
38
        .val('')            // Empty filter text boxes
39
        .trigger('keyup')   // Filter (display all rows)
40
        .trigger('blur');   // Reset value to the column name
41
    filters_row.hide();
42
43
    $('#' + id + '_activate_filters')
44
        .html('<i class="fa fa-filter"></i> ' + _("Activate filters") )
45
        .unbind('click')
46
        .click(function() {
47
            activate_filters(id);
48
            return false;
49
        });
50
}

Return to bug 9573