From 1b10a6f3a0e07ab79abbbdec1a215a1cd8235ccd Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 22 Jul 2013 07:43:13 -0400 Subject: [PATCH] Bug 9456: (follow-up) sort on callnumber only Signed-off-by: Jonathan Druart Signed-off-by: Galen Charlton --- .../intranet-tmpl/prog/en/js/datatables.js | 30 +++++++++++++++++++ .../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 5015da2b9f..ee7f039c4d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js @@ -590,12 +590,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)); }; @@ -607,11 +617,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 38270f1f47..9743bf107d 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. -- 2.39.5