From 3bbdc28f106beed08398df269ce1a22c4514c6ba Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 28 Jan 2013 14:37:42 -0500 Subject: [PATCH] Bug 9456 [Alternate] Add callnumber column to the cart - Followup - Sort by callnumbers This patch removes the sub-tables for callnumber/location, and simply surrounds them with a span tag. Sorting is enabled on the 'Items' column which uses a custom sorting routine to sort the callnumbers. If the sort is ascending, each column will be sorted by the highest ordered callnumber for that row. Likewise, if the sort is descending the table will be sorted by the lowest valued callnumber for that row. --- .../intranet-tmpl/prog/en/modules/basket/basket.tt | 67 +++++++++++++------- 1 files changed, 44 insertions(+), 23 deletions(-) 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 85bfa20..d7ddd76 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt @@ -91,18 +91,51 @@ function placeHold () { $(".hold").text(_("Place Hold")); $("#downloadcartc").empty(); yuiToolbar(); + + /* Define two custom functions (asc and desc) for string sorting */ + jQuery.fn.dataTableExt.oSort['callnumbers-asc'] = function(x,y) { + var x_array = x.split(""); + var y_array = y.split(""); + + /* Pop the first elements, they are empty strings */ + x_array.shift(); + y_array.shift(); + + x_array.sort(); + y_array.sort(); + + x = x_array.shift(); + y = y_array.shift(); + + return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + }; + + jQuery.fn.dataTableExt.oSort['callnumbers-desc'] = function(x,y) { + var x_array = x.split(""); + var y_array = y.split(""); + + /* Pop the first elements, they are empty strings */ + x_array.shift(); + y_array.shift(); + + x_array.sort(); + y_array.sort(); + + x = x_array.pop(); + y = y_array.pop(); + + return ((x < y) ? 1 : ((x > y) ? -1 : 0)); + }; + $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, { "sDom": 't', "aoColumnDefs": [ - { "aTargets": [ 0,3 ], "bSortable": false, "bSearchable": false }, + { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }, + { "aTargets": [ 3 ], "sType": 'callnumbers' }, ], "aaSorting": [[ 1, "asc" ]], "bPaginate": false })); - $(".itemstable").dataTable($.extend(true, {}, dataTablesDefaults, { - "sDom": 't', - "bPaginate": false - })); }); @@ -383,26 +416,14 @@ function yuiToolbar() { [% BIBLIO_RESULT.description %] - [% IF ( BIBLIO_RESULT.ITEM_RESULTS ) %] - - - - - - + - - - + [% ITEM_RESULT.itemcallnumber %] [% ITEM_RESULT.branchname %] [% ITEM_RESULT.location_description %] [% END %] - -
LocationCall number
+ [% IF ( BIBLIO_RESULT.ITEM_RESULTS ) %] [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %] -
[% ITEM_RESULT.branchname %] [% ITEM_RESULT.location_description %] - [% IF ( ITEM_RESULT.itemcallnumber ) %] - ([% ITEM_RESULT.itemcallnumber %]) - [% END %] -
- [% ELSE %]This record has no items.[% END %] + [% ELSE %] + This record has no items. + [% END %] [% END %] -- 1.7.2.5