@@ -, +, @@
- Launch a search at the OPAC
- Check some biblios
- Go on another page
- Check some biblios
- Come back to the first page and check that already checked biblio is
automatically checked.
- Click on the "Browse selected biblios >>" link
- Check that you are able to browse results you had checked.
- check some biblios from several pages
- add them to the cart
- add them to a list
---
.../bootstrap/en/includes/opac-bottom.inc | 4 +-
.../bootstrap/en/includes/page-numbers.inc | 4 +-
.../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 64 +++++++++++---------
.../opac-tmpl/bootstrap/en/modules/opac-results.tt | 55 +++++++++++++++--
koha-tmpl/opac-tmpl/bootstrap/js/basket.js | 42 +++++++++----
koha-tmpl/opac-tmpl/bootstrap/js/commons.js | 69 ++++++++++++++++++++++
.../lib/jquery/plugins/jquery.cookie.min.js | 1 +
opac/opac-detail.pl | 20 ++++++-
8 files changed, 207 insertions(+), 52 deletions(-)
create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/commons.js
create mode 100644 koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.cookie.min.js
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
@@ -83,6 +83,8 @@ $.widget.bridge('uitooltip', $.ui.tooltip);
+
+
--- a/koha-tmpl/opac-tmpl/bootstrap/js/basket.js
+++ a/koha-tmpl/opac-tmpl/bootstrap/js/basket.js
@@ -157,17 +157,25 @@ function SelectAll(){
}
function addMultiple(){
+ var bibnums = getContextBiblioNumbers();
var c_value = "";
- 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 + "/";
- }
+ if ( bibnums.length > 0 ) {
+ for ( var i = 0 ; i < bibnums.length ; i++ ) {
+ c_value = c_value + bibnums[i] + "/";
}
addSelRecords(c_value);
} else {
- c_value = c_value + document.bookbag_form.biblionumber.value + "/";
- addSelRecords(c_value);
+ 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 + "/";
+ }
+ }
+ addSelRecords(c_value);
+ } else {
+ c_value = c_value + document.bookbag_form.biblionumber.value + "/";
+ addSelRecords(c_value);
+ }
}
}
@@ -433,20 +441,28 @@ function addSelToShelf() {
/// vShelfAdd() builds url string for multiple-biblio adds.
function vShelfAdd() {
- bibs= new Array;
+ var bibnums = getContextBiblioNumbers();
+ bibs = new Array;
+ if ( bibnums.length > 0 ) {
+ for ( var i = 0 ; i < bibnums.length ; i++ ) {
+ bibs.push("biblionumber=" + bibnums[i]);
+ }
+ return bibs.join("&");
+ } 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) {
- bibs.push("biblionumber=" + document.bookbag_form.biblionumber[i].value);
- }
+ for (var i=0; i < document.bookbag_form.biblionumber.length; i++) {
+ if (document.bookbag_form.biblionumber[i].checked) {
+ bibs.push("biblionumber=" + document.bookbag_form.biblionumber[i].value);
}
- if (bibs.length == 0) { showListsUpdate(MSG_NO_RECORD_SELECTED); }
+ }
+ if (bibs.length == 0) { showListsUpdate(MSG_NO_RECORD_SELECTED); }
return bibs.join("&");
} else {
if (document.bookbag_form.biblionumber.checked) {
return "biblionumber=" + document.bookbag_form.biblionumber.value;
}
}
+ }
}
function showCart(){
--- a/koha-tmpl/opac-tmpl/bootstrap/js/commons.js
+++ a/koha-tmpl/opac-tmpl/bootstrap/js/commons.js
@@ -0,0 +1,69 @@
+// Extends jQuery API
+// http://www.wskidmore.com/downloads/jquery-uniqueArray.min.js
+jQuery.extend({uniqueArray:function(e){if($.isArray(e)){var c={};var a,b;for(b=0,a=e.length;bparam('busc')) {
push @{$arrParamsBusc{$key}}, uri_unescape($value);
}
}
+
my $searchAgain = 0;
+ my ( $offset, $results_per_page );
+
+ my $bibnums = JSON::from_json( $query->cookie('bibs_selected') || '[]' );
+ if ( scalar( @$bibnums ) ) {
+ $arrParamsBusc{count} = scalar( @$bibnums );
+ $arrParamsBusc{listBiblios} = join ',', @$bibnums;
+ $results_per_page = $arrParamsBusc{count};
+ $offset = 0;
+ } else {
+ $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
my $count = C4::Context->preference('OPACnumSearchResults') || 20;
- my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
+ $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
$arrParamsBusc{'count'} = $results_per_page;
- my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
# The value OPACnumSearchResults has changed and the search has to be rebuild
if ($count != $results_per_page) {
if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
@@ -308,6 +319,9 @@ if ($session->param('busc')) {
@arrBusc = split(/\&(?:amp;)?/, $newbusc);
}
}
+
+ } # end if cookie bibs_selected exists
+
my $buscParam = '';
my $j = 0;
# Rebuild the query for the button "back to results"
@@ -374,7 +388,7 @@ if ($session->param('busc')) {
}
$offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
}
- if ($searchAgain) {
+ if ($searchAgain and not scalar( @$bibnums )) {
my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
my @newresults = @$newresultsRef;
# build the new listBiblios
--