Bugzilla – Attachment 13494 Details for
Bug 9061
DataTables date sort does not work with date in uk format (dd/mm/yyyy)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[Signed off] Bug 9061 - DataTables date sort does not work with date in uk format (dd/mm/yyyy)
Signed-off-Bug-9061---DataTables-date-sort-does-no.patch (text/plain), 4.59 KB, created by
Melia Meggs
on 2012-11-16 19:03:41 UTC
(
hide
)
Description:
[Signed off] Bug 9061 - DataTables date sort does not work with date in uk format (dd/mm/yyyy)
Filename:
MIME Type:
Creator:
Melia Meggs
Created:
2012-11-16 19:03:41 UTC
Size:
4.59 KB
patch
obsolete
>From cbde9c1c068b0efa71c1afd49c2e50e6361a4e03 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 12 Nov 2012 15:29:28 -0500 >Subject: [PATCH] [Signed off] Bug 9061 - DataTables date sort does not work with date in uk format (dd/mm/yyyy) > >The DataTables plugin doesn't include native support for sorting date >in uk/euro format (dd/mm/yyyy). This patch adds a plugin to be >optionally included in cases where the Koha dateformat preference >is set to "metric." > >The patron circulation history page is the only page affected by this >patch. If it is found to be working well I will submit follow-ups >to cover other instances where sorting by date occurs. > >To test, load the patron circulation history page (members/readingrec.pl) >for a patron with a circulation history. Sorting by "date," "checked out >on," "date due," and "Return date" should work correctly with under >all three dateformat settings. > >Signed-off-by: Melia Meggs <melia@test.bywatersolutions.com> >--- > .../prog/en/js/datatables.date-euro.js | 44 ++++++++++++++++++++ > .../prog/en/modules/members/readingrec.tt | 8 +++- > 2 files changed, 50 insertions(+), 2 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/datatables.date-euro.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.date-euro.js b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.date-euro.js >new file mode 100644 >index 0000000..e744d0b >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.date-euro.js >@@ -0,0 +1,44 @@ >+/* Adapted from sorting plugin found at http://datatables.net/plug-ins/sorting, >+ "Date (dd/mm/YYY hh:ii:ss)," by Ronan Guilloux. Original plugin did not >+ account for variation in input string */ >+ >+jQuery.extend( jQuery.fn.dataTableExt.oSort, { >+ "date-euro-pre": function ( a ) { >+ // function should work with strings like "dd/mm/yyyy hh:mm:ss" or "dd/mm/yyyy" >+ // function doesn't validate the date, just checks for valid structure >+ var x; >+ var dateTimeParts; >+ var dateParts; >+ var timeParts; >+ if ($.trim(a) !== '') { >+ dateTimeParts = $.trim(a).split(' '); >+ dateParts = dateTimeParts[0].split('/'); >+ if( dateParts.length == 3 ){ >+ // validish date format >+ if( dateTimeParts.length > 1){ >+ // there is a time portion >+ timeParts = dateTimeParts[1].split(':'); >+ if( timeParts.length > 1 ){ >+ // validish time portion >+ x = (dateParts[2] + dateParts[1] + dateParts[0] + timeParts[0] + timeParts[1] + timeParts[2]) * 1; >+ } >+ } else { >+ x = (dateParts[2] + dateParts[1] + dateParts[0]) * 1; >+ } >+ } else { >+ x = 10000000000000; // = l'an 1000 ... >+ } >+ } else { >+ x = 10000000000000; // = l'an 1000 ... >+ } >+ return x; >+ }, >+ >+ "date-euro-asc": function ( a, b ) { >+ return a - b; >+ }, >+ >+ "date-euro-desc": function ( a, b ) { >+ return b - a; >+ } >+} ); >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt >index b7c5f53..1b86667 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt >@@ -1,15 +1,19 @@ > [% USE KohaDates %] > [% INCLUDE 'doc-head-open.inc' %] >-<title>Circulation History for [% INCLUDE 'patron-title.inc' %]</title> >+<title>Circulation history for [% INCLUDE 'patron-title.inc' %]</title> > [% INCLUDE 'doc-head-close.inc' %] > <link rel="stylesheet" type="text/css" href="/intranet-tmpl/prog/en/css/datatables.css" /> > <script type="text/javascript" src="/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.dataTables.min.js"></script> > [% INCLUDE 'datatables-strings.inc' %] > <script type="text/javascript" src="/intranet-tmpl/prog/en/js/datatables.js"></script> >+[% IF ( dateformat_metric ) %]<script type="text/javascript" src="/intranet-tmpl/prog/en/js/datatables.date-euro.js"></script>[% END %] > <script type="text/javascript" id="js">$(document).ready(function() { > $(document).ready(function() { > $("#table_readingrec").dataTable($.extend(true, {}, dataTablesDefaults, { >- "sPaginationType": "four_button", >+ "sPaginationType": "four_button" >+ [% IF ( dateformat_metric ) %], "aoColumnDefs": [ >+ { "sType": "date-euro", "aTargets": [ 0,6,8,9 ] } >+ ][% END %] > })); > }); > }); </script> >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9061
:
13493
| 13494