Bug 39715

Summary: Do not quote DataTables options
Product: Koha Reporter: Owen Leonard <oleonard>
Component: TemplatesAssignee: Owen Leonard <oleonard>
Status: Pushed to main --- QA Contact: Lucas Gass (lukeg) <lucas>
Severity: enhancement    
Priority: P5 - low CC: dcook, jonathan.druart, lucas
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: Medium patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This patch updates templates so that the options passed to DataTables, via KohaTable, are not quoted. The quotes are not necessary, and are not consistent with official DataTables documentation. This establishes a standard for us to follow in the future.
Version(s) released in:
26.05.00
Circulation function:
Bug Depends on:    
Bug Blocks: 41324, 41563, 41564, 41565, 41566, 41567, 41568, 41569, 41573, 41575, 41579, 41580, 41581, 41582    
Attachments: Bug 39715: Do not quote DataTables options
Descriptions of updated pages
Bug 39715: Do not quote DataTables options
Bug 39715: Do not quote DataTables options
Bug 39715: Do not quote DataTables options
Bug 39715: Do not quote DataTables options
Bug 39715: Do not quote DataTables options
Bug 39715: (follow-up) Undo change to shelves_results.tt
Bug 39715: (follow-up) Undo change to shelves_results.tt
Bug 39715: Do not quote DataTables options
Bug 39715: (follow-up) Undo change to shelves_results.tt

Description Owen Leonard 2025-04-23 16:42:02 UTC
Koha templates are inconsistent when it comes to quoting DataTables options:

(https://gitlab.com/koha-community/Koha/-/blob/main/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt#L221)

var cities_table = $("#table_cities").kohaTable({
    "ajax": {
        "url": cities_table_url
    },
    "order": [[ 1, "asc" ]],
    "columnDefs": [ {
        "targets": [0,1,2,3,4],
        "render": function (data, type, row, meta) {
            if ( type == 'display' ) {
                if ( data != null ) {
                    return data.escapeHtml();
                } else {
                    return "";
                }
            }
            return data;
        }
    } ],

Options in this example like "ajax", "order", and "columnDefs" are quoted in this example but other templates will have unquoted options. I think we should standardize on having no quotes around the options. The quotes are unnecessary, and inconsistent with up-to-date DataTables documentation.
Comment 1 Owen Leonard 2025-06-06 11:11:06 UTC Comment hidden (obsolete)
Comment 2 Owen Leonard 2025-06-06 11:13:05 UTC
Created attachment 183068 [details]
Descriptions of updated pages
Comment 3 Owen Leonard 2025-06-24 19:15:10 UTC
Created attachment 183473 [details] [review]
Bug 39715: Do not quote DataTables options

This patch updates templates so that the options passed to DataTables
(via kohaTable) are not quoted. The quotes are not necessary, and
are not consistent with official DataTables documentation. This
establishes a standard for us to follow in the future.

The patch also corrects some option names which required upates,
particularly "sorting" -> "order".

To test, apply the patch and test updated DataTables.

Sponsored-by: Athens County Public Libraries
Comment 4 Owen Leonard 2025-09-08 17:55:09 UTC
Created attachment 186267 [details] [review]
Bug 39715: Do not quote DataTables options

This patch updates templates so that the options passed to DataTables
(via kohaTable) are not quoted. The quotes are not necessary, and
are not consistent with official DataTables documentation. This
establishes a standard for us to follow in the future.

The patch also corrects some option names which required upates,
particularly "sorting" -> "order".

To test, apply the patch and test updated DataTables.

Sponsored-by: Athens County Public Libraries
Comment 5 Owen Leonard 2025-10-28 11:02:20 UTC
Created attachment 188502 [details] [review]
Bug 39715: Do not quote DataTables options

This patch updates templates so that the options passed to DataTables
(via kohaTable) are not quoted. The quotes are not necessary, and
are not consistent with official DataTables documentation. This
establishes a standard for us to follow in the future.

The patch also corrects some option names which required upates,
particularly "sorting" -> "order".

To test, apply the patch and test updated DataTables.

Sponsored-by: Athens County Public Libraries
Comment 6 Jonathan Druart 2025-11-27 14:17:51 UTC
Created attachment 189993 [details] [review]
Bug 39715: Do not quote DataTables options

This patch updates templates so that the options passed to DataTables
(via kohaTable) are not quoted. The quotes are not necessary, and
are not consistent with official DataTables documentation. This
establishes a standard for us to follow in the future.

The patch also corrects some option names which required upates,
particularly "sorting" -> "order".

To test, apply the patch and test updated DataTables.

Sponsored-by: Athens County Public Libraries

Rebased-by: Jonathan Druart
paginate => paging

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Owen Leonard 2026-01-05 13:16:04 UTC
Created attachment 190886 [details] [review]
Bug 39715: Do not quote DataTables options

This patch updates templates so that the options passed to DataTables
(via kohaTable) are not quoted. The quotes are not necessary, and
are not consistent with official DataTables documentation. This
establishes a standard for us to follow in the future.

The patch also corrects some option names which required upates,
particularly "sorting" -> "order".

To test, apply the patch and test updated DataTables.

Sponsored-by: Athens County Public Libraries

Rebased-by: Jonathan Druart
paginate => paging

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Jonathan Druart 2026-01-08 15:33:36 UTC
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt

-    "data": [
+    data: [

This breaks the JSON response of the svc/virtualshelves/search script (Something went wrong when loading the table.)
Comment 9 Owen Leonard 2026-01-08 16:12:59 UTC
Created attachment 191028 [details] [review]
Bug 39715: (follow-up) Undo change to shelves_results.tt

This must have been an overzealous find and replace. A similar template,
itemsearch_json.tt, was not similarly affected.
Comment 10 Jonathan Druart 2026-01-09 08:36:28 UTC
Created attachment 191046 [details] [review]
Bug 39715: (follow-up) Undo change to shelves_results.tt

This must have been an overzealous find and replace. A similar template,
itemsearch_json.tt, was not similarly affected.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 11 Lucas Gass (lukeg) 2026-01-21 21:26:30 UTC
Created attachment 191840 [details] [review]
Bug 39715: Do not quote DataTables options

This patch updates templates so that the options passed to DataTables
(via kohaTable) are not quoted. The quotes are not necessary, and
are not consistent with official DataTables documentation. This
establishes a standard for us to follow in the future.

The patch also corrects some option names which required upates,
particularly "sorting" -> "order".

To test, apply the patch and test updated DataTables.

Sponsored-by: Athens County Public Libraries

Rebased-by: Jonathan Druart
paginate => paging

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 12 Lucas Gass (lukeg) 2026-01-21 21:26:32 UTC
Created attachment 191841 [details] [review]
Bug 39715: (follow-up) Undo change to shelves_results.tt

This must have been an overzealous find and replace. A similar template,
itemsearch_json.tt, was not similarly affected.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 13 Lucas Gass (lukeg) 2026-01-23 14:30:09 UTC
Nice work everyone!

Pushed to main for 26.05