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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc (-1 / +1 lines)
Lines 8-14 Link Here
8
[%- biblioitem = item.biblioitem -%]
8
[%- biblioitem = item.biblioitem -%]
9
[
9
[
10
"[% FILTER escape_quotes = replace('"', '\"') ~%]
10
"[% FILTER escape_quotes = replace('"', '\"') ~%]
11
    <input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" />
11
    <input type="checkbox" name="itemnumber" value="[% item.itemnumber | html %]" data-itemnumber="[% item.itemnumber | html %]" id="[% item.itemnumber | html %]" />
12
[%~ END %]",
12
[%~ END %]",
13
"[% FILTER escape_quotes ~%]
13
"[% FILTER escape_quotes ~%]
14
    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]" title="Go to record detail page">[% INCLUDE 'biblio-title.inc' | trim | collapse %]</a
14
    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]" title="Go to record detail page">[% INCLUDE 'biblio-title.inc' | trim | collapse %]</a
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt (-49 / +6 lines)
Lines 430-436 Link Here
430
        }
430
        }
431
431
432
        function exportItems(format) {
432
        function exportItems(format) {
433
            let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || [];
433
            var the_table = $("#results").DataTable();
434
            var item_search_selections = the_table.select.cumulative().rows;
434
            if (item_search_selections.length > 0) {
435
            if (item_search_selections.length > 0) {
435
            var href = '/cgi-bin/koha/catalogue/item-export.pl?format=' + format;
436
            var href = '/cgi-bin/koha/catalogue/item-export.pl?format=' + format;
436
                href += '&itemnumber=' + Array.from( item_search_selections ).join('&itemnumber=');
437
                href += '&itemnumber=' + Array.from( item_search_selections ).join('&itemnumber=');
Lines 442-460 Link Here
442
            }
443
            }
443
        }
444
        }
444
445
445
        function prepSelections(){
446
            let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || [];
447
            if( item_search_selections.length > 0 ){
448
                showItemSelections( item_search_selections.length );
449
                $("#results input[type='checkbox']").each(function(){
450
                    var itemnumber = $(this).val();
451
                    if( item_search_selections.indexOf( itemnumber ) >= 0 ){
452
                        $(this).prop("checked", true );
453
                    }
454
                });
455
            }
456
        }
457
458
        function getParams($form) {
446
        function getParams($form) {
459
            var params = [];
447
            var params = [];
460
            $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
448
            $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() {
Lines 649-654 Link Here
649
                "destroy": true,
637
                "destroy": true,
650
                "serverSide": true,
638
                "serverSide": true,
651
                "processing": true,
639
                "processing": true,
640
                "select": { "style": "multi", "selector": "td:first-child" },
652
                "ajax": {
641
                "ajax": {
653
                    url: '/cgi-bin/koha/catalogue/itemsearch.pl',
642
                    url: '/cgi-bin/koha/catalogue/itemsearch.pl',
654
                    data: function ( d ) {
643
                    data: function ( d ) {
Lines 692-706 Link Here
692
                    { 'name': 'date_due' },
681
                    { 'name': 'date_due' },
693
                    { 'name': 'actions', 'orderable': false, searchable: false, }
682
                    { 'name': 'actions', 'orderable': false, searchable: false, }
694
                ],
683
                ],
684
                "rowId": [6],
695
                "pagingType": "full_numbers",
685
                "pagingType": "full_numbers",
696
                "drawCallback": function( settings ) {
697
                    prepSelections();
698
                },
699
                fixedHeader: false // There is a bug on this view
686
                fixedHeader: false // There is a bug on this view
700
            }, table_settings, true, null, filters_options );
687
            }, table_settings, true, null, filters_options );
701
688
702
            $('#results').on('draw.dt', function (e, settings) {
689
            $('#results').on('draw.dt', function (e, settings) {
703
                prepSelections();
704
                $('[data-bs-toggle="tooltip"]').tooltip();
690
                $('[data-bs-toggle="tooltip"]').tooltip();
705
            });
691
            });
706
        }
692
        }
Lines 763-798 Link Here
763
                });
749
                });
764
            });
750
            });
765
751
766
            $("body").on("click", "#clear-row-selection", function(e){
767
                e.preventDefault();
768
                $("#results input[type='checkbox']").prop("checked" ,false ).change();
769
                localStorage.removeItem("item_search_selections");
770
                showItemSelections( 0 );
771
            });
