@@ -, +, @@ search results - Perform a search in the catalog - You should see a disabled "Edit" button in the toolbar at the top of the search results table. - Check a single checkbox. The button should become enabled. - Test the "Batch edit" and "Batch delete" menu items. They should work correctly. - Test the "Merge records" item. It should warn you that you must select at least two records. - Check more than one checkbox and test each menu item again. All should work as expected. - Log in to the staff client as a user who does not have edit_catalogue permission. The "Edit" menu should no longer appear on the search results page. --- .../prog/en/modules/catalogue/results.tt | 10 ++++ koha-tmpl/intranet-tmpl/prog/js/pages/results.js | 68 +++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -165,6 +165,16 @@
Z39.50/SRU search
+
+ + +
[% END %] [% IF ( searchdesc ) %] --- a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js +++ a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js @@ -1,4 +1,4 @@ -/* global KOHA biblionumber new_results_browser addMultiple vShelfAdd openWindow search_result SEARCH_RESULTS PREF_AmazonCoverImages PREF_LocalCoverImages PREF_IntranetCoce PREF_CoceProviders CoceHost CoceProviders addRecord delSingleRecord PREF_BrowseResultSelection resetSearchContext addBibToContext delBibToContext getContextBiblioNumbers MSG_NO_ITEM_SELECTED MSG_NO_ITEM_SELECTED holdfor_cardnumber holdforclub strQuery MSG_NON_RESERVES_SELECTED PREF_NotHighlightedWords PLACE_HOLD */ +/* global KOHA biblionumber new_results_browser addMultiple vShelfAdd openWindow search_result SEARCH_RESULTS PREF_AmazonCoverImages PREF_LocalCoverImages PREF_IntranetCoce PREF_CoceProviders CoceHost CoceProviders addRecord delSingleRecord PREF_BrowseResultSelection resetSearchContext addBibToContext delBibToContext getContextBiblioNumbers MSG_NO_ITEM_SELECTED MSG_NO_ITEM_SELECTED holdfor_cardnumber holdforclub strQuery MSG_NON_RESERVES_SELECTED PREF_NotHighlightedWords PLACE_HOLD _ */ if( PREF_AmazonCoverImages ){ $(window).load(function() { @@ -152,6 +152,11 @@ $(document).ready(function() { } $(".selection").change(function(){ + if( $(".selection:checked").length > 0 ){ + toggleBatchOp( true ); + } else { + toggleBatchOp( false ); + } if ( $(this).is(':checked') == true ) { addBibToContext( $(this).val() ); } else { @@ -170,6 +175,16 @@ $(document).ready(function() { } } }); + + if( $(".selection:checked") > 0 ){ + toggleBatchOp( true ); + } + + $(".results_batch_op").on("click", function(e){ + e.preventDefault(); + var op = $(this).data("op"); + resultsBatchProcess( op ); + }); }); @@ -306,3 +321,54 @@ function verify_images() { } }); } + +function toggleBatchOp( b ){ + var results_batch_ops = $("#results_batch_ops"); + if( b ){ + results_batch_ops.removeClass("disabled"); + } else { + results_batch_ops.addClass("disabled"); + } +} + +function resultsBatchProcess( op ){ + var selected = $(".selection:checked"); + var params = []; + var url = ""; + if( op == "edit" ){ + // batch edit selected records + if ( selected.length < 1 ){ + alert( _("You must select at least one record") ); + } else { + selected.each(function() { + params.push( $(this).val() ); + }); + url = "/cgi-bin/koha/tools/batch_record_modification.pl?op=list&bib_list=" + params.join("/"); + location.href = url; + } + } else if( op == "delete" ){ + // batch delete selected records + if ( selected.length < 1) { + alert( _("You must select at least one record") ); + } else { + selected.each(function() { + params.push( $(this).val() ); + }); + url = "/cgi-bin/koha/tools/batch_delete_records.pl?op=list&type=biblio&bib_list=" + params.join("/"); + location.href = url; + } + } else if( op == "merge" ){ + // merge selected records + if ( selected.length < 2) { + alert( _("At least two records must be selected for merging") ); + } else { + selected.each(function() { + params.push('biblionumber=' + $(this).val()); + }); + url = "/cgi-bin/koha/cataloguing/merge.pl?" + params.join("&"); + location.href = url; + } + } else { + return false; + } +} --