@@ -, +, @@ - 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. - 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. - 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. --- .../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 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt @@ -1,104 +1,40 @@ +[% BLOCK controls %] +

+ Select all Clear all + | Selected items : + Remove + + [% IF ( loggedinusername ) %] + | Add to a list + [% END %] + + [% IF ( CAN_user_reserveforothers ) %] + | Place hold + [% END %] + + [% IF CAN_user_tools_records_batchmod %] + | Batch modify + [% END %] + + [% IF CAN_user_tools_records_batchdel %] + | Batch delete + [% END %] +

+[% END %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] Catalog › Your cart [% IF ( print_basket ) %] - [% ELSE %][% INCLUDE 'doc-head-close.inc' %] + [% INCLUDE 'datatables.inc' %] - [% END %] [% IF ( print_basket ) %][% ELSE %][% END %] @@ -109,8 +45,13 @@ function batchDelete(){

Your cart

- [% IF ( verbose ) %] Brief display[% ELSE %] More details[% END %] - Send + [% IF ( verbose ) %] + Brief display + [% ELSE %] + More details + [% END %] + + Send
Download
- [% IF CAN_user_tools_records_batchmod %] -
- Actions - -
- [% END %] - Print - Empty and close + Print + Empty and close Hide window
[% END %] [% IF ( verbose ) %] - [% UNLESS ( print_basket ) %]

Select all Clear all | Selected items : - - Remove - -[% IF ( loggedinusername ) %] - | Add to a list -[% END %] - -[% IF ( CAN_user_reserveforothers ) %] - | Place hold -[% END %] - -[% IF CAN_user_tools_records_batchdel %] - | Batch delete -[% END %] - -

[% END %] + [% UNLESS ( print_basket ) %] + [% PROCESS controls %] + [% END %]
[% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]

@@ -164,7 +81,7 @@ function batchDelete(){ [% IF ( BIBLIO_RESULT.subtitle ) %] [% BIBLIO_RESULT.subtitle %][% END %] [% IF ( BIBLIO_RESULT.author ) %] [% BIBLIO_RESULT.author %][% END %] [% ELSE %] - + [% 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 ) %] -

- - Select all - Clear all - | Selected items : -Remove - -[% IF ( loggedinusername ) %] - | Add to a list -[% END %] - -[% IF ( CAN_user_reserveforothers ) %] - | Place hold -[% END %] - -[% IF CAN_user_tools_records_batchdel %] - | Batch delete -[% END %] - + + [% PROCESS controls %] [% END %] -

[% UNLESS ( print_basket ) %][% END %] @@ -350,10 +249,10 @@ function batchDelete(){ [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %] [% UNLESS ( print_basket ) %] [% END %] -
 
- + + [% BIBLIO_RESULT.title |html %] [% BIBLIO_RESULT.author %] --- a/koha-tmpl/intranet-tmpl/prog/js/basket.js +++ a/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); } }); - - --- a/koha-tmpl/intranet-tmpl/prog/js/cart.js +++ a/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 ); + }); +}); --