From 22bbefba640f5a117e14070f3f29f83c939274fc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 5 Mar 2013 13:52:20 +0100 Subject: [PATCH] Bug 9747: Fix NSB/NSE sorting issues on z3950 search results MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit At least the BNF server returns results containing non-sorting characters (NSB/NSE). In order to sort results according these characters, this patch adds a new Datatable function. Test plan: - search 'tintin' on the z3950 search (cataloguing/z3950_search.pl) - sort on title (default sort) and check that results are not well sorted. - apply this patch - do the same search and check that the first result is "Hergé. Les Aventures de Tintin..." The value of the cell is: ˆHergé. Les ‰Aventures de Tintin... Signed-off-by: Chris Cormack Works as advertised and doesn't break existing searching Signed-off-by: Galen Charlton --- koha-tmpl/intranet-tmpl/prog/en/js/datatables.js | 16 +++++++++++++++- .../prog/en/modules/cataloguing/z3950_search.tt | 1 + 2 files changed, 16 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 d2433926af..cca389d8db 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js @@ -471,6 +471,7 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, { } ); }()); + /* Plugin to allow sorting on data stored in a span's title attribute * * Ex: [% formatted_date %] @@ -495,7 +496,6 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, { } } ); - /* Plugin to allow sorting on numeric data stored in a span's title attribute * * Ex: @@ -566,3 +566,17 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, { }); }()); + +// Remove string between NSB NSB characters +$.fn.dataTableExt.oSort['nsb-nse-asc'] = function(a,b) { + var pattern = new RegExp("\x88.*\x89"); + a = a.replace(pattern, ""); + b = b.replace(pattern, ""); + return (a > b) ? 1 : ((a < b) ? -1 : 0); +} +$.fn.dataTableExt.oSort['nsb-nse-desc'] = function(a,b) { + var pattern = new RegExp("\x88.*\x89"); + a = a.replace(pattern, ""); + b = b.replace(pattern, ""); + return (b > a) ? 1 : ((b < a) ? -1 : 0); +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt index 7e5b0af340..d8d370e392 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt @@ -33,6 +33,7 @@ $(document).ready(function(){ "sDom": 't', "aoColumnDefs": [ { "aTargets": [ -1,-2,-3 ], "bSortable": false, "bSearchable": false }, + { "aTargets": [ 1 ], "sType": "nsb-nse" }, ], "aaSorting": [[ 1, "asc" ]], "bPaginate": false -- 2.39.5