Bugzilla – Attachment 51376 Details for
Bug 16477
Improve staff client cart JavaScript and template
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16477 - Improve staff client cart JavaScript and template
Bug-16477---Improve-staff-client-cart-JavaScript-a.patch (text/plain), 17.70 KB, created by
Marc Véron
on 2016-05-10 09:13:53 UTC
(
hide
)
Description:
Bug 16477 - Improve staff client cart JavaScript and template
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2016-05-10 09:13:53 UTC
Size:
17.70 KB
patch
obsolete
>From 5e776a949ee67e08900d083890ed5b8f0be9e5e3 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 9 May 2016 11:15:28 -0400 >Subject: [PATCH] Bug 16477 - Improve staff client cart JavaScript and > template >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch makes several changes to the cart JavaScript and template. In >the template: > >- Remove "onclick" attributes in favor of defining events in the > JavaScript. >- Add a [% BLOCK %] section for some repeated markup. >- Add some Font Awesome icons (I didn't add icons to all controls > because I thought it looked cluttered). >- Move the batch modification control out of the toolbar and into the > group of controls which affects selected records. I think this is a > logical grouping, and makes more sense than having a drop-down menu in > the toolbar with a single menu item. > >JavaScript: > >- Created separate "cart.js" file so that JS could be moved out of the > template without loading up basket.js with event functions which are > not needed on every page in the staff client. >- Fix JSHint errors. > >To test, apply the patch and clear your browser cache if necessary. > >- Add multiple items to the cart in the staff client and open the cart. >- Confirm correct functionality of these toolbar buttons: > - "More details" (and the corresponding "Show less") > - "Send" > - "Print" > - "Empty and close" >- Confirm the correct functionality of all the selection controls: > Select all, clear all, Remove, Add to a list, Place hold, Batch > modify, and Batch delete. >- Confirm that clicking any title in the cart opens the correct detail > page in the parent window. > >Followed test plan, works as expected. >Signed-off-by: Marc Véron <veron@veron.ch> >--- > .../intranet-tmpl/prog/en/modules/basket/basket.tt | 183 +++++--------------- > koha-tmpl/intranet-tmpl/prog/js/basket.js | 5 +- > koha-tmpl/intranet-tmpl/prog/js/cart.js | 156 +++++++++++++++++ > 3 files changed, 198 insertions(+), 146 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/cart.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >index 72db196..ce2fc16 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >@@ -1,104 +1,40 @@ >+[% BLOCK controls %] >+ <p style="padding: 7px 0; border-top : 1px solid #E8E8E8;"> >+ <a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a> <a id="CheckNone" href="#"><i class="fa fa-remove"></i> Clear all</a> >+ | <b>Selected items :</b> >+ <a href="#" id="remove_from_cart">Remove</a> >+ >+ [% IF ( loggedinusername ) %] >+ | <a href="#" id="add_to_list">Add to a list</a> >+ [% END %] >+ >+ [% IF ( CAN_user_reserveforothers ) %] >+ | <a href="#" id="place_hold">Place hold</a> >+ [% END %] >+ >+ [% IF CAN_user_tools_records_batchmod %] >+ | <a href="#" id="batch_modify">Batch modify</a> >+ [% END %] >+ >+ [% IF CAN_user_tools_records_batchdel %] >+ | <a href="#" id="batch_delete">Batch delete</a> >+ [% END %] >+ </p> >+[% END %] > [% INCLUDE 'doc-head-open.inc' %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] Catalog › Your cart</title> > [% IF ( print_basket ) %] > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon %][% ELSE %][% interface %]/[% theme %]/img/favicon.ico[% END %]" type="image/x-icon" /> >-<meta http-equiv="Content-Language" content="en-us" /> > <style type="text/css"> > @import url([% interface %]/[% theme %]/css/print.css); > </style> > [% ELSE %][% INCLUDE 'doc-head-close.inc' %] >+<script type="text/javascript" src="[% interface %]/[% theme %]/js/cart.js"></script> > <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> > [% INCLUDE 'datatables.inc' %] >-<script type="text/javascript"> >- //<![CDATA[ >- >-function placeHold () { >- var checkedItems = $("input:checkbox:checked"); >- if ($(checkedItems).size() == 0) { >- alert(MSG_NO_RECORD_SELECTED); >- return false; >- } >- >- var newloc; >- >- if ($(checkedItems).size() > 1) { >- var bibs = ""; >- $(checkedItems).each(function() { >- var bib = $(this).val(); >- bibs += bib + "/"; >- }); >- >- newloc = "/cgi-bin/koha/reserve/request.pl?biblionumbers=" + bibs + "&multi_hold=1"; >- } else { >- var bib = checkedItems[0].value; >- newloc = "/cgi-bin/koha/reserve/request.pl?biblionumber=" + bib; >- } >- >- window.opener.location = newloc; >- window.close(); >-} >-[% IF CAN_user_tools_records_batchdel %] >-function batchDelete(){ >- var checkedItems = $("input:checkbox:checked"); >- if ($(checkedItems).size() == 0) { >- alert(MSG_NO_RECORD_SELECTED); >- return false; >- } >- var newloc; >- >- var bibs = ""; >- $(checkedItems).each(function() { >- var bib = $(this).val(); >- bibs += bib + "/"; >- }); >- >- newloc = "/cgi-bin/koha/tools/batch_delete_records.pl?op=list&type=biblio&bib_list=" + bibs; >- >- window.opener.location = newloc; >- window.close(); >-} >-[% END %] >- $(document).ready(function(){ >- $("#items-popover").popover(); >- $("#CheckAll").click(function(){ >- var checked = []; >- $("#bookbag_form").checkCheckboxes("*", true).each( >- function() { >- selRecord(this.value,true); >- } >- ); >- return false; >- }); >- $("#CheckNone").click(function(){ >- var checked = []; >- $("#bookbag_form").unCheckCheckboxes("*",true).each( >- function() { >- selRecord(this.value,false); >- } >- ); >- return false; >- }); >- $(".holdsep").text("| "); >- $(".hold").text(_("Place hold")); >- $("#downloadcartc").empty(); >- >- $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, { >- "sDom": 't', >- "aoColumnDefs": [ >- { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, >- { "sType": "anti-the", "aTargets" : [ "anti-the" ] }, >- { "sType": "callnumbers", "aTargets" : [ "callnumbers"] } >- ], >- "aaSorting": [[ 1, "asc" ]], >- "bPaginate": false >- })); >- >- }); >- //]]> >- </script> > [% END %] > </head> > [% IF ( print_basket ) %]<body id="cart_basket" class="cart" onload="print();history.back();">[% ELSE %]<body id="cart_basket" class="cart">[% END %] >@@ -109,8 +45,13 @@ function batchDelete(){ > <h1>Your cart</h1> > > <div id="toolbar" class="btn-toolbar"> >- [% IF ( verbose ) %]<a href="basket.pl" class="btn btn-small" onclick="showLess(); return false;"><i class="fa fa-folder"></i> Brief display</a>[% ELSE %]<a href="basket.pl" class="btn btn-small" onclick="showMore(); return false;"><i class="fa fa-folder-open"></i> More details</a>[% END %] >- <a class="btn btn-small" href="basket.pl" onclick="sendBasket(); return false;"><i class="fa fa-envelope"></i> Send</a> >+ [% IF ( verbose ) %] >+ <a href="basket.pl" class="btn btn-small showdetails showless"><i class="fa fa-folder"></i> Brief display</a> >+ [% ELSE %] >+ <a href="basket.pl" class="btn btn-small showdetails showmore"><i class="fa fa-folder-open"></i> More details</a> >+ [% END %] >+ >+ <a class="btn btn-small" href="basket.pl" id="send_cart"><i class="fa fa-envelope"></i> Send</a> > <div class="btn-group"> > <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#" id="downloadcart"><i class="fa fa-download"></i> Download <span class="caret"></span> </a> > <ul class="dropdown-menu"> >@@ -122,40 +63,16 @@ function batchDelete(){ > [% END %] > </ul> > </div> >- [% IF CAN_user_tools_records_batchmod %] >- <div class="btn-group"> >- <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#" id="actioncart"><i class="fa fa-play"></i> Actions <span class="caret"></span> </a> >- <ul class="dropdown-menu"> >- [% IF CAN_user_tools_records_batchmod %] >- <li><a href="/cgi-bin/koha/tools/batch_record_modification.pl?op=list&bib_list=[% bib_list %]&type=biblio">Modify</a></li> >- [% END %] >- </ul> >- </div> >- [% END %] >- <a class="btn btn-small" href="basket.pl" onclick="printBasket(); return false;"><i class="fa fa-print"></i> Print</a> >- <a class="btn btn-small" href="basket.pl" onclick="delBasket('popup'); return false;"><i class="fa fa-trash"></i> Empty and close</a> >+ <a class="btn btn-small" href="basket.pl" id="print_cart"><i class="fa fa-print"></i> Print</a> >+ <a class="btn btn-small" href="basket.pl" id="empty_cart"><i class="fa fa-trash"></i> Empty and close</a> > <a class="btn btn-small close" href="basket.pl"><i class="fa fa-times-circle"></i> Hide window</a> > </div> > [% END %] > > [% IF ( verbose ) %] >- [% UNLESS ( print_basket ) %]<p style="padding: 7px 0; border-top : 1px solid #E8E8E8;"><a id="CheckAll" href="#">Select all</a> <a id="CheckNone" href="#">Clear all</a> | <b>Selected items :</b> >- >- <a href="#" onclick="delSelRecords(); return false;">Remove</a> >- >-[% IF ( loggedinusername ) %] >- | <a href="#" onclick="addSelToShelf(); return false;">Add to a list</a> >-[% END %] >- >-[% IF ( CAN_user_reserveforothers ) %] >- | <a href="#" onclick="placeHold(); return false;">Place hold</a> >-[% END %] >- >-[% IF CAN_user_tools_records_batchdel %] >- | <a href="#" onclick="batchDelete(); return false;">Batch delete</a> >-[% END %] >- >-</p>[% END %] >+ [% UNLESS ( print_basket ) %] >+ [% PROCESS controls %] >+ [% END %] > <form action="basket.pl" method="get" name="bookbag_form" id="bookbag_form"> > [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %] > <h3> >@@ -164,7 +81,7 @@ function batchDelete(){ > [% IF ( BIBLIO_RESULT.subtitle ) %] [% BIBLIO_RESULT.subtitle %][% END %] > [% IF ( BIBLIO_RESULT.author ) %] [% BIBLIO_RESULT.author %][% END %] > [% ELSE %] >- <input type="checkbox" value="[% BIBLIO_RESULT.biblionumber %]" name="bib[% BIBLIO_RESULT.biblionumber %]" id="bib[% BIBLIO_RESULT.biblionumber %]" onclick="selRecord(value,checked)" /> >+ <input type="checkbox" class="select_record" value="[% BIBLIO_RESULT.biblionumber %]" name="bib[% BIBLIO_RESULT.biblionumber %]" id="bib[% BIBLIO_RESULT.biblionumber %]" /> > [% BIBLIO_RESULT.title |html %] > [% IF ( BIBLIO_RESULT.subtitle ) %] [% BIBLIO_RESULT.subtitle %][% END %] > [% IF ( BIBLIO_RESULT.author ) %] [% BIBLIO_RESULT.author %][% END %] >@@ -317,28 +234,10 @@ function batchDelete(){ > > [% ELSE %] > [% UNLESS ( print_basket ) %] >-<p style="border-top : 1px solid #E8E8E8;"> >- <form action="/cgi-bin/koha/basket/basket.pl" method="get" name="bookbag_form" id="bookbag_form"> >- <a id="CheckAll" href="#">Select all</a> >- <a id="CheckNone" href="#">Clear all</a> >- | <b>Selected items :</b> >-<a href="#" onclick="delSelRecords(); return false;">Remove</a> >- >-[% IF ( loggedinusername ) %] >- | <a href="#" onclick="addSelToShelf(); return false;">Add to a list</a> >-[% END %] >- >-[% IF ( CAN_user_reserveforothers ) %] >- | <a href="#" onclick="placeHold(); return false;">Place hold</a> >-[% END %] >- >-[% IF CAN_user_tools_records_batchdel %] >- | <a href="#" onclick="batchDelete(); return false;">Batch delete</a> >-[% END %] >- >+ <form action="/cgi-bin/koha/basket/basket.pl" method="get" name="bookbag_form" id="bookbag_form"> >+ [% PROCESS controls %] > [% END %] > >-</p> > <table id="itemst"> > <thead><tr> > [% UNLESS ( print_basket ) %]<th class="NoSort"> </th>[% END %] >@@ -350,10 +249,10 @@ function batchDelete(){ > [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %] > <tr> > [% UNLESS ( print_basket ) %]<td> >- <input type="checkbox" value="[% BIBLIO_RESULT.biblionumber %]" name="bib[% BIBLIO_RESULT.biblionumber %]" id="bib[% BIBLIO_RESULT.biblionumber %]" onclick="selRecord(value,checked);" /> >+ <input type="checkbox" class="select_record" value="[% BIBLIO_RESULT.biblionumber %]" name="bib[% BIBLIO_RESULT.biblionumber %]" id="bib[% BIBLIO_RESULT.biblionumber %]" /> > > </td> [% END %] >- <td><a href="#" onclick="openBiblio('[% BIBLIO_RESULT.dest %]',[% BIBLIO_RESULT.biblionumber %])"> >+ <td><a href="[% BIBLIO_RESULT.dest %]?biblionumber=[% BIBLIO_RESULT.biblionumber %]" class="open_title"> > [% BIBLIO_RESULT.title |html %] > </a> > [% BIBLIO_RESULT.author %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/basket.js b/koha-tmpl/intranet-tmpl/prog/js/basket.js >index d5b1e33..db74a4d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/basket.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/basket.js >@@ -388,8 +388,7 @@ function updateBasket(updated_value,target) { > var basketcount = updated_value; > } > >-function openBiblio(dest,biblionumber) { >- openerURL=dest+"?biblionumber="+biblionumber; >+function openBiblio(openerURL) { > opener.document.location = openerURL; > opener.focus(); > } >@@ -443,5 +442,3 @@ $(document).ready(function(){ > $("#cartmenulink").click(function(){ openBasket(); return false; }); > if(basketcount){ updateBasket(basketcount); } > }); >- >- >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cart.js b/koha-tmpl/intranet-tmpl/prog/js/cart.js >new file mode 100644 >index 0000000..0494398 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/cart.js >@@ -0,0 +1,156 @@ >+ >+function placeHold () { >+ var checkedItems = $("input:checkbox:checked"); >+ if ($(checkedItems).size() === 0) { >+ alert(MSG_NO_RECORD_SELECTED); >+ return false; >+ } >+ >+ var newloc; >+ >+ if ($(checkedItems).size() > 1) { >+ var bibs = ""; >+ $(checkedItems).each(function() { >+ var bib = $(this).val(); >+ bibs += bib + "/"; >+ }); >+ >+ newloc = "/cgi-bin/koha/reserve/request.pl?biblionumbers=" + bibs + "&multi_hold=1"; >+ } else { >+ var bib = checkedItems[0].value; >+ newloc = "/cgi-bin/koha/reserve/request.pl?biblionumber=" + bib; >+ } >+ >+ window.opener.location = newloc; >+ window.close(); >+} >+ >+function batchDelete(){ >+ var checkedItems = $("input:checkbox:checked"); >+ if ($(checkedItems).size() === 0) { >+ alert(MSG_NO_RECORD_SELECTED); >+ return false; >+ } >+ var newloc; >+ >+ var bibs = ""; >+ checkedItems.each(function() { >+ var bib = $(this).val(); >+ bibs += bib + "/"; >+ }); >+ >+ newloc = "/cgi-bin/koha/tools/batch_delete_records.pl?op=list&type=biblio&bib_list=" + bibs; >+ >+ window.opener.location = newloc; >+ window.close(); >+} >+ >+function batchModify(){ >+ var checkedItems = $("input:checkbox:checked"); >+ if ($(checkedItems).size() === 0) { >+ alert(MSG_NO_RECORD_SELECTED); >+ return false; >+ } >+ var newloc; >+ >+ var bibs = ""; >+ $(checkedItems).each(function() { >+ var bib = $(this).val(); >+ bibs += bib + "/"; >+ }); >+ newloc = "/cgi-bin/koha/tools/batch_record_modification.pl?op=list&bib_list=" + bibs + "&type=biblio"; >+ >+ window.opener.location = newloc; >+ window.close(); >+} >+ >+$(document).ready(function(){ >+ $("#items-popover").popover(); >+ $("#CheckAll").click(function(){ >+ var checked = []; >+ $("#bookbag_form").checkCheckboxes("*", true).each( >+ function() { >+ selRecord(this.value,true); >+ } >+ ); >+ return false; >+ }); >+ $("#CheckNone").click(function(){ >+ var checked = []; >+ $("#bookbag_form").unCheckCheckboxes("*",true).each( >+ function() { >+ selRecord(this.value,false); >+ } >+ ); >+ return false; >+ }); >+ $(".holdsep").text("| "); >+ $(".hold").text(_("Place hold")); >+ $("#downloadcartc").empty(); >+ >+ $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sDom": 't', >+ "aoColumnDefs": [ >+ { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, >+ { "sType": "anti-the", "aTargets" : [ "anti-the" ] }, >+ { "sType": "callnumbers", "aTargets" : [ "callnumbers"] } >+ ], >+ "aaSorting": [[ 1, "asc" ]], >+ "bPaginate": false >+ })); >+ >+ $(".showdetails").on("click",function(e){ >+ e.preventDefault(); >+ if( $(this).hasClass("showmore") ){ >+ showMore(); >+ } else { >+ showLess(); >+ } >+ }); >+ >+ $("#batch_modify").on("click",function(e){ >+ e.preventDefault(); >+ batchModify(); >+ }); >+ $("#batch_delete").on("click",function(e){ >+ e.preventDefault(); >+ batchDelete(); >+ }); >+ >+ $("#remove_from_cart").on("click",function(e){ >+ e.preventDefault(); >+ delSelRecords(); >+ }); >+ >+ $("#add_to_list").on("click",function(e){ >+ e.preventDefault(); >+ addSelToShelf(); >+ }); >+ >+ $("#place_hold").on("click",function(e){ >+ e.preventDefault(); >+ placeHold(); >+ }); >+ >+ $("#send_cart").on("click",function(e){ >+ e.preventDefault(); >+ sendBasket(); >+ }); >+ >+ $("#print_cart").on("click",function(e){ >+ e.preventDefault(); >+ printBasket(); >+ }); >+ >+ $("#empty_cart").on("click",function(e){ >+ e.preventDefault(); >+ delBasket('popup'); >+ }); >+ $(".open_title").on("click",function(e){ >+ e.preventDefault(); >+ openBiblio( this.href ); >+ }); >+ $(".select_record").on("change",function(){ >+ selRecord( this.value, this.checked ); >+ }); >+}); >-- >1.7.10.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 16477
:
51344
|
51376
|
52772