|
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") |