Bugzilla – Attachment 51383 Details for
Bug 16490
Add an "add to cart" link for each search results in the staff client
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16490 - Add an "add to cart" link for each search results in the staff client
Bug-16490---Add-an-add-to-cart-link-for-each-searc.patch (text/plain), 11.01 KB, created by
Owen Leonard
on 2016-05-10 15:06:03 UTC
(
hide
)
Description:
Bug 16490 - Add an "add to cart" link for each search results in the staff client
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2016-05-10 15:06:03 UTC
Size:
11.01 KB
patch
obsolete
>From 8f07afee3e4bb23a82e7d396b05cf03bbad40936 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 9 May 2016 21:14:17 -0400 >Subject: [PATCH] Bug 16490 - Add an "add to cart" link for each search results > in the staff client >Content-Type: text/plain; charset="utf-8" > >This patch adds an "add to cart" link to each line of search results in >the staff client. > >To test, apply the patch and clear your browser cache if necessary. > >- Enable the intranetbookbag system preference. >- Perform a search which will return multiple search results. >- Each result should have an "Add to cart" link. > - Clicking the "Add to cart" link should add the title to the cart, > triggering the correct pop-up message and changing the link to read > "In your cart (remove)." > - Clicking the "remove" link should remove the title from your cart > and trigger the correct messages. >- Add multiple titles to your cart and perform the same search again. > Each result should correctly indicate which titles are already in your > cart. >- Open the cart popup window. > - Check the checkbox for one or more titles in your cart and choose > "Remove." The titles should be removed, and the "In your cart" label > in the search results page should reflect that the titles are no > longer in the cart. > - Choose "Empty and close." All titles in the parent page should now > indicate that they are not in the cart. >- Disable the intranetbookbag preference and confirm that the "Add to > cart" links are no longer there. >--- > catalogue/search.pl | 12 ++++++ > koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 11 ++++++ > .../prog/en/includes/doc-head-close.inc | 3 ++ > .../prog/en/modules/catalogue/results.tt | 37 ++++++++++++++--- > koha-tmpl/intranet-tmpl/prog/js/basket.js | 46 ++++++++++++++++++++++ > 5 files changed, 103 insertions(+), 6 deletions(-) > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index c70efb0..dcbd21c 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -205,6 +205,14 @@ if($cgi->cookie("holdfor")){ > ); > } > >+# get biblionumbers stored in the cart >+my @cart_list; >+ >+if($cgi->cookie("intranet_bib_list")){ >+ my $cart_list = $cgi->cookie("intranet_bib_list"); >+ @cart_list = split(/\//, $cart_list); >+} >+ > # load the branches > my $branches = GetBranches(); > >@@ -610,6 +618,10 @@ for (my $i=0;$i<@servers;$i++) { > # in order to avoid problems generated by the default size value in TT > foreach my $line (@newresults) { > if ( not exists $line->{'size'} ) { $line->{'size'} = "" } >+ # while we're checking each line, see if item is in the cart >+ if ( grep {$_ eq $line->{'biblionumber'}} @cart_list) { >+ $line->{'incart'} = 1; >+ } > } > $template->param(SEARCH_RESULTS => \@newresults); > ## FIXME: add a global function for this, it's better than the current global one >diff --git a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >index 35fa6f8..5a6bc43 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >@@ -1097,6 +1097,17 @@ a.xml { > background-image: url("../img/famfamfam/silk/page_white_code.png"); > } > >+a.cartRemove { >+ color: #cc3333; >+ font-size : 90%; >+ margin : 0; >+ padding: 0; >+} >+ >+a.incart { >+ color: #666; >+} >+ > div.message { > background: #ffffff; /* Old browsers */ > background: -moz-linear-gradient(top, #ffffff 0%, #f4f6fa 2%, #eaeef5 23%, #e8edf6 94%, #cddbf2 100%); /* FF3.6+ */ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >index 43236f9..f72425d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >@@ -65,6 +65,9 @@ > var MSG_CONFIRM_DEL_RECORDS = _("Are you sure you want to remove the selected items?"); > var MSG_IN_YOUR_CART = _("Items in your cart: %s"); > var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be reserved."); >+ var MSG_ITEM_NOT_IN_CART = _("Add to cart"); >+ var MSG_ITEM_IN_CART = _("In your cart"); >+ var MSG_RECORD_REMOVED = _("The item has been removed from your cart"); > //]]> > </script> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 6e71a41..0d7691b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -184,6 +184,20 @@ $('#sort_by').change(function() { > > [% IF LocalCoverImages %]KOHA.LocalCover.LoadResultsCovers();[% END %] > >+ $("#searchresults").on("click",".addtocart",function(e){ >+ e.preventDefault(); >+ var selection_id = this.id; >+ var biblionumber = selection_id.replace("cart",""); >+ addRecord(biblionumber); >+ }); >+ >+ $("#searchresults").on("click",".cartRemove",function(e){ >+ e.preventDefault(); >+ var selection_id = this.id; >+ var biblionumber = selection_id.replace("cartR",""); >+ delSingleRecord(biblionumber); >+ }); >+ > }); > > >@@ -553,12 +567,23 @@ var holdForPatron = function () { > > [% END %] > [% END %] >- <p class="hold">[% IF ( SEARCH_RESULT.norequests ) %] >- <span class="noholdstext">No holds allowed</span> >- [% ELSE %] >- <a id="reserve_[% SEARCH_RESULT.biblionumber %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Holds</a> >- [% IF ( holdfor ) %] <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]&findborrower=[% holdfor_cardnumber %]">Place hold for [% holdfor_firstname %] [% holdfor_surname %] ([% holdfor_cardnumber %])</a></span>[% END %] >- [% END %] >+ <p class="hold"> >+ >+ [% IF ( SEARCH_RESULT.norequests ) %] >+ <span class="noholdstext">No holds allowed</span> >+ [% ELSE %] >+ <a id="reserve_[% SEARCH_RESULT.biblionumber %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Holds</a> >+ [% IF ( holdfor ) %] <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]&findborrower=[% holdfor_cardnumber %]">Place hold for [% holdfor_firstname %] [% holdfor_surname %] ([% holdfor_cardnumber %])</a></span>[% END %] >+ [% END %] >+ >+ [% IF Koha.Preference('intranetbookbag') == 1 %] >+ [% IF ( SEARCH_RESULT.incart ) %] >+ | <a class="addtocart" id="cart[% SEARCH_RESULT.biblionumber %]" href="#">In your cart</a> <a class="cartRemove" id="cartR[% SEARCH_RESULT.biblionumber %]" href="#">(remove)</a> >+ [% ELSE %] >+ | <a class="addtocart" id="cart[% SEARCH_RESULT.biblionumber %]" href="#">Add to cart</a> <a style="display:none;" class="cartRemove" id="cartR[% SEARCH_RESULT.biblionumber %]" href="#">(remove)</a> >+ [% END %] >+ [% END # / IF intranetbookbag %] >+ > [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] > | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]">Edit record</a> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/basket.js b/koha-tmpl/intranet-tmpl/prog/js/basket.js >index d5b1e33..f3b5b4a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/basket.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/basket.js >@@ -126,10 +126,12 @@ function addRecord(val, selection,NoMsgAlert) { > if (write) { > writeCookie(nameCookie, valCookie); > if (selection) { // when adding a selection of records >+ updateLink(val,"add"); > return 1; > } > if (! NoMsgAlert ) { > showCartUpdate(MSG_RECORD_ADDED); >+ updateLink(val,"add"); > } > } > } >@@ -227,6 +229,18 @@ function selRecord(num, status) { > document.myform.records.value = str; > } > >+function delSingleRecord(biblionumber){ >+ var valCookie = readCookie(nameCookie); >+ var arrayRecords = valCookie.split("/"); >+ var pos = jQuery.inArray(biblionumber,arrayRecords); >+ arrayRecords.splice(pos,1); >+ valCookie = arrayRecords.join("/"); >+ writeCookie( nameCookie, valCookie ); >+ updateBasket( arrayRecords.length-1 ); >+ updateLink(biblionumber,"del"); >+ showCartUpdate(MSG_RECORD_REMOVED); >+} >+ > function delSelRecords() { > var recordsSel = 0; > var end = 0; >@@ -243,6 +257,7 @@ function delSelRecords() { > num = str.substring(0, s); > str = delRecord(num,str); > str2 = delRecord(num,str2); >+ updateLink(num,"del",top.opener); > } else { > end = 1; > } >@@ -308,6 +323,7 @@ function delBasket(context,rep) { > if (rep) { > if(context == "popup"){ > delCookie(nameCookie); >+ updateAllLinks(top.opener); > document.location = "about:blank"; > updateBasket(0,top.opener); > window.close(); >@@ -439,6 +455,36 @@ function hideCart(){ > $("#cartDetails").fadeOut("fast"); > } > >+function updateLink(val,op,target){ >+ if(target){ >+ if(op == "add"){ >+ target.$("#cart"+val).html(MSG_ITEM_IN_CART).addClass("incart"); >+ target.$("#cartR"+val).show(); >+ } else { >+ target.$("#cart"+val).html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart"); >+ target.$("#cartR"+val).hide(); >+ } >+ } else { >+ if(op == "add"){ >+ $("#cart"+val).html(MSG_ITEM_IN_CART).addClass("incart"); >+ $("#cartR"+val).show(); >+ } else { >+ $("#cart"+val).html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart"); >+ $("#cartR"+val).hide(); >+ } >+ } >+} >+ >+function updateAllLinks(target){ >+ if(target){ >+ target.$("a.incart").html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart"); >+ target.$(".cartRemove").hide(); >+ } else { >+ $("a.incart").html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart"); >+ $(".cartRemove").hide(); >+ } >+} >+ > $(document).ready(function(){ > $("#cartmenulink").click(function(){ openBasket(); return false; }); > if(basketcount){ updateBasket(basketcount); } >-- >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 16490
:
51383
|
51384
|
52520
|
52522
|
52525
|
52526
|
52797
|
52798