Bug 29949

Summary: Remove use of title-numeric sorting routine from OPAC datatables JS
Product: Koha Reporter: Owen Leonard <oleonard>
Component: OPACAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: kyle, lucas
Version: master   
Hardware: All   
OS: All   
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
Bug 29949: Remove use of title-numeric sorting routine from OPAC datatables JS
Bug 29949: Remove use of title-numeric sorting routine from OPAC datatables JS

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 🦄