Bugzilla – Attachment 79903 Details for
Bug 21479
Removing from cart removes 2 items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21479: (alternate) Removing from cart removes 2 items
Bug-21479-alternate-Removing-from-cart-removes-2-i.patch (text/plain), 7.66 KB, created by
Owen Leonard
on 2018-10-03 15:55:52 UTC
(
hide
)
Description:
Bug 21479: (alternate) Removing from cart removes 2 items
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2018-10-03 15:55:52 UTC
Size:
7.66 KB
patch
obsolete
>From a2a096a161cedc6becb3a5ec0d508b0f73499690 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 3 Oct 2018 14:13:49 +0000 >Subject: [PATCH] Bug 21479: (alternate) Removing from cart removes 2 items > >This patch changes the way biblionumbers are passed to the cart script >for adding and removing single items. The title's biblionumber is now >stored in a data-attribute on the links for adding and removing. This >should be a more robust, unified way to handle these single-item >operations. > >To test, apply the patch and enable the opacbookbag system preference. > >Test adding and removing items from the cart from various pages using >various methods: > > - By clicking an "Add to your cart" / "Remove" link in search results > - By clicking an "Add to your cart" / "Remove" link on a detail page > - By checking boxes in search results and adding via the dropdown > >Each operation should work correctly. >--- > .../opac-tmpl/bootstrap/en/includes/opac-bottom.inc | 17 ++++++++++------- > .../bootstrap/en/includes/opac-detail-sidebar.inc | 4 ++-- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 4 ++-- > koha-tmpl/opac-tmpl/bootstrap/js/basket.js | 5 ++++- > 4 files changed, 18 insertions(+), 12 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index ab7eb2c..6baedf9 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -188,15 +188,18 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > Dopop('opac-addbybiblionumber.pl?biblionumber=[% biblionumber | html %]'); > return false; > }); >- $(".addrecord").on("click",function(){ >- addRecord('[% biblionumber | html %]'); >- return false; >+ $("body").on("click", ".addtocart", function(e){ >+ e.preventDefault(); >+ var biblionumber = $(this).data("biblionumber"); >+ addRecord( biblionumber ); > }); >- $(".cartRemove").on("click",function(){ >- delSingleRecord('[% biblionumber | html %]'); >- return false; >+ $("body").on("click", ".cartRemove", function(e){ >+ e.preventDefault(); >+ var biblionumber = $(this).data("biblionumber"); >+ delSingleRecord( biblionumber ); > }); >- $(".clearsh").on("click", function(){ >+ $(".clearsh").on("click", function(e){ >+ e.preventDefault(); > return confirmDelete(MSG_DELETE_SEARCH_HISTORY); > }); > //]]> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >index a8f6f4e..e1c645d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >@@ -27,9 +27,9 @@ > > [% IF Koha.Preference( 'opacbookbag' ) == 1 %] > [% IF ( incart ) %] >- <li><a class="incart cart[% biblio.biblionumber | html %] addrecord" href="#">In your cart</a> <a class="cartRemove cartR[% biblio.biblionumber | html %]" href="#">(remove)</a></li> >+ <li><a data-biblionumber="[% biblio.biblionumber | html %]" class="addtocart incart cart[% biblio.biblionumber | html %] addrecord" href="#">In your cart</a> <a data-biblionumber="[% biblio.biblionumber | html %]" class="cartRemove cartR[% biblio.biblionumber | html %]" href="#">(remove)</a></li> > [% ELSE %] >- <li><a class="addtocart cart[% biblio.biblionumber | html %] addrecord" href="#">Add to your cart</a> <a style="display:none;" class="cartRemove cartR[% biblio.biblionumber | html %]" href="#">(remove)</a></li> >+ <li><a data-biblionumber="[% biblio.biblionumber | html %]" class="addtocart cart[% biblio.biblionumber | html %] addrecord" href="#">Add to your cart</a> <a style="display:none;" data-biblionumber="[% biblio.biblionumber | html %]" class="cartRemove cartR[% biblio.biblionumber | html %]" href="#">(remove)</a></li> > [% END %] > [% END %] > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index 4d4fe4f..45733ea 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -535,9 +535,9 @@ > > [% IF Koha.Preference( 'opacbookbag' ) == 1 %] > [% IF ( SEARCH_RESULT.incart ) %] >- <span class="actions"><a class="addtocart cart[% SEARCH_RESULT.biblionumber | html %]" href="#" onclick="addRecord('[% SEARCH_RESULT.biblionumber | html %]'); return false;">In your cart</a> <a class="cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#" onclick="delSingleRecord('[% SEARCH_RESULT.biblionumber | html %]'); return false;">(remove)</a></span> >+ <span class="actions"><a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="addtocart cart[% SEARCH_RESULT.biblionumber | html %]" href="#">In your cart</a> <a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#">(remove)</a></span> > [% ELSE %] >- <span class="actions"><a class="addtocart cart[% SEARCH_RESULT.biblionumber | html %]" href="#" onclick="addRecord('[% SEARCH_RESULT.biblionumber | html %]'); return false;">Add to cart</a> <a style="display:none;" class="cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#" onclick="delSingleRecord('[% SEARCH_RESULT.biblionumber | html %]'); return false;">(remove)</a></span> >+ <span class="actions"><a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="addtocart cart[% SEARCH_RESULT.biblionumber | html %]" href="#">Add to your cart</a> <a style="display:none;" data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#">(remove)</a></span> > [% END %] > [% END # / IF opacbookbag %] > </div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/basket.js b/koha-tmpl/opac-tmpl/bootstrap/js/basket.js >index 9eb6630..250a0af 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/basket.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/basket.js >@@ -1,3 +1,5 @@ >+/* global MSG_BASKET_EMPTY MSG_RECORD_IN_BASKET MSG_RECORD_ADDED MSG_NRECORDS_IN_BASKET MSG_NRECORDS_ADDED MSG_NO_RECORD_SELECTED MSG_NO_RECORD_ADDED MSG_IN_YOUR_CART MSG_RECORD_REMOVED MSG_CONFIRM_DEL_BASKET MSG_CONFIRM_DEL_RECORDS MSG_ITEM_IN_CART MSG_ITEM_NOT_IN_CART */ >+ > ////////////////////////////////////////////////////////////////////////////// > // BASIC FUNCTIONS FOR COOKIE MANAGEMENT // > ////////////////////////////////////////////////////////////////////////////// >@@ -230,11 +232,12 @@ function selRecord(num, status) { > } > > function delSingleRecord(biblionumber){ >+ biblionumber = String( biblionumber ); > var nameCookie = "bib_list"; > var valCookie = readCookie(nameCookie); > var arrayRecords = valCookie.split("/"); > var pos = jQuery.inArray(biblionumber,arrayRecords); >- arrayRecords.splice(pos,1); >+ arrayRecords.splice( pos, 1 ); > valCookie = arrayRecords.join("/"); > writeCookie( nameCookie, valCookie ); > updateBasket( arrayRecords.length-1 ); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21479
:
79852
|
79857
|
79893
|
79903
|
79950
|
80219
|
80291
|
80292
|
80304
|
80305
|
80557
|
80605
|
80625
|
80643