Bug 39715 - Do not quote DataTables options
Summary: Do not quote DataTables options
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-23 16:42 UTC by Owen Leonard
Modified: 2025-06-24 19:15 UTC (History)
0 users

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


Attachments
Bug 39715: Do not quote DataTables options (150.96 KB, patch)
2025-06-06 11:11 UTC, Owen Leonard
Details | Diff | Splinter Review
Descriptions of updated pages (1.71 KB, text/plain)
2025-06-06 11:13 UTC, Owen Leonard
Details
Bug 39715: Do not quote DataTables options (150.22 KB, patch)
2025-06-24 19:15 UTC, Owen Leonard
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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
Created attachment 183067 [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 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