@@ -, +, @@ detail pages - 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. - 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. --- catalogue/ISBDdetail.pl | 33 ++++++++++ catalogue/MARCdetail.pl | 34 ++++++++++ catalogue/detail.pl | 32 +++++++++ catalogue/labeledMARCdetail.pl | 33 ++++++++++ catalogue/moredetail.pl | 32 +++++++++ .../intranet-tmpl/prog/css/src/staff-global.scss | 18 ++++++ .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 75 ++++++++++++++++++---- .../prog/en/modules/catalogue/ISBDdetail.tt | 1 + .../prog/en/modules/catalogue/MARCdetail.tt | 1 + .../prog/en/modules/catalogue/labeledMARCdetail.tt | 1 + koha-tmpl/intranet-tmpl/prog/js/basket.js | 28 ++++++-- koha-tmpl/intranet-tmpl/prog/js/catalog.js | 39 +++++++++-- 12 files changed, 301 insertions(+), 26 deletions(-) --- a/catalogue/ISBDdetail.pl +++ a/catalogue/ISBDdetail.pl @@ -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, --- a/catalogue/MARCdetail.pl +++ a/catalogue/MARCdetail.pl @@ -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 ); --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -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; --- a/catalogue/labeledMARCdetail.pl +++ a/catalogue/labeledMARCdetail.pl @@ -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, --- a/catalogue/moredetail.pl +++ a/catalogue/moredetail.pl @@ -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, --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -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 { --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -100,19 +100,68 @@ CAN_user_serials_create_subscription ) %] -[% IF ( virtualshelves && intranetbookbag ) %] -
- - -
-[% ELSIF ( virtualshelves ) %] -
Add to list
-[% ELSIF ( intranetbookbag ) %] -
Add to cart
-[% END %] + [% IF ( intranetbookbag ) %] + [% IF ( incart ) %] +
+ Add to cart +
+
+ Remove from cart +
+ [% ELSE %] +
+ Add to cart +
+
+ Remove from cart +
+ [% END %] + [% END %] + + [% IF Koha.Preference('virtualshelves') %] +
+ + +
+ [% END # /IF virtualshelves %]
Print
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt @@ -1,4 +1,5 @@ [% USE raw %] +[% USE Koha %] [% USE Asset %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt @@ -1,4 +1,5 @@ [% USE raw %] +[% USE Koha %] [% USE Asset %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt @@ -1,4 +1,5 @@ [% USE raw %] +[% USE Koha %] [% USE Asset %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/js/basket.js +++ a/koha-tmpl/intranet-tmpl/prog/js/basket.js @@ -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(" " + __("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(" " + __("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(" " + __("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(){ --- a/koha-tmpl/intranet-tmpl/prog/js/catalog.js +++ a/koha-tmpl/intranet-tmpl/prog/js/catalog.js @@ -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(" " + __("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); + } + }); + }); --