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

(-)a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.columnFilter.js (-29 / +39 lines)
Lines 523-539 Link Here
523
            var sFilterRow = "tr"; //Before fix for ColVis
523
            var sFilterRow = "tr"; //Before fix for ColVis
524
524
525
            if (properties.sPlaceHolder == "head:after") {
525
            if (properties.sPlaceHolder == "head:after") {
526
                var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
526
527
                //tr.appendTo($(oTable.fnSettings().nTHead));
527
                if (!properties.bFiltersAlreadyActivated) {
528
                if (oTable.fnSettings().bSortCellsTop) {
528
                    var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
529
                    tr.prependTo($(oTable.fnSettings().nTHead));
529
                    //tr.appendTo($(oTable.fnSettings().nTHead));
530
                    //tr.appendTo($("thead", oTable));
530
                    if (oTable.fnSettings().bSortCellsTop) {
531
                    aoFilterCells = oTable.fnSettings().aoHeader[1];
531
                        tr.prependTo($(oTable.fnSettings().nTHead));
532
                }
532
                        //tr.appendTo($("thead", oTable));
533
                else {
533
                        aoFilterCells = oTable.fnSettings().aoHeader[1];
534
                    tr.appendTo($(oTable.fnSettings().nTHead));
534
                    }
535
                    //tr.prependTo($("thead", oTable));
535
                    else {
536
                    aoFilterCells = oTable.fnSettings().aoHeader[0];
536
                        tr.appendTo($(oTable.fnSettings().nTHead));
537
                        //tr.prependTo($("thead", oTable));
538
                        aoFilterCells = oTable.fnSettings().aoHeader[0];
539
                    }
537
                }
540
                }
538
541
539
                sFilterRow = "tr:last";
542
                sFilterRow = "tr:last";
Lines 541-567 Link Here
541
544
542
            } else if (properties.sPlaceHolder == "head:before") {
545
            } else if (properties.sPlaceHolder == "head:before") {
543
546
544
                if (oTable.fnSettings().bSortCellsTop) {
547
                if (!properties.bFiltersAlreadyActivated) {
545
                    var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
548
                    if (oTable.fnSettings().bSortCellsTop) {
546
                    tr.appendTo($(oTable.fnSettings().nTHead));
549
                        var tr = $("tr:first", oTable.fnSettings().nTHead).detach();
547
                    aoFilterCells = oTable.fnSettings().aoHeader[1];
550
                        tr.appendTo($(oTable.fnSettings().nTHead));
548
                } else {
551
                        aoFilterCells = oTable.fnSettings().aoHeader[1];
549
                    aoFilterCells = oTable.fnSettings().aoHeader[0];
552
                    } else {
553
                        aoFilterCells = oTable.fnSettings().aoHeader[0];
554
                    }
555
                    /*else {
556
                    //tr.prependTo($("thead", oTable));
557
                    sFilterRow = "tr:first";
558
                    }*/
550
                }
559
                }
551
                /*else {
552
                //tr.prependTo($("thead", oTable));
553
                sFilterRow = "tr:first";
554
                }*/
555
560
556
                sFilterRow = "tr:first";
561
                sFilterRow = "tr:first";
557
558
                oHost = oTable.fnSettings().nTHead;
562
                oHost = oTable.fnSettings().nTHead;
559
563
560
561
            }
564
            }
562
565
563
            //$(sFilterRow + " th", oHost).each(function (index) {//bug with ColVis
