From 4a065be964752858d1beaff47bfb0659f2c98fdb Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 22 Jul 2013 07:43:13 -0400 Subject: [PATCH] Bug 9456 - Add callnumber column to the cart - QA Followup 2 - Sort on callnumber only Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/en/js/datatables.js | 30 ++++++++++++++++++++ .../intranet-tmpl/prog/en/modules/basket/basket.tt | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js index 0ff05c4..d90de2d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js @@ -548,12 +548,22 @@ jQuery.fn.dataTableExt.oSort['callnumbers-asc'] = function(x,y) { x_array.shift(); y_array.shift(); + x_array = jQuery.map( x_array, function( a ) { + return parse_callnumber( a ); + }); + y_array = jQuery.map( y_array, function( a ) { + return parse_callnumber( a ); + }); + x_array.sort(); y_array.sort(); x = x_array.shift(); y = y_array.shift(); + if ( !x ) { x = ""; } + if ( !y ) { y = ""; } + return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }; @@ -565,11 +575,31 @@ jQuery.fn.dataTableExt.oSort['callnumbers-desc'] = function(x,y) { x_array.shift(); y_array.shift(); + x_array = jQuery.map( x_array, function( a ) { + return parse_callnumber( a ); + }); + y_array = jQuery.map( y_array, function( a ) { + return parse_callnumber( a ); + }); + x_array.sort(); y_array.sort(); x = x_array.pop(); y = y_array.pop(); + if ( !x ) { x = ""; } + if ( !y ) { y = ""; } + return ((x < y) ? 1 : ((x > y) ? -1 : 0)); }; + +function parse_callnumber ( html ) { + var array = html.split(''); + if ( array[1] ) { + array = array[1].split(''); + return array[0]; + } else { + return ""; + } +} 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 38270f1..9743bf1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt @@ -326,7 +326,7 @@ function placeHold () { [% IF ( BIBLIO_RESULT.ITEM_RESULTS ) %] [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %] -
[% ITEM_RESULT.itemcallnumber %] [% ITEM_RESULT.branchname %] [% ITEM_RESULT.location_description %]
+
[% ITEM_RESULT.itemcallnumber %] [% ITEM_RESULT.branchname %] [% ITEM_RESULT.location_description %]
[% END %] [% ELSE %] This record has no items. -- 1.7.10.4