Bug 10792 - Amounts in funds table on acquisitions home page not sorting correctly
Summary: Amounts in funds table on acquisitions home page not sorting correctly
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Owen Leonard
QA Contact: Kyle M Hall (khall)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-27 21:24 UTC by Katrin Fischer
Modified: 2014-05-26 21:04 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
funds table, showing wrong sorting (10.61 KB, image/png)
2013-08-27 21:24 UTC, Katrin Fischer
Details
Bug 10792: fix sorting of funds table on acquisitions home page (5.53 KB, patch)
2013-09-05 16:29 UTC, Galen Charlton
Details | Diff | Splinter Review
Bug 10792: fix sorting of funds table on acquisitions home page (5.59 KB, patch)
2013-09-07 00:36 UTC, Chris Cormack
Details | Diff | Splinter Review
Screenshot of acquisiton funds table with non-working sort and patch applied (29.57 KB, image/png)
2013-09-07 18:39 UTC, Katrin Fischer
Details
Bug 10792: fix sorting of funds table on acquisitions home page (7.01 KB, patch)
2013-09-07 18:57 UTC, Galen Charlton
Details | Diff | Splinter Review
[SIGNED OFF] Bug 10792: fix sorting of funds table on acquisitions home page (3.37 KB, patch)
2013-09-07 19:12 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 10792: fix sorting of funds table on acquisitions home page (7.21 KB, patch)
2013-09-12 14:51 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 (khall) 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 (khall) 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 (tcohen) 2013-11-06 16:30:58 UTC
Galen, this doesn't apply cleanly on 3.12.x.