Bug 26707: Split cart and lists button on bibliographic detail pages
This patch modifies the toolbar shown on bibliographic detail pages so that the "Add to cart" and "Add to lists" buttons are separate. The "Add to cart" will now reflect whether the title is in the cart. The "Add to lists" button will now be a menu of list choices like it is on the search results page. To test, apply the patch and rebuild the staff client CSS (https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client). Search for a title in the staff client and view the detail page for one of the results. Testing the cart button: - In the toolbar you should see an "Add to cart" button and an "Add to lists" menu button. - Clicking the "Add to cart" button should show the cart message associated with cart link in the header. - The label showing the number of items in the cart should be incremented. - The button should change to a "Remove from cart" button. - Clicking the "Remove from cart" button should correctly remove the item from the cart: - The label showing the number of items in the cart should be decremented. - The button should change to "Add to cart." - Add a title to the cart and click the cart link in the header to open the cart pop-up window. - Click the "Empty and close" button in the cart window. - After you confirm the cart window should close. The "Remove from cart" button should now be an "Add to cart" button. - Add a title to the cart and navigate between each of the other views of that title: Normal, MARC, Labeled MARC, and ISBD. On each page you should see a "Remove from cart" button. - Test the add and remove functions from each of the other bibliographic detail views. Testing the lists button: - On the normal bibliographic detail page you should see an "Add to list" menu button. Clicking it should reveal the same kind of lists menu you see on the catalog search results page, with recent public and private lists and options for "More lists" and "New list." - Test that each of these options works correctly to trigger the expected pop-up window. - Confrim that the correct title is added to the correct list. - Perform this test from each of the bibliographic detail pages: Normal, MARC, Labeled MARC, and ISBD. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
c7e228c60c
commit
ff2c52e093
|
|
@ -49,6 +49,7 @@ use C4::Search; # enabled_staff_search_views
|
|||
use Koha::Biblios;
|
||||
use Koha::Patrons;
|
||||
use Koha::RecordProcessor;
|
||||
use Koha::Virtualshelves;
|
||||
|
||||
|
||||
my $query = CGI->new;
|
||||
|
|
@ -138,6 +139,38 @@ if ($subscriptionsnumber) {
|
|||
);
|
||||
}
|
||||
|
||||
# get biblionumbers stored in the cart
|
||||
my @cart_list;
|
||||
|
||||
if($query->cookie("intranet_bib_list")){
|
||||
my $cart_list = $query->cookie("intranet_bib_list");
|
||||
@cart_list = split(/\//, $cart_list);
|
||||
if ( grep {$_ eq $biblionumber} @cart_list) {
|
||||
$template->param( incart => 1 );
|
||||
}
|
||||
}
|
||||
|
||||
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $loggedinuser,
|
||||
add_allowed => 1,
|
||||
category => 1,
|
||||
}
|
||||
);
|
||||
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $loggedinuser,
|
||||
add_allowed => 1,
|
||||
category => 2,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$template->param(
|
||||
add_to_some_private_shelves => $some_private_shelves,
|
||||
add_to_some_public_shelves => $some_public_shelves,
|
||||
);
|
||||
|
||||
$template->param (
|
||||
ISBD => $res,
|
||||
biblionumber => $biblionumber,
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ use Koha::Biblios;
|
|||
use Koha::BiblioFrameworks;
|
||||
use Koha::Patrons;
|
||||
use Koha::DateUtils;
|
||||
use Koha::Virtualshelves;
|
||||
|
||||
use List::MoreUtils qw( uniq );
|
||||
|
||||
|
|
@ -325,6 +326,38 @@ if ($subscriptionscount) {
|
|||
);
|
||||
}
|
||||
|
||||
# get biblionumbers stored in the cart
|
||||
my @cart_list;
|
||||
|
||||
if($query->cookie("intranet_bib_list")){
|
||||
my $cart_list = $query->cookie("intranet_bib_list");
|
||||
@cart_list = split(/\//, $cart_list);
|
||||
if ( grep {$_ eq $biblionumber} @cart_list) {
|
||||
$template->param( incart => 1 );
|
||||
}
|
||||
}
|
||||
|
||||
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $loggedinuser,
|
||||
add_allowed => 1,
|
||||
category => 1,
|
||||
}
|
||||
);
|
||||
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $loggedinuser,
|
||||
add_allowed => 1,
|
||||
category => 2,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$template->param(
|
||||
add_to_some_private_shelves => $some_private_shelves,
|
||||
add_to_some_public_shelves => $some_public_shelves,
|
||||
);
|
||||
|
||||
$template->param (
|
||||
item_loop => \@item_loop,
|
||||
item_header_loop => \@item_header_loop,
|
||||
|
|
@ -337,6 +370,7 @@ $template->param (
|
|||
C4::Search::enabled_staff_search_views,
|
||||
searchid => scalar $query->param('searchid'),
|
||||
biblio => $biblio_object,
|
||||
loggedinuser => $loggedinuser,
|
||||
);
|
||||
|
||||
$template->param( holdcount => $biblio_object->holds->count );
|
||||
|
|
|
|||
|
|
@ -438,6 +438,27 @@ if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
|
|||
}
|
||||
}
|
||||
|
||||
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $borrowernumber,
|
||||
add_allowed => 1,
|
||||
category => 1,
|
||||
}
|
||||
);
|
||||
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $borrowernumber,
|
||||
add_allowed => 1,
|
||||
category => 2,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$template->param(
|
||||
add_to_some_private_shelves => $some_private_shelves,
|
||||
add_to_some_public_shelves => $some_public_shelves,
|
||||
);
|
||||
|
||||
$template->param(
|
||||
MARCNOTES => $marcnotesarray,
|
||||
itemdata_ccode => $itemfields{ccode},
|
||||
|
|
@ -580,6 +601,17 @@ if ($StaffDetailItemSelection) {
|
|||
}
|
||||
}
|
||||
|
||||
# get biblionumbers stored in the cart
|
||||
my @cart_list;
|
||||
|
||||
if($query->cookie("intranet_bib_list")){
|
||||
my $cart_list = $query->cookie("intranet_bib_list");
|
||||
@cart_list = split(/\//, $cart_list);
|
||||
if ( grep {$_ eq $biblionumber} @cart_list) {
|
||||
$template->param( incart => 1 );
|
||||
}
|
||||
}
|
||||
|
||||
$template->param(biblio => $biblio);
|
||||
|
||||
output_html_with_http_headers $query, $cookie, $template->output;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ use C4::Serials;
|
|||
use Koha::Biblios;
|
||||
use Koha::BiblioFrameworks;
|
||||
use Koha::Patrons;
|
||||
use Koha::Virtualshelves;
|
||||
|
||||
my $query = CGI->new;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
|
@ -120,6 +121,38 @@ for my $field ($record->fields)
|
|||
};
|
||||
}
|
||||
|
||||
# get biblionumbers stored in the cart
|
||||
my @cart_list;
|
||||
|
||||
if($query->cookie("intranet_bib_list")){
|
||||
my $cart_list = $query->cookie("intranet_bib_list");
|
||||
@cart_list = split(/\//, $cart_list);
|
||||
if ( grep {$_ eq $biblionumber} @cart_list) {
|
||||
$template->param( incart => 1 );
|
||||
}
|
||||
}
|
||||
|
||||
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $loggedinuser,
|
||||
add_allowed => 1,
|
||||
category => 1,
|
||||
}
|
||||
);
|
||||
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $loggedinuser,
|
||||
add_allowed => 1,
|
||||
category => 2,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$template->param(
|
||||
add_to_some_private_shelves => $some_private_shelves,
|
||||
add_to_some_public_shelves => $some_public_shelves,
|
||||
);
|
||||
|
||||
$template->param (
|
||||
marc_data => \@marc_data,
|
||||
biblionumber => $biblionumber,
|
||||
|
|
|
|||
|
|
@ -265,6 +265,38 @@ $template->param(count => $data->{'count'},
|
|||
C4::Search::enabled_staff_search_views,
|
||||
);
|
||||
|
||||
# get biblionumbers stored in the cart
|
||||
my @cart_list;
|
||||
|
||||
if($query->cookie("intranet_bib_list")){
|
||||
my $cart_list = $query->cookie("intranet_bib_list");
|
||||
@cart_list = split(/\//, $cart_list);
|
||||
if ( grep {$_ eq $biblionumber} @cart_list) {
|
||||
$template->param( incart => 1 );
|
||||
}
|
||||
}
|
||||
|
||||
my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $loggedinuser,
|
||||
add_allowed => 1,
|
||||
category => 1,
|
||||
}
|
||||
);
|
||||
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
|
||||
{
|
||||
borrowernumber => $loggedinuser,
|
||||
add_allowed => 1,
|
||||
category => 2,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$template->param(
|
||||
add_to_some_private_shelves => $some_private_shelves,
|
||||
add_to_some_public_shelves => $some_public_shelves,
|
||||
);
|
||||
|
||||
$template->param(
|
||||
ITEM_DATA => \@items,
|
||||
moredetailview => 1,
|
||||
|
|
|
|||
|
|
@ -1365,6 +1365,24 @@ dd {
|
|||
margin-top: 0;
|
||||
z-index: 300;
|
||||
}
|
||||
|
||||
a.addtocart {
|
||||
display: block;
|
||||
}
|
||||
|
||||
a.cartRemove {
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
a.addtocart.incart {
|
||||
display: none;
|
||||
}
|
||||
|
||||
a.cartRemove.incart {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
#disabled {
|
||||
|
|
|
|||
|
|
@ -100,19 +100,68 @@ CAN_user_serials_create_subscription ) %]
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
[% IF ( virtualshelves && intranetbookbag ) %]
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Add to <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" id="addtocart">Cart</a></li>
|
||||
<li><a href="#" id="addtoshelf">List</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
[% ELSIF ( virtualshelves ) %]
|
||||
<div class="btn-group"><a id="addtoshelf" class="btn btn-default"><i class="fa fa-list"></i> Add to list</a> </div>
|
||||
[% ELSIF ( intranetbookbag ) %]
|
||||
<div class="btn-group"><a id="addtocart" class="btn btn-default"><i class="fa fa-shopping-cart"></i> Add to cart</a> </div>
|
||||
[% END %]
|
||||
[% IF ( intranetbookbag ) %]
|
||||
[% IF ( incart ) %]
|
||||
<div class="btn-group">
|
||||
<a id="cart[% biblionumber | html %]" class="btn btn-default addtocart incart" href="#"><i class="fa fa-shopping-cart"></i> Add to cart</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a id="cartR[% biblionumber | html %]" class="btn btn-default cartRemove incart" href="#"><i class="fa fa-shopping-cart"></i> Remove from cart</a>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
<div class="btn-group">
|
||||
<a id="cart[% biblionumber | html %]" class="btn btn-default addtocart" href="#"><i class="fa fa-shopping-cart"></i> Add to cart</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a id="cartR[% biblionumber | html %]" class="btn btn-default cartRemove" href="#"><i class="fa fa-shopping-cart"></i> Remove from cart</a>
|
||||
</div>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
[% IF Koha.Preference('virtualshelves') %]
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-list"></i> Add to list <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
[% IF add_to_some_private_shelves.count %]
|
||||
<li class="dropdown-header">Your lists</li>
|
||||
[% SET number_of_private_shelves = 0 %]
|
||||
[% FOREACH s IN add_to_some_private_shelves %]
|
||||
[% IF shelfnumber != s.shelfnumber %]
|
||||
<li>
|
||||
<a href="#" class="addtolist" data-shelfnumber="[% s.shelfnumber | html %]">[% s.shelfname | html %]</a>
|
||||
</li>
|
||||
[% SET number_of_private_shelves = number_of_private_shelves + 1 %]
|
||||
[% IF number_of_private_shelves == 10 %][% LAST %][% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% IF add_to_some_public_shelves.count %]
|
||||
<li class="dropdown-header">Public lists</li>
|
||||
[% SET number_of_public_shelves = 0 %]
|
||||
[% FOREACH s IN add_to_some_public_shelves %]
|
||||
[% IF shelfnumber != s.shelfnumber %]
|
||||
<li>
|
||||
<a href="#" data-shelfnumber="[% s.shelfnumber | html %]" class="addtolist">[% s.shelfname | html %]</a>
|
||||
</li>
|
||||
[% SET number_of_public_shelves = number_of_public_shelves + 1 %]
|
||||
[% IF number_of_public_shelves == 10 %][% LAST %][% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
<li role="separator" class="divider"></li>
|
||||
[% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
|
||||
<li>
|
||||
<a href="#" class="addtolist morelists">More lists</a>
|
||||
</li>
|
||||
[% END %]
|
||||
<li>
|
||||
<a href="#" class="addtolist newlist">New list</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
[% END # /IF virtualshelves %]
|
||||
|
||||
<div class="btn-group"><a id="printbiblio" class="btn btn-default"><i class="fa fa-print"></i> Print</a></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
[% USE raw %]
|
||||
[% USE Koha %]
|
||||
[% USE Asset %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
[% USE raw %]
|
||||
[% USE Koha %]
|
||||
[% USE Asset %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
[% USE raw %]
|
||||
[% USE Koha %]
|
||||
[% USE Asset %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
|
|
|
|||
|
|
@ -484,22 +484,36 @@ function updateLink(val, op, target){
|
|||
var cartR = target ? target.$("#cartR" + val) : $("#cartR" + val);
|
||||
|
||||
if(op == "add"){
|
||||
cart.html(__("In your cart")).addClass("incart");
|
||||
if( cart.hasClass("btn") ){
|
||||
/* Cart link is a button with an icon */
|
||||
cart.html("<i class=\"fa fa-shopping-cart\"></i> " + __("Add to cart")).addClass("incart");
|
||||
cart.hide();
|
||||
} else {
|
||||
cart.html( __("In your cart") ).addClass("incart");
|
||||
}
|
||||
cartR.show();
|
||||
} else {
|
||||
cart.html(__("Add to cart")).removeClass("incart").addClass("addtocart");
|
||||
if (cart.hasClass("btn")) {
|
||||
cart.html("<i class=\"fa fa-shopping-cart\"></i> " + __("Add to cart")).addClass("addtocart");
|
||||
cart.show();
|
||||
} else {
|
||||
cart.html(__("Add to cart")).addClass("addtocart");
|
||||
}
|
||||
cartR.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function updateAllLinks(target){
|
||||
if(target){
|
||||
target.$("a.incart").html(__("Add to cart")).removeClass("incart").addClass("addtocart");
|
||||
target.$(".cartRemove").hide();
|
||||
var cart = target ? target.$("a.incart") : $("a.incart");
|
||||
var cartR = target ? target.$(".cartRemove") : $(".cartRemove");
|
||||
if( cart.hasClass("btn") ){
|
||||
/* Cart link is a button with an icon */
|
||||
cart.html("<i class=\"fa fa-shopping-cart\"></i> " + __("Add to cart")).addClass("incart");
|
||||
cartR.hide();
|
||||
} else {
|
||||
$("a.incart").html(__("Add to cart")).removeClass("incart").addClass("addtocart");
|
||||
$(".cartRemove").hide();
|
||||
cart.html( __("In your cart") ).addClass("incart");
|
||||
}
|
||||
cart.show();
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* global __ biblionumber count holdcount countorders countdeletedorders searchid addRecord */
|
||||
/* global __ biblionumber count holdcount countorders countdeletedorders searchid addRecord delSingleRecord */
|
||||
/* exported GetZ3950Terms PopupZ3950Confirmed */
|
||||
/* IF ( CAN_user_editcatalogue_edit_catalogue ) */
|
||||
/* this function open a popup to search on z3950 server. */
|
||||
|
|
@ -15,7 +15,10 @@
|
|||
}
|
||||
/* END IF( CAN_user_editcatalogue_edit_catalogue ) */
|
||||
|
||||
function addToCart() { addRecord( biblionumber ); }
|
||||
function addToCart(){
|
||||
addRecord( biblionumber );
|
||||
}
|
||||
|
||||
function addToShelf() { window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=' + biblionumber,'Add_to_virtualshelf','width=500,height=400,toolbar=false,scrollbars=yes');
|
||||
}
|
||||
function printBiblio() {window.print(); }
|
||||
|
|
@ -94,11 +97,22 @@ $(document).ready(function() {
|
|||
printBiblio();
|
||||
return false;
|
||||
});
|
||||
$("#addtocart").click(function(){
|
||||
addToCart();
|
||||
$(".btn-group").removeClass("open");
|
||||
return false;
|
||||
|
||||
$(".addtocart").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var selection_id = this.id;
|
||||
var biblionumber = selection_id.replace("cart", "");
|
||||
addRecord(biblionumber);
|
||||
});
|
||||
|
||||
$(".cartRemove").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var selection_id = this.id;
|
||||
var biblionumber = selection_id.replace("cartR", "");
|
||||
delSingleRecord(biblionumber);
|
||||
$(".addtocart").html("<i class=\"fa fa-shopping-cart\"></i> " + __("Add to cart"));
|
||||
});
|
||||
|
||||
$("#addtoshelf").click(function(){
|
||||
addToShelf();
|
||||
$(".btn-group").removeClass("open");
|
||||
|
|
@ -112,4 +126,17 @@ $(document).ready(function() {
|
|||
alertNoItems();
|
||||
})
|
||||
.tooltip();
|
||||
|
||||
$(".addtolist").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var shelfnumber = $(this).data("shelfnumber");
|
||||
if ($(this).hasClass("morelists")) {
|
||||
openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=' + biblionumber);
|
||||
} else if ($(this).hasClass("newlist")) {
|
||||
openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&biblionumber=' + biblionumber);
|
||||
} else {
|
||||
openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber=' + shelfnumber + '&confirm=1&biblionumber=' + biblionumber);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue