Bug 23349: Add batch operations to staff interface catalog search results
This patch adds three new options to the staff interface catalog search results for users with cataloging permission: batch edit, batch delete, and merge. The choices are found in an "Edit" menu which is disabled by default. Checking any boxes in the search results table enables the button. To test, apply the patch and log in to Koha as a user with edit_catalogue permission. - 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. Signed-off-by: Abbey Holt <aholt@dubuque.lib.ia.us> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
c54654c129
commit
743f40a202
2 changed files with 77 additions and 1 deletions
|
@ -165,6 +165,16 @@
|
|||
<div class="btn-group">
|
||||
<a class="btn btn-default btn-xs" id="z3950submit" href="#"><i class="fa fa-search"></i> Z39.50/SRU search</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button type="button" id="results_batch_ops" class="btn btn-default btn-xs dropdown-toggle disabled" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-pencil"></i> Edit <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="results_batch_op" data-op="edit" href="#">Batch edit</a></li>
|
||||
<li><a class="results_batch_op" data-op="delete" href="#">Batch delete</a></li>
|
||||
<li><a class="results_batch_op" data-op="merge" href="#">Merge records</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
[% END %]
|
||||
|
||||
[% IF ( searchdesc ) %]
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue