Bug 29949 - Remove use of title-numeric sorting routine from OPAC datatables JS
Summary: Remove use of title-numeric sorting routine from OPAC datatables JS
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-26 12:18 UTC by Owen Leonard
Modified: 2022-02-07 17:30 UTC (History)
2 users (show)

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


Attachments
Bug 29949: Remove use of title-numeric sorting routine from OPAC datatables JS (5.74 KB, patch)
2022-01-26 12:33 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29949: Remove use of title-numeric sorting routine from OPAC datatables JS (5.80 KB, patch)
2022-01-26 16:36 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 29949: Remove use of title-numeric sorting routine from OPAC datatables JS (5.85 KB, patch)
2022-01-29 23:54 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2022-01-26 12:18:28 UTC
There is one template in the OPAC, opac-topissues.tt, which uses a special DataTables sorting routine called "title-numeric." This can be replaced with sorting via a data-order attribute, and the custom routine can be removed.
Comment 1 Owen Leonard 2022-01-26 12:33:15 UTC
Created attachment 129824 [details] [review]
Bug 29949: Remove use of title-numeric sorting routine from OPAC datatables JS

This patch removes the use of a specific "title-numeric" sorting routine
from the DataTables configuration of the "Most popular" table. We can
use a "data-order" attribute instead.

The patch also removes the now unused code from our custom DataTables JS
file in both the OPAC and the staff interface (where it was unused).

To test, apply the patch and make sure the OpacTopissue system
preference is enabled.

- In the OPAC, view the "Most popular" page.
- Change the filter settings, if necessary, to get multiple results.
- In the results table, confirm that sorting by number of checkouts
  still works correctly.

A search of the code for instances of "title-numeric" should return only
one in a comment in the official DataTables library.
Comment 2 Lucas Gass 2022-01-26 16:36:21 UTC
Created attachment 129836 [details] [review]
Bug 29949: Remove use of title-numeric sorting routine from OPAC datatables JS

This patch removes the use of a specific "title-numeric" sorting routine
from the DataTables configuration of the "Most popular" table. We can
use a "data-order" attribute instead.

The patch also removes the now unused code from our custom DataTables JS
file in both the OPAC and the staff interface (where it was unused).

To test, apply the patch and make sure the OpacTopissue system
preference is enabled.

- In the OPAC, view the "Most popular" page.
- Change the filter settings, if necessary, to get multiple results.
- In the results table, confirm that sorting by number of checkouts
  still works correctly.

A search of the code for instances of "title-numeric" should return only
one in a comment in the official DataTables library.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 3 Lucas Gass 2022-01-26 16:37:26 UTC
before patch:

root@kohadevbox:koha(master)$ git grep 'title-numeric'
koha-tmpl/intranet-tmpl/lib/datatables/datatables.js:                    *    $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
koha-tmpl/intranet-tmpl/prog/js/datatables.js: *        { "sType": "title-numeric" },
koha-tmpl/intranet-tmpl/prog/js/datatables.js:    "title-numeric-pre": function ( a ) {
koha-tmpl/intranet-tmpl/prog/js/datatables.js:    "title-numeric-asc": function ( a, b ) {
koha-tmpl/intranet-tmpl/prog/js/datatables.js:    "title-numeric-desc": function ( a, b ) {
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt:                    { "type": "title-numeric", "targets" : [ "title-num"] },
koha-tmpl/opac-tmpl/bootstrap/js/datatables.js: *        { "sType": "title-numeric" },
koha-tmpl/opac-tmpl/bootstrap/js/datatables.js:    "title-numeric-pre": function ( a ) {
koha-tmpl/opac-tmpl/bootstrap/js/datatables.js:    "title-numeric-asc": function ( a, b ) {
koha-tmpl/opac-tmpl/bootstrap/js/datatables.js:    "title-numeric-desc": function ( a, b ) {


after patch:

root@kohadevbox:koha(master)$ git grep 'title-numeric'
koha-tmpl/intranet-tmpl/lib/datatables/datatables.js:                    *    $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
Comment 4 Katrin Fischer 2022-01-29 23:54:24 UTC
Created attachment 129972 [details] [review]
Bug 29949: Remove use of title-numeric sorting routine from OPAC datatables JS

This patch removes the use of a specific "title-numeric" sorting routine
from the DataTables configuration of the "Most popular" table. We can
use a "data-order" attribute instead.

The patch also removes the now unused code from our custom DataTables JS
file in both the OPAC and the staff interface (where it was unused).

To test, apply the patch and make sure the OpacTopissue system
preference is enabled.

- In the OPAC, view the "Most popular" page.
- Change the filter settings, if necessary, to get multiple results.
- In the results table, confirm that sorting by number of checkouts
  still works correctly.

A search of the code for instances of "title-numeric" should return only
one in a comment in the official DataTables library.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Fridolin Somers 2022-02-01 07:57:32 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