From 8c44ae90af723368be24729431c1fb74014baaac Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 22 Apr 2025 17:45:33 +0000 Subject: [PATCH] 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 --- .../tables/items/catalogue_detail.inc | 3 +- .../prog/en/includes/patron-search.inc | 162 +++++++++--------- .../prog/en/modules/acqui/acqui-home.tt | 14 +- .../prog/en/modules/acqui/edifactmsgs.tt | 74 ++++---- .../prog/en/modules/acqui/lateorders.tt | 8 +- .../prog/en/modules/acqui/orderreceive.tt | 128 +++++++------- .../prog/en/modules/acqui/parcel.tt | 84 ++++----- .../prog/en/modules/acqui/parcels.tt | 2 +- .../prog/en/modules/admin/aqbudgetperiods.tt | 16 +- .../prog/en/modules/admin/aqbudgets.tt | 18 +- .../modules/admin/auth_subfields_structure.tt | 1 - .../prog/en/modules/admin/background_jobs.tt | 66 +++---- .../prog/en/modules/admin/branches.tt | 84 ++++----- .../prog/en/modules/admin/cities.tt | 48 +++--- .../admin/identity_provider_domains.tt | 64 +++---- .../en/modules/admin/marc-overlay-rules.tt | 22 +-- .../prog/en/modules/admin/smtp_servers.tt | 68 ++++---- .../prog/en/modules/bookings/list.tt | 76 ++++---- .../prog/en/modules/catalogue/detail.tt | 128 +++++++------- .../prog/en/modules/catalogue/itemsearch.tt | 20 +-- .../prog/en/modules/cataloguing/concerns.tt | 52 +++--- .../circ/circulation_batch_checkouts.tt | 3 +- .../prog/en/modules/circ/curbside_pickups.tt | 2 +- .../prog/en/modules/circ/pendingbookings.tt | 92 +++++----- .../prog/en/modules/clubs/patron-clubs-tab.tt | 2 +- .../prog/en/modules/members/discharges.tt | 1 - .../prog/en/modules/patron_lists/lists.tt | 2 +- .../intranet-tmpl/prog/en/modules/pos/pay.tt | 33 ++-- .../prog/en/modules/pos/register.tt | 38 ++-- .../modules/reports/guided_reports_start.tt | 8 +- .../prog/en/modules/reports/itemslost.tt | 1 - .../prog/en/modules/suggestion/suggestion.tt | 2 +- .../en/modules/tools/batch_delete_records.tt | 6 +- .../modules/tools/batch_extend_due_dates.tt | 1 - .../tools/batch_record_modification.tt | 6 +- .../prog/en/modules/tools/inventory.tt | 14 +- .../en/modules/tools/manage-marc-import.tt | 30 ++-- .../prog/en/modules/virtualshelves/shelves.tt | 34 ++-- .../virtualshelves/tables/shelves_results.tt | 2 +- .../intranet-tmpl/prog/js/addorderiso2709.js | 1 - koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 1 - .../prog/js/marc_subfields_structure.js | 1 - .../bootstrap/en/modules/opac-account.tt | 26 +-- .../en/modules/opac-course-reserves.tt | 2 +- .../bootstrap/en/modules/opac-detail.tt | 2 +- .../bootstrap/en/modules/opac-holdshistory.tt | 2 +- .../bootstrap/en/modules/opac-suggestions.tt | 10 +- .../bootstrap/en/modules/opac-tags.tt | 2 +- .../bootstrap/en/modules/opac-topissues.tt | 2 +- .../bootstrap/en/modules/opac-user.tt | 18 +- .../bootstrap/en/modules/sco/sco-main.tt | 2 +- 51 files changed, 735 insertions(+), 749 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 67440510e69..d7f72296a4a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -337,8 +337,7 @@ var items_table = $("#" + tab_id + '_table').kohaTable({ ajax: { url: item_table_url }, - order: [], - embed, + embed, autoWidth: false, bKohaColumnsUseNames: true, columns: [ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index 85184bdc6aa..206b646a410 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -476,9 +476,9 @@ [% SET embed = ['extended_attributes','library'] %] let table_node = $("#[% table_id | html %]"); patrons_table = table_node.kohaTable({ - "ajax": { - "url": patron_search_url, - "dataSrc": function ( json ) { + ajax: { + url: patron_search_url, + dataSrc: function ( json ) { [% IF redirect_if_one_result %] // redirect if there is only 1 result. // Do not redirect if state has been loaded @@ -496,7 +496,7 @@ } }, [% IF open_on_row_click OR preview_on_name_click OR remember_selections %] - "drawCallback": function( settings ) { + drawCallback: function( settings ) { var api = this.api(); var data = api.data(); if ( data.length == 0 ) return; @@ -520,8 +520,8 @@ [% END %] }, [% END %] - "deferLoading": defer_loading, - "columns": [ + deferLoading: defer_loading, + columns: [ [% FOR column IN columns %] [% IF default_sort_column == column %] [% order_column_index = loop.count - 1%] @@ -529,19 +529,19 @@ [% SWITCH column %] [% CASE 'checkbox' %] { - "data": "patron_id", - "searchable": false, - "orderable": false, - "render": function( data, type, row, meta ) { + data: "patron_id", + searchable: false, + orderable: false, + render: function( data, type, row, meta ) { return ""; } } [% CASE 'cardnumber' %] { - "data": "cardnumber", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "cardnumber", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { let patron_id = encodeURIComponent(row.patron_id); [% IF !open_on_row_click AND CAN_user_circulate_circulate_remaining_permissions %] return "" + escape_str(data) + ""; @@ -553,20 +553,20 @@ } [% CASE 'dateofbirth' %] { - "data": "date_of_birth", - "type": "date", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "date_of_birth", + type: "date", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { return data ? "" + escape_str($date(data)) + " (" + _("%s years").format($get_age(data)) + ")" : ""; } } [% CASE 'address' %] { - "data": "me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { let r = '
'; @@ -575,10 +575,10 @@ } [% CASE 'address-library' %] { - "data": "me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { let r = '
'; @@ -588,10 +588,10 @@ } [% CASE 'name-address' %] { - "data": "me.surname:me.preferred_name:me.firstname:me.middle_name:me.othernames:me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "me.surname:me.preferred_name:me.firstname:me.middle_name:me.othernames:me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { let patron_id = encodeURIComponent(row.patron_id); let r = ''; [% IF ! open_on_row_click %] @@ -613,10 +613,10 @@ } [% CASE 'name' %] { - "data": "me.surname:me.preferred_name:me.firstname:me.middle_name:me.othernames", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "me.surname:me.preferred_name:me.firstname:me.middle_name:me.othernames", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { let patron_id = encodeURIComponent(row.patron_id); [% IF ! open_on_row_click %] return "" + $patron_to_html(row, { invert_name: 1 }) + ""; @@ -627,10 +627,10 @@ } [% CASE 'branch' %] { - "data": "library.name:me.library_id", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "library.name:me.library_id", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { if( !singleBranchMode && row.library.library_id == logged_in_library_id ) { return "" + escape_str(row.library.name) + ""; } else { @@ -640,45 +640,45 @@ } [% CASE 'category' %] { - "data": "category_id", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "category_id", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { return escape_str(categories_map[data.toLowerCase()].description); } } [% CASE 'dateexpiry' %] { - "data": "expiry_date", - "type": "date", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "expiry_date", + type: "date", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { return "" + (data ? escape_str($date(data)) : '') + ""; } } [% CASE 'borrowernotes' %] { - "data": "staff_notes", - "searchable": true, - "orderable": true, + data: "staff_notes", + searchable: true, + orderable: true, [%# We don't escape here, we allow html tag in staff notes %] } [% CASE 'phone' %] { - "data": "phone", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "phone", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { return escape_str(data); } } [% CASE 'checkouts' %][% embed.push('checkouts+count', 'overdues+count') %] { - "data": "", - "searchable": false, - "orderable": false, - "render": function( data, type, row, meta ) { + data: "", + searchable: false, + orderable: false, + render: function( data, type, row, meta ) { if ( row.overdues_count ) { return ""+row.overdues_count + "" + " / " + row.checkouts_count; } else { @@ -688,10 +688,10 @@ } [% CASE 'account_balance' %][% embed.push('account_balance') %] { - "data": "", - "searchable": false, - "orderable": false, - "render": function( data, type, row, meta ) { + data: "", + searchable: false, + orderable: false, + render: function( data, type, row, meta ) { let r = ""; let balance_str = row.account_balance || 0; balance_str = balance_str.escapeHtml().format_price(); @@ -711,10 +711,10 @@ [% CASE 'sort1' %] { - "data": "statistics_1", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "statistics_1", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { if (data === null) return ''; let bsort1 = av_bsort1_map[data.toString()]; return escape_str(bsort1 ? bsort1.lib : data); @@ -723,10 +723,10 @@ [% CASE 'sort2' %] { - "data": "statistics_2", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { + data: "statistics_2", + searchable: true, + orderable: true, + render: function( data, type, row, meta ) { if (data === null) return ''; let bsort2 = av_bsort2_map[data.toString()]; return escape_str(bsort2 ? bsort2.lib : data); @@ -736,7 +736,7 @@ [% CASE 'action' %] { - "data": function( row, type, val, meta ) { + data: function( row, type, val, meta ) { let patron_id = encodeURIComponent(row.patron_id); let action_node = ""; @@ -764,21 +764,21 @@ return action_node; }, - "searchable": false, - "orderable": false + searchable: false, + orderable: false } [% END %] [% UNLESS loop.last %],[% END %] [% END %] ], - 'embed': [% To.json(embed) | $raw %], - "order": [[ [% order_column_index | html %], "asc" ]], - "autoWidth": false, - 'lengthMenu': [aLengthMenu, aLengthMenuLabel], - "pagingType": 'full_numbers', - "pageLength": [% Koha.Preference('PatronsPerPage') | html %], + embed: [% To.json(embed) | $raw %], + order: [[ [% order_column_index | html %], "asc" ]], + autoWidth: false, + lengthMenu: [aLengthMenu, aLengthMenuLabel], + pagingType: 'full_numbers', + pageLength: [% Koha.Preference('PatronsPerPage') | html %], [% IF sticky_header %] - "initComplete": function(settings, json) { + initComplete: function(settings, json) { $("#[% sticky_header | html %]").show(); }, [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt index 1951395a132..7049c2f18e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt @@ -213,7 +213,7 @@ $(document).ready(function() { var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'acq_acqui-home', 'accounts', 'json' ) | $raw %]; var oTable = $("#accounts").kohaTable({ - "drawCallback": function ( oSettings ) { + drawCallback: function ( oSettings ) { if ( oSettings.aiDisplay.length == 0 ) { return; @@ -239,17 +239,17 @@ } } }, - "footerCallback": function ( row, data, start, end, display ) { + footerCallback: function ( row, data, start, end, display ) { var api = this.api(), data; footer_column_sum( api, [ 6, 7, 8, 9 ] ); }, - "columnDefs": [ + columnDefs: [ { "orderable": false, "targets": ["_all"] } ], - "ordering": true, - "orderFixed": [[ 1, 'asc' ]], - "paginate": false, - "autoWidth": false + ordering: true, + orderFixed: [[ 1, 'asc' ]], + paginate: false, + autoWidth: false }, table_settings ); let table_dt = oTable.DataTable(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt index 1c8d8a56a17..f191dac9d59 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt @@ -80,37 +80,37 @@ let edi_msgs_table_url = '/api/v1/acquisitions/edifiles?'; var edi_msgs_table = $("#edi_msgs").kohaTable({ - "ajax": { + ajax: { "url": edi_msgs_table_url }, - "embed": [ + embed: [ "vendor", "basket", "errors" ], - "order": [[ 1, "desc" ]], - "columns": [ + order: [[ 1, "desc" ]], + columns: [ { - "data": "type", - "title": _("Type"), - "searchable": true, - "orderable": true + data: "type", + title: _("Type"), + searchable: true, + orderable: true }, { - "data": "transfer_date", - "title": _("Transferred"), - "searchable": true, - "orderable": true, - "render": function(data, type, row, meta) { + data: "transfer_date", + title: _("Transferred"), + searchable: true, + orderable: true, + render: function(data, type, row, meta) { return $date(row.transfer_date); } }, { - "data": "status", - "title": _("Status"), - "searchable": true, - "orderable": true, - "render": function(daya, type, row, meta) { + data: "status", + title: _("Status"), + searchable: true, + orderable: true, + render: function(daya, type, row, meta) { let rendered = ''; if ( row.errors.length > 0 ) { let errorsList = '