Summary: | Amounts in funds table on acquisitions home page not sorting correctly | ||
---|---|---|---|
Product: | Koha | Reporter: | Katrin Fischer <katrin.fischer> |
Component: | Templates | Assignee: | Owen Leonard <oleonard> |
Status: | CLOSED FIXED | QA Contact: | Kyle M Hall (khall) <kyle> |
Severity: | minor | ||
Priority: | P5 - low | CC: | gmcharlt, kyle, tomascohen |
Version: | Main | ||
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: | ||
Circulation function: | |||
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 |
Created attachment 20805 [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] 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. [2] Apply the patch. [3] 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> Created attachment 20839 [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] 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. [2] Apply the patch. [3] 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: Chris Cormack <chris@bigballofwax.co.nz> 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.
Created attachment 20858 [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> Created attachment 20859 [details] [review] [SIGNED OFF] 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. 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 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> Pushed to master. Galen, this doesn't apply cleanly on 3.12.x. |
Created attachment 20674 [details] funds table, showing wrong sorting The amounts in the fund table on the acquisitions home page are not sorting correctly.