566
            $(sFilterRow + " th", oHost).each(function (index) {
564
            $(aoFilterCells).each(function (index) {//fix for ColVis
567
            //$(aoFilterCells).each(function (index) {//fix for ColVis
568
569
                var bHeaderHasInput = $(this).find('input').length;
570
565
                i = index;
571
                i = index;
566
                var aoColumn = { type: "text",
572
                var aoColumn = { type: "text",
567
                    bRegex: false,
573
                    bRegex: false,
Lines 569-584 Link Here
569
                    iMaxLenght: -1,
575
                    iMaxLenght: -1,
570
                    iFilterLength: 0
576
                    iFilterLength: 0
571
                };
577
                };
578
572
                if (properties.aoColumns != null) {
579
                if (properties.aoColumns != null) {
573
                    if (properties.aoColumns.length < i || properties.aoColumns[i] == null)
580
                    if (properties.aoColumns.length < i || properties.aoColumns[i] == null)
574
                        return;
581
                        return;
575
                    aoColumn = properties.aoColumns[i];
582
                    aoColumn = properties.aoColumns[i];
576
                }
583
                }
577
                //label = $(this).text(); //Before fix for ColVis
584
                if (bHeaderHasInput)
578
                label = $($(this)[0].cell).text(); //Fix for ColVis
585
                    label = $(this).find('input').val();
586
                else
587
                    label = $(this).text();
588
                //label = $($(this)[0].cell).text(); //Fix for ColVis
579
                if (aoColumn.sSelector == null) {
589
                if (aoColumn.sSelector == null) {
580
                    //th = $($(this)[0]);//Before fix for ColVis
590
                    th = $($(this)[0]);
581
                    th = $($(this)[0].cell); //Fix for ColVis
591
                    //th = $($(this)[0].cell); //Fix for ColVis
582
                }
592
                }
583
                else {
593
                else {
584
                    th = $(aoColumn.sSelector);
594
                    th = $(aoColumn.sSelector);
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc (-1 / +1 lines)
Lines 216-222 function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { Link Here
216
            // This function can be created separately and used to trigger
216
            // This function can be created separately and used to trigger
217
            // an event after the DataTable has loaded AND column visibility
217
            // an event after the DataTable has loaded AND column visibility
218
            // has been updated according to the table's configuration
218
            // has been updated according to the table's configuration
219
            columnsInit();
219
            columnsInit(this);
220
        }
220
        }
221
    }).columns( hidden_ids ).visible( false );
221
    }).columns( hidden_ids ).visible( false );
222
222
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (+4 lines)
Lines 1990-1995 Note that permanent location is a code, and location may be an authval. Link Here
1990
1990
1991
        });
1991
        });
1992
1992
1993
        function columnsInit(table) {
1994
            activate_filters(table.id, false);
1995
        }
1996
1993
        [% IF found1 && Koha.Preference('RetainCatalogSearchTerms') %]
1997
        [% IF found1 && Koha.Preference('RetainCatalogSearchTerms') %]
1994
            $(document).ready(function() {
1998
            $(document).ready(function() {
1995
                var search_index = localStorage.getItem("cat_search_pulldown_selection");
1999
                var search_index = localStorage.getItem("cat_search_pulldown_selection");
(-)a/koha-tmpl/intranet-tmpl/prog/js/table_filters.js (-12 / +21 lines)
Lines 1-4 Link Here
1
function activate_filters(id) {
1
function activate_filters(id, bShowFilters) {
2
    var table = $("#" + id );
2
    var table = $("#" + id );
3
    if (table.length == 1) {
3
    if (table.length == 1) {
4
        filters_row = table.find('thead tr.filters_row');
4
        filters_row = table.find('thead tr.filters_row');
Lines 16-34 function activate_filters(id) { Link Here
16
            table.dataTable().columnFilter({
16
            table.dataTable().columnFilter({
17
                'sPlaceHolder': 'head:after'
17
                'sPlaceHolder': 'head:after'
18
                ,   'aoColumns': aoColumns
18
                ,   'aoColumns': aoColumns
19
                ,'bFiltersAlreadyActivated': false
19
            });
20
            });
20
            filters_row.addClass('columnFilter');
21
            filters_row.addClass('columnFilter');
22
        } else {
23
            table.dataTable().columnFilter({
24
                'sPlaceHolder': 'head:after'
25
                ,   'aoColumns': aoColumns
26
                ,'bFiltersAlreadyActivated': true
27
            });
21
        }
28
        }
22
        filters_row.show();
23
    }
24
29
25
    $('#' + id + '_activate_filters')
30
        if (bShowFilters) {
26
        .html('<i class="fa fa-filter"></i> ' + __('Deactivate filters') )
31
            filters_row.show();
27
        .unbind('click')
32
28
        .click(function() {
33
            $('#' + id + '_activate_filters')
29
            deactivate_filters(id);
34
                .html('<i class="fa fa-filter"></i> ' + __('Deactivate filters') )
30
            return false;
35
                .unbind('click')
31
        });
36
                .click(function() {
37
                    deactivate_filters(id);
38
                    return false;
39
                });
40
        }
41
    }
32
}
42
}
33
43
34
function deactivate_filters(id) {
44
function deactivate_filters(id) {
Lines 44-50 function deactivate_filters(id) { Link Here
44
        .html('<i class="fa fa-filter"></i> ' + __('Activate filters') )
54
        .html('<i class="fa fa-filter"></i> ' + __('Activate filters') )
45
        .unbind('click')
55
        .unbind('click')
46
        .click(function() {
56
        .click(function() {
47
            activate_filters(id);
57
            activate_filters(id, true);
48
            return false;
58
            return false;
49
        });
59
        });
50
}
60
}
51
- 

Return to bug 32447