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 <m.de.rooy@rijksmuseum.nl>
Tested yearly repeatables under Calendar for all three date formats.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
(cherry picked from commit 9a168e7c94)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
(cherry picked from commit c52d62d92a)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Owen Leonard 2011-12-06 15:09:27 -05:00 committed by Chris Nighswonger
parent f8c821ba18
commit 659fd64f4b
1 changed files with 31 additions and 6 deletions

View File

@ -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 @@
<table id="holidaysyearlyrepeatable">
<thead>
<tr>
[% IF ( dateformat == 'metric' ) %]
[% IF ( dateformat_metric ) %]
<th class="repeatableyearly">Day/Month</th>
[% ELSE %]
<th class="repeatableyearly">Month/Day</th>