Bug 19290: Browse selected bibliographic records - Staff interface
This patch adds the same feature as bug 10858 for the OPAC interface: after a search, librarians will be able to browse selected results. The results can be selected from several pages. By extension it is possible to add results from several pages to a list or the cart. When at least one result is selected, a new "Browse selected records" button becomes usable and change the behaviour of the existing browser. The whole feature can be turned off with the pref BrowseResultSelection. Test plan: - Launch a search (on the staff interface) - Check some biblios - Go on another page - Check some biblios - Come back to a page you already check results and confirm that they are still checked - Click on the "Browse selected records" button - Check that you are able to browse results you had checked. You can also: - add them to the cart - add them to a list QA note: the browsers at the OPAC and the one at the staff interface are completely different That's why the code is not mimicking what has been done on bug 10858. The behaviour must stay the same anyway. Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
af1a8c5a78
commit
c9a7b6742b
11 changed files with 183 additions and 29 deletions
1
installer/data/mysql/atomicupdate/bug_19290.sql
Normal file
1
installer/data/mysql/atomicupdate/bug_19290.sql
Normal file
|
@ -0,0 +1 @@
|
|||
INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('BrowseResultSelection','0',NULL,'Enable/Disable browsing search results fromt the bibliographic record detail page in staff client','YesNo');
|
|
@ -92,6 +92,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
|
|||
('BorrowersTitles','Mr|Mrs|Miss|Ms',NULL,'Define appropriate Titles for patrons','free'),
|
||||
('BorrowerUnwantedField','',NULL,'Name the fields you don\'t need to store for a patron\'s account','free'),
|
||||
('BranchTransferLimitsType','ccode','itemtype|ccode','When using branch transfer limits, choose whether to limit by itemtype or collection code.','Choice'),
|
||||
('BrowseResultSelection','0',NULL,'Enable/Disable browsing search results fromt the bibliographic record detail page in staff client','YesNo'),
|
||||
('CalculateFinesOnReturn','1','','Switch to control if overdue fines are calculated on return or not','YesNo'),
|
||||
('CalendarFirstDayOfWeek','0','0|1|2|3|4|5|6','Select the first day of week to use in the calendar.','Choice'),
|
||||
('canreservefromotherbranches','1','','With Independent branches on, can a user from one library place a hold on an item from another library','YesNo'),
|
||||
|
|
|
@ -102,7 +102,7 @@ KOHA.browser = function (searchid, biblionumber) {
|
|||
} else {
|
||||
nextbutton = '<a href="#" id="browse-next" class="browse-button">' + BROWSER_NEXT + ' »</a>';
|
||||
}
|
||||
$('#menu').before('<div class="browse-controls"><div class="browse-controls-inner"><div class="browse-label"><a href="' + searchURL + '" id="browse-return-to-results" class="browse-button">' + BROWSER_RETURN_TO_SEARCH + '</a></div><div class="browse-prev-next">' + prevbutton + nextbutton + '</div></div></div>');
|
||||
$('#menu').before('<div class="browse-controls"><div class="browse-controls-inner"><div class="browse-label"><a href="' + searchURL + '" id="browse-return-to-results" class="browse-button searchwithcontext">' + BROWSER_RETURN_TO_SEARCH + '</a></div><div class="browse-prev-next">' + prevbutton + nextbutton + '</div></div></div>');
|
||||
$('a#browse-previous').click(function (ev) {
|
||||
ev.preventDefault();
|
||||
browseRecords(-1);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.validate.min_[% KOHA_VERSION %].js"></script>
|
||||
<!-- koha core js -->
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/staff-global_[% KOHA_VERSION %].js"></script>
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/commons_[% KOHA_VERSION %].js"></script>
|
||||
|
||||
[% INCLUDE 'validator-strings.inc' %]
|
||||
[% IF ( IntranetUserJS ) %]
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
[% IF ( PAGE_NUMBERS ) %]<nav><ul class="pagination">
|
||||
[% IF ( previous_page_offset.defined ) %]
|
||||
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">First</a></li>
|
||||
<li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">First</a></li>
|
||||
<!-- Row of numbers corresponding to search result pages -->
|
||||
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% previous_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]"><< Previous</a></li>
|
||||
<li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% previous_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]"><< Previous</a></li>
|
||||
[% END %]
|
||||
[% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %]
|
||||
[% IF ( PAGE_NUMBER.highlight ) %]
|
||||
<li class="active"><span>[% PAGE_NUMBER.pg %]</span></li>
|
||||
[% ELSE %]
|
||||
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg %]</a></li>
|
||||
<li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg %]</a></li>
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% IF ( next_page_offset ) %]
|
||||
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% next_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">Next >></a></li>
|
||||
<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% last_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">Last</a></li>
|
||||
<li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% next_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">Next >></a></li>
|
||||
<li><a class="nav" href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% last_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">Last</a></li>
|
||||
[% END %]
|
||||
</ul></nav>[% END %]
|
||||
|
|
|
@ -78,6 +78,13 @@ Searching:
|
|||
yes: Keep
|
||||
no: "Don't keep"
|
||||
- patron search history in the staff client.
|
||||
-
|
||||
- pref: BrowseResultSelection
|
||||
default: 0
|
||||
choices:
|
||||
yes: Enable
|
||||
no: Disable
|
||||
- "browsing search results fromt the bibliographic record detail page in staff client."
|
||||
Search Form:
|
||||
-
|
||||
- Load the unlogged history to the next user.
|
||||
|
|
|
@ -1035,7 +1035,8 @@
|
|||
<script type="text/javascript" src="[% interface %]/js/browser_[% KOHA_VERSION %].js"></script>
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/js/table_filters_[% KOHA_VERSION %].js"></script>
|
||||
<script type="text/javascript">
|
||||
var browser = KOHA.browser('[% searchid %]', parseInt(biblionumber, 10));
|
||||
var browser;
|
||||
browser = KOHA.browser('[% searchid %]', parseInt(biblionumber, 10));
|
||||
browser.show();
|
||||
|
||||
$(document).ready(function() {
|
||||
|
|
|
@ -135,6 +135,9 @@
|
|||
<div id="placeholdc" class="btn-group"><a class="btn btn-default btn-xs placehold" href="#"><i class="fa fa-sticky-note-o"></i> Place hold</a></div>
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% IF Koha.Preference('BrowseResultSelection') %]
|
||||
<div id="browse_selection" class="btn-group"><a class="btn btn-default btn-xs browse_selection" href="#"><i class="fa fa-sticky-note-o"></i> Browse selected records</a></div>
|
||||
[% END %]
|
||||
|
||||
[% IF ( CAN_user_editcatalogue_edit_catalogue ) %] <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>[% END %]
|
||||
|
||||
|
@ -621,6 +624,7 @@
|
|||
[% INCLUDE 'browser-strings.inc' %]
|
||||
<script type="text/javascript" src="[% interface %]/js/browser_[% KOHA_VERSION %].js"></script>
|
||||
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat_[% KOHA_VERSION %].js"></script>
|
||||
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min_[% KOHA_VERSION %].js"></script>
|
||||
<script type="text/javascript">
|
||||
var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
|
||||
var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be placed on hold.");
|
||||
|
@ -652,15 +656,13 @@
|
|||
|
||||
$("#cartsubmit").click(function(e){
|
||||
e.preventDefault();
|
||||
var checkboxes = $("#searchresults").find(":checkbox");
|
||||
addMultiple(checkboxes);
|
||||
addMultiple();
|
||||
});
|
||||
|
||||
$(".addtolist").on("click",function(e){
|
||||
e.preventDefault();
|
||||
var shelfnumber = $(this).data("shelfnumber");
|
||||
var checkboxes = $("#searchresults").find(":checkbox");
|
||||
var vshelf = vShelfAdd(checkboxes);
|
||||
var vshelf = vShelfAdd();
|
||||
if( vshelf ){
|
||||
if( $(this).hasClass("morelists") ){
|
||||
openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?' + vshelf);
|
||||
|
@ -677,6 +679,11 @@
|
|||
return false;
|
||||
});
|
||||
|
||||
$("#searchheader").on("click", ".browse_selection", function(){
|
||||
browse_selection();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#searchheader").on("click",".placehold", function(){
|
||||
$("#holdFor").val("");
|
||||
placeHold();
|
||||
|
@ -767,6 +774,29 @@
|
|||
delSingleRecord(biblionumber);
|
||||
});
|
||||
|
||||
[% UNLESS Koha.Preference('BrowseResultSelection') %]
|
||||
resetSearchContext();
|
||||
[% END %]
|
||||
$(".selection").change(function(){
|
||||
if ( $(this).is(':checked') == true ) {
|
||||
addBibToContext( $(this).val() );
|
||||
} else {
|
||||
delBibToContext( $(this).val() );
|
||||
}
|
||||
});
|
||||
$("#bookbag_form").ready(function(){
|
||||
$("#bookbag_form").unCheckCheckboxes();
|
||||
var bibnums = getContextBiblioNumbers();
|
||||
if (bibnums) {
|
||||
for (var i=0; i < bibnums.length; i++) {
|
||||
var id = ('#bib' + bibnums[i]);
|
||||
if ($(id)) {
|
||||
$(id).attr('checked', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -789,10 +819,18 @@
|
|||
[% END %]
|
||||
|
||||
function selectAll () {
|
||||
$(".selection").prop("checked", true);
|
||||
$("#bookbag_form").checkCheckboxes();
|
||||
$("#bookbag_form").find("input[type='checkbox'][name='biblionumber']").each(function(){
|
||||
$(this).change();
|
||||
} );
|
||||
return false;
|
||||
}
|
||||
function clearAll () {
|
||||
$(".selection").prop("checked", false);
|
||||
$("#bookbag_form").unCheckCheckboxes();
|
||||
$("#bookbag_form").find("input[type='checkbox'][name='biblionumber']").each(function(){
|
||||
$(this).change();
|
||||
} );
|
||||
return false;
|
||||
}
|
||||
function placeHold () {
|
||||
var checkedItems = $(".selection:checked");
|
||||
|
@ -825,6 +863,18 @@
|
|||
$("#placeholdc").html("<a class=\"btn btn-default btn-xs placehold\" href=\"#\"><i class=\"fa fa-sticky-note-o\"></i> "+_("Place hold")+"</a>");
|
||||
}
|
||||
|
||||
function browse_selection () {
|
||||
var bibnums = getContextBiblioNumbers();
|
||||
if ( bibnums && bibnums.length > 0 ) {
|
||||
var browser = KOHA.browser('', parseInt('[% biblionumber %]', 10));
|
||||
browser.create(1, '[% query_cgi %]', '[% limit_cgi | uri %]','[% sort_cgi | uri %]', bibnums, bibnums.length);
|
||||
window.location = '/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + bibnums[0] + '&searchid='+browser.searchid;
|
||||
} else {
|
||||
alert(MSG_NO_ITEM_SELECTED);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function addToList () {
|
||||
var checkedItems = $(".selection:checked");
|
||||
if ($(checkedItems).size() == 0) {
|
||||
|
|
|
@ -157,17 +157,31 @@ function SelectAll(){
|
|||
|
||||
function addMultiple(biblist){
|
||||
var c_value = "";
|
||||
if(biblist.length > 0) {
|
||||
if( biblist && biblist.length > 0 ) {
|
||||
for (var i=0; i < biblist.length; i++) {
|
||||
if (biblist[i].checked) {
|
||||
c_value = c_value + biblist[i].value + "/";
|
||||
}
|
||||
}
|
||||
addSelRecords(c_value);
|
||||
} else {
|
||||
c_value = c_value + biblist.value + "/";
|
||||
addSelRecords(c_value);
|
||||
var bibnums = getContextBiblioNumbers();
|
||||
if ( bibnums.length > 0 ) {
|
||||
for ( var i = 0 ; i < bibnums.length ; i++ ) {
|
||||
c_value = c_value + bibnums[i] + "/";
|
||||
}
|
||||
} else {
|
||||
if(document.bookbag_form.biblionumber.length > 0) {
|
||||
for (var i=0; i < document.bookbag_form.biblionumber.length; i++) {
|
||||
if (document.bookbag_form.biblionumber[i].checked) {
|
||||
c_value = c_value + document.bookbag_form.biblionumber[i].value + "/";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c_value = c_value + document.bookbag_form.biblionumber.value + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
addSelRecords(c_value);
|
||||
}
|
||||
|
||||
function addSelRecords(valSel) { // function for adding a selection of biblios to the basket
|
||||
|
@ -421,20 +435,24 @@ function addSelToShelf() {
|
|||
/// vShelfAdd() builds url string for multiple-biblio adds.
|
||||
|
||||
function vShelfAdd(biblist) {
|
||||
bibs = [];
|
||||
if(biblist.length > 0) {
|
||||
for (var i=0; i < biblist.length; i++) {
|
||||
if (biblist[i].checked) {
|
||||
bibs.push("biblionumber=" + biblist[i].value);
|
||||
}
|
||||
}
|
||||
if (bibs.length === 0) { showListsUpdate(MSG_NO_RECORD_SELECTED); }
|
||||
return bibs.join("&");
|
||||
} else {
|
||||
if (biblist.checked) {
|
||||
return "biblionumber=" + biblist.value;
|
||||
var bibs = new Array;
|
||||
if( biblist && biblist.length > 0 ) {
|
||||
for (var i=0; i < biblist.length; i++) {
|
||||
if (biblist[i].checked) {
|
||||
bibs.push("biblionumber=" + biblist[i].value);
|
||||
}
|
||||
}
|
||||
if (bibs.length === 0) { showListsUpdate(MSG_NO_RECORD_SELECTED); }
|
||||
return bibs.join("&");
|
||||
} else {
|
||||
var bibnums = getContextBiblioNumbers();
|
||||
if ( bibnums.length > 0 ) {
|
||||
for ( var i = 0 ; i < bibnums.length ; i++ ) {
|
||||
bibs.push("biblionumber=" + bibnums[i]);
|
||||
}
|
||||
return bibs.join("&");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showCart(){
|
||||
|
|
|
@ -71,6 +71,7 @@ $(document).ready(function(){
|
|||
$("#bookbag_form").checkCheckboxes("*", true).each(
|
||||
function() {
|
||||
selRecord(this.value,true);
|
||||
$(this).change();
|
||||
}
|
||||
);
|
||||
return false;
|
||||
|
@ -80,6 +81,7 @@ $(document).ready(function(){
|
|||
$("#bookbag_form").unCheckCheckboxes("*",true).each(
|
||||
function() {
|
||||
selRecord(this.value,false);
|
||||
$(this).change();
|
||||
}
|
||||
);
|
||||
return false;
|
||||
|
|
73
koha-tmpl/intranet-tmpl/prog/js/commons.js
Normal file
73
koha-tmpl/intranet-tmpl/prog/js/commons.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Extends jQuery API
|
||||
jQuery.extend({uniqueArray:function(array){
|
||||
return $.grep(array, function(el, index) {
|
||||
return index === $.inArray(el, array);
|
||||
});
|
||||
}});
|
||||
|
||||
function removeByValue(arr, val) {
|
||||
for(var i=0; i<arr.length; i++) {
|
||||
if(arr[i] == val) {
|
||||
arr.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function paramOfUrl( url, param ) {
|
||||
param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
||||
var regexS = "[\\?&]"+param+"=([^&#]*)";
|
||||
var regex = new RegExp( regexS );
|
||||
var results = regex.exec( url );
|
||||
if( results == null ) {
|
||||
return "";
|
||||
} else {
|
||||
return results[1];
|
||||
}
|
||||
}
|
||||
|
||||
function addBibToContext( bibnum ) {
|
||||
bibnum = parseInt(bibnum, 10);
|
||||
var bibnums = getContextBiblioNumbers();
|
||||
bibnums.push(bibnum);
|
||||
setContextBiblioNumbers( bibnums );
|
||||
setContextBiblioNumbers( $.uniqueArray( bibnums ) );
|
||||
}
|
||||
|
||||
function delBibToContext( bibnum ) {
|
||||
var bibnums = getContextBiblioNumbers();
|
||||
removeByValue( bibnums, bibnum );
|
||||
setContextBiblioNumbers( $.uniqueArray( bibnums ) );
|
||||
}
|
||||
|
||||
function setContextBiblioNumbers( bibnums ) {
|
||||
$.cookie('bibs_selected', JSON.stringify( bibnums ));
|
||||
}
|
||||
|
||||
function getContextBiblioNumbers() {
|
||||
var r = $.cookie('bibs_selected');
|
||||
if ( r ) {
|
||||
return JSON.parse(r);
|
||||
}
|
||||
r = new Array();
|
||||
return r;
|
||||
}
|
||||
|
||||
function resetSearchContext() {
|
||||
setContextBiblioNumbers( new Array() );
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
// forms with action leading to search
|
||||
$("form[action*='search.pl']").submit(function(){
|
||||
resetSearchContext();
|
||||
});
|
||||
// any link to launch a search except navigation links
|
||||
$("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){
|
||||
resetSearchContext();
|
||||
});
|
||||
// any link to a detail page from the results page.
|
||||
$("#bookbag_form a[href*='detail.pl?']").click(function(){
|
||||
resetSearchContext();
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue