Bug 39715

Summary: Do not quote DataTables options
Product: Koha Reporter: Owen Leonard <oleonard>
Component: TemplatesAssignee: Owen Leonard <oleonard>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
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
Descriptions of updated pages
Bug 39715: Do not quote DataTables options

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