Bug 10792

Summary: Amounts in funds table on acquisitions home page not sorting correctly
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: TemplatesAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Kyle M Hall <kyle>
Severity: minor    
Priority: P5 - low CC: gmcharlt, kyle, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: funds table, showing wrong sorting
Bug 10792: fix sorting of funds table on acquisitions home page
Bug 10792: fix sorting of funds table on acquisitions home page
Screenshot of acquisiton funds table with non-working sort and patch applied
Bug 10792: fix sorting of funds table on acquisitions home page
[SIGNED OFF] Bug 10792: fix sorting of funds table on acquisitions home page
Bug 10792: fix sorting of funds table on acquisitions home page

Description Katrin Fischer 2013-08-27 21:24:52 UTC
Created attachment 20674 [details]
funds table, showing wrong sorting

The amounts in the fund table on the acquisitions home page are not sorting correctly.
Comment 1 Galen Charlton 2013-09-05 16:29:59 UTC Comment hidden (obsolete)
Comment 2 Chris Cormack 2013-09-07 00:36:02 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2013-09-07 18:39:59 UTC
Created attachment 20855 [details]
Screenshot of acquisiton funds table with non-working sort and patch applied

Sadly, this doesn't work for me. I tested in 2 different browsers (Firefox and Chromium), reloading the Javascript files multiple times.

Error shown in firebug:
datatables.js, line 513
TypeError: a.match(...) is null
var x = a.match(/title="*(-?[0-9\.]+)/)[1];

Screenshot of my acquisitions table attached.
Comment 4 Galen Charlton 2013-09-07 18:57:48 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2013-09-07 19:12:25 UTC Comment hidden (obsolete)
Comment 6 Kyle M Hall 2013-09-12 14:25:16 UTC
I'm afraid I cannot reproduce the correct behavior with the patch applied. Please let me know if I'm testing incorrectly: http://screencast.com/t/qX21hg9M
Comment 7 Kyle M Hall 2013-09-12 14:51:06 UTC
Created attachment 21046 [details] [review]
Bug 10792: fix sorting of funds table on acquisitions home page

This patch introduces a DataTables sorting plugin, title-numeric,
for sorting cells based on a decimal number embedded in a span title
attribute.  This allows currency amounts to be formatted properly
for display without having to writing a sorting plugin that's
super-smart about removing the formatting, particularly for locales
that use a comma as the decimal mark.

The sorter plugin can be used like this:

- In the DataTables config:

"aoColumns": [
   { "sType": "title-numeric" },
]

- In the table data

<td><span title="[% decimal_number_that_JS_parseFloat_accepts %]">
    [% formatted currency %]
</span></td>

To test:

[1] Ensure that there is at least one active budget and at least
    one inactive one.
[2] Go to the acquisitions home page.  Note that changing the sort order
    on the amount, ordered, spent, or avail columns results in incorrect
    sorting that is either ASCII-betical or which ignores any component
    of large numbers that occur after the thousands separator.
[3] Apply the patch.
[4] Verify that the sorting now works correctly and that no JavaScript
    errors appear in the JS debug console of your choice.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Sorting now works correctly, for active and inactive funds.
Passes all tests and QA script.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 8 Galen Charlton 2013-09-16 15:31:00 UTC
Pushed to master.
Comment 9 Tomás Cohen Arazi 2013-11-06 16:30:58 UTC
Galen, this doesn't apply cleanly on 3.12.x.