From 9a168e7c9451e1960dadbecf83ba937851840310 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 6 Dec 2011 15:09:27 -0500 Subject: [PATCH] Bug 3806 - Holidays table doesn't order by date correcly Adding dateformat filter to JavaScript tablesorter configurations. Follow-up adds a custom date parser for dates without year ("01/10") Signed-off-by: Marcel de Rooy Tested yearly repeatables under Calendar for all three date formats. Signed-off-by: Paul Poulain --- .../prog/en/modules/tools/holidays.tt | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt index 19b2309042..686e3af350 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt @@ -84,20 +84,45 @@ newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes'); } $(document).ready(function() { + +[% IF ( dateformat_metric ) %] $.tablesorter.addParser({ // http://tablesorter.com/docs/example-parsers.html + id: 'shortDates', + is: function(s){ + return false; + }, + format: function(s){ + var datepattern = new RegExp("[0-9]\/[0-9]"); + if( datepattern.test(s)){ // sorting a date without a year: "01/12" + var dateparts = s.split("/").reverse().join("-"); // build an ISO date to be sorted as text + s = "2000-" + dateparts; // use 2000 as the default year + } + return s; + }, + type: 'text' + }); +[% END %] $(".hint").hide(); $("#branch").change(function(){ changeBranch(); }); - $("#holidayexceptions").tablesorter({ + $("#holidayexceptions").tablesorter({[% IF ( dateformat_metric ) %] + dateFormat: 'uk',[% END %] sortList: [[0,0]], widgets: ['zebra'] }); - $("#holidayweeklyrepeatable").tablesorter({ + $("#holidayweeklyrepeatable").tablesorter({[% IF ( dateformat_metric ) %] + dateFormat: 'uk',[% END %] sortList: [[0,0]], widgets: ['zebra'] }); - $("#holidaysyearlyrepeatable").tablesorter({ - sortList: [[0,0]], widgets: ['zebra'] + $("#holidaysyearlyrepeatable").tablesorter({[% IF ( dateformat_metric ) %] + headers : { + 0: { + sorter : 'shortDates' + } + },[% END %] + sortList: [[0,0]], widgets: ['zebra'] }); - $("#holidaysunique").tablesorter({ + $("#holidaysunique").tablesorter({[% IF ( dateformat_metric ) %] + dateFormat: 'uk',[% END %] sortList: [[0,0]], widgets: ['zebra'] }); $("a.helptext").click(function(){ @@ -438,7 +463,7 @@ - [% IF ( dateformat == 'metric' ) %] + [% IF ( dateformat_metric ) %] [% ELSE %] -- 2.20.1
Day/MonthMonth/Day