772
773
            $("body").on('change', '#results input[type="checkbox"]', function() {
774
                let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || [];
775
                var itemnumber = $(this).val();
776
                if( $(this).prop("checked") ){
777
                    item_search_selections.push( $(this).val() );
778
                    localStorage.setItem('item_search_selections', JSON.stringify( item_search_selections ));
779
                    showItemSelections( item_search_selections.length );
780
                } else {
781
                    var filtered = item_search_selections.filter(function( value ){
782
                        return value !== itemnumber;
783
                    });
784
                    if( filtered.length > 0 ){
785
                        localStorage.setItem('item_search_selections', JSON.stringify( filtered ));
786
                        item_search_selections = filtered;
787
                        showItemSelections( filtered.length );
788
                    } else {
789
                        item_search_selections = [];
790
                        localStorage.removeItem('item_search_selections');
791
                        showItemSelections( 0 );
792
                    }
793
                }
794
            });
795
796
            $("body").on("click", "#csvExportLink", function(e){
752
            $("body").on("click", "#csvExportLink", function(e){
797
                e.preventDefault();
753
                e.preventDefault();
798
                exportItems('csv');
754
                exportItems('csv');
Lines 822-828 Link Here
822
                    .attr("name", "del")
778
                    .attr("name", "del")
823
                    .attr("id", "batch_mod_del")
779
                    .attr("id", "batch_mod_del")
824
                );
780
                );
825
                let item_search_selections = JSON.parse( localStorage.getItem("item_search_selections") ) || [];
781
                var the_table = $("#results").DataTable();
782
                var item_search_selections = the_table.select.cumulative().rows;
826
                // Populate batch forms with itemnumbers in local storage
783
                // Populate batch forms with itemnumbers in local storage
827
                for (let item of item_search_selections){
784
                for (let item of item_search_selections){
828
                    var field = $("<input>").attr("type","hidden")
785
                    var field = $("<input>").attr("type","hidden")
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-2 / +16 lines)
Lines 38-43 var dataTablesDefaults = { Link Here
38
    },
38
    },
39
    dom: '<"dt-info"i><"top pager"<"table_entries"lp><"table_controls"fB>>tr<"bottom pager"ip>',
39
    dom: '<"dt-info"i><"top pager"<"table_entries"lp><"table_controls"fB>>tr<"bottom pager"ip>',
40
    buttons: [
40
    buttons: [
41
        "selectNone",
41
        {
42
        {
42
            fade: 100,
43
            fade: 100,
43
            className: "dt_button_clear_filter",
44
            className: "dt_button_clear_filter",
Lines 75-81 var dataTablesDefaults = { Link Here
75
    },
76
    },
76
};
77
};
77
DataTable.defaults.column.orderSequence = ["asc", "desc"];
78
DataTable.defaults.column.orderSequence = ["asc", "desc"];
78
79
//select: { style: 'multi',selector: 'td:first-child' },
79
function toggledClearFilter(searchText, tableId) {
80
function toggledClearFilter(searchText, tableId) {
80
    let clear_filter_button = $("#" + tableId + "_wrapper").find(
81
    let clear_filter_button = $("#" + tableId + "_wrapper").find(
81
        ".dt_button_clear_filter"
82
        ".dt_button_clear_filter"
Lines 837-842 function _dt_buttons(params) { Link Here
837
                format: export_format_spreadsheet,
838
                format: export_format_spreadsheet,
838
            },
839
            },
839
        },
840
        },
841
        {
842
            extend: "excelHtml5",
843
            text: _("Export selected to excel"),
844
            exportOptions: {
845
                columns: exportColumns,
846
                format: export_format_spreadsheet,
847
                //                rows: function(idx, data, node) {
848
                //                    console.log( idx, $(node).find('td:first-child input[type="checkbox"]').is(':checked') );
849
                //                    return $(node).find('td:first-child input[type="checkbox"]').is(':checked');
850
                //                },
851
                modifier: { selected: true },
852
            },
853
        },
840
        {
854
        {
841
            extend: "csvHtml5",
855
            extend: "csvHtml5",
842
            exportOptions: {
856
            exportOptions: {
Lines 875-880 function _dt_buttons(params) { Link Here
875
            node.addClass("disabled");
889
            node.addClass("disabled");
876
        },
890
        },
877
    });
891
    });
892
    buttons.push("selectNone");
878
893
879
    // Retrieving bKohaColumnsUseNames from the options passed to the constructor, not DT's settings
894
    // Retrieving bKohaColumnsUseNames from the options passed to the constructor, not DT's settings
880
    // But ideally should be retrieved using table.data()
895
    // But ideally should be retrieved using table.data()
881
- 

Return to bug 40683