From dc26f6c1ed5f86d64973d666e1b443fd881fc4bb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 2 Dec 2024 13:38:51 +0100 Subject: [PATCH] Bug 38255: Replace dataTable constructor with kohaTable - OPAC Signed-off-by: Lucas Gass --- .../bootstrap/en/modules/clubs/clubs-tab.tt | 20 +++++------ .../bootstrap/en/modules/opac-account.tt | 12 +++---- .../en/modules/opac-alert-subscriptions.tt | 3 +- .../opac-authoritiessearchresultlist.tt | 18 +++++----- .../bootstrap/en/modules/opac-basket.tt | 18 +++------- .../en/modules/opac-curbside-pickups.tt | 18 +++++----- .../en/modules/opac-full-serial-issues.tt | 6 ++-- .../bootstrap/en/modules/opac-idref.tt | 10 +++--- .../bootstrap/en/modules/opac-illrequests.tt | 10 +++--- .../bootstrap/en/modules/opac-messaging.tt | 18 +++++----- .../bootstrap/en/modules/opac-recalls.tt | 18 +++++----- .../bootstrap/en/modules/opac-suggestions.tt | 4 +-- .../bootstrap/en/modules/opac-tags.tt | 24 ++++++------- .../bootstrap/en/modules/opac-topissues.tt | 22 ++++++------ .../bootstrap/en/modules/opac-user.tt | 22 ++++++------ .../bootstrap/en/modules/sco/sco-main.tt | 36 +++++++++---------- .../bootstrap/js/ill-availability.js | 4 +-- 17 files changed, 120 insertions(+), 143 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt index a76bc5f1396..618fdf86864 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt @@ -105,18 +105,18 @@ function cancelEnrollment( id ) { var Tables = $("#clubs-table-enrolled,#clubs-table-unenrolled"); Tables.each(function(){ - $(this).dataTable($.extend(true, {}, dataTablesDefaults, { - "searching": false, - "paging": false, - "info": false, - "responsive": { - "details": { "type": "column", "target": -1 } + $(this).kohaTable({ + searching: false, + paging: false, + info: false, + responsive: { + details: { type: "column", target: -1 }, }, - "columnDefs": [ - { "orderable": false, "searchable": false, "targets": [ 'NoSort' ] }, - { "className": "dtr-control", "orderable": false, "targets": -1 }, + columnDefs: [ + { orderable: false, searchable: false, targets: ["NoSort"] }, + { className: "dtr-control", orderable: false, targets: -1 }, ], - })); + }); }); $(".cancel_enrollment").on("click", function(e){ diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt index fb82df67786..4190bfdd8c2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt @@ -85,7 +85,7 @@ $( document ).ready(function() { var txtActivefilter = _("Filter paid transactions"); var txtInactivefilter = _("Show all transactions"); - var fines_table = $("#finestable").dataTable($.extend(true, {}, dataTablesDefaults, { + var fines_table = $("#finestable").kohaTable({ [% IF ENABLE_OPAC_PAYMENTS %] "order": [[ 1, "desc" ]], [% ELSE %] @@ -98,22 +98,22 @@ $( document ).ready(function() { "columnDefs": [ { "className": 'dtr-control', "orderable": false, "targets": -1 } ], - 'fnDrawCallback': function() { + 'drawCallback': function() { show_hiddentfoot('#finestable'); } - } )); + } ); - $('table[id^="finestable-"]').dataTable($.extend(true, {}, dataTablesDefaults, { + $('table[id^="finestable-"]').kohaTable({ "responsive": { "details": { "type": 'column',"target": -1 } }, "columnDefs": [ { "className": 'dtr-control', "orderable": false, "targets": -1 } ], - 'fnDrawCallback': function() { + 'drawCallback': function() { show_hiddentfoot('table[id^="finestable-"]'); } - } )); + }); function show_hiddentfoot(selector) { $('.finestable tfoot .sum').show(); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscriptions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscriptions.tt index e413ee30b41..2ce3ab369de 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscriptions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscriptions.tt @@ -100,8 +100,7 @@ [% INCLUDE 'datatables.inc' %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt index c4b5ad9bf02..117952f020e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt @@ -498,19 +498,11 @@ }); if( $("#itemst").length > 0 ){ - var itemst = $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, { - "order": [[ 1, "asc" ]], - "columnDefs": [ - { "targets": [ 0,-1 ], "sortable": false, "searchable": false } - ], - "columns": [ - null, - { "type": "anti-the" }, - null, - null, - null - ], - })); + var itemst = $("#itemst").kohaTable({ + order: [[1, "asc"]], + columnDefs: [{ targets: [0, -1], sortable: false, searchable: false }], + columns: [null, { type: "anti-the" }, null, null, null], + }); var buttons = new $.fn.dataTable.Buttons(itemst, { buttons: [ diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt index e6e1fc10d6a..9578a04824d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt @@ -321,17 +321,15 @@ }); $(document).ready(function() { - $('#pickups-table').dataTable($.extend(true, {}, dataTablesDefaults, { - "searching": false, - "paging": false, - "info": false, - "responsive": { - "details": { "type": 'column',"target": -1 } + $("#pickups-table").kohaTable({ + searching: false, + paging: false, + info: false, + responsive: { + details: { type: "column", target: -1 }, }, - "columnDefs": [ - { "className": 'dtr-control', "orderable": false, "targets": -1 } - ], - })); + columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }], + }); $("#pickup-branch option").each(function(){ if ( $(this).val() != "" && !policies[$(this).val()].enabled ) { $(this).prop("disabled", "disabled"); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt index ad7d20e6bdb..94a5232a9ad 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt @@ -203,9 +203,9 @@ $(this).addClass("currentsubtab"); showlayer( year ); }); - $(".subscriptionstclass").dataTable($.extend(true, {}, dataTablesDefaults, { - "order": [[ 0, "desc" ]] - })); + $(".subscriptionstclass").kohaTable({ + order: [[0, "desc"]], + }); }); // Filters initialization diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-idref.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-idref.tt index 202ca28fe4c..c239a1a676b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-idref.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-idref.tt @@ -52,12 +52,10 @@ [% INCLUDE 'datatables.inc' %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt index 0fc9c1413e5..71d0e795dc6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt @@ -135,16 +135,16 @@ $(".cancel_recall").click(function(){ return confirmDelete(_("Are you sure you want to remove this recall?")); }); - $("#recalls-table").dataTable($.extend(true, {}, dataTablesDefaults, { - "responsive": { - "details": { "type": 'column', "target": -1 } + $("#recalls-table").kohaTable({ + responsive: { + details: { type: "column", target: -1 }, }, - "columnDefs": [ - { "targets": [ "nosort" ],"sortable": false,"searchable": false }, - { "type": "anti-the", "targets" : [ "anti-the" ] }, - { "className": "dtr-control", "orderable": false, "targets": -1 } - ] - })); + columnDefs: [ + { targets: ["nosort"], sortable: false, searchable: false }, + { type: "anti-the", targets: ["anti-the"] }, + { className: "dtr-control", orderable: false, targets: -1 }, + ], + }); }); [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index 1a9c43bc12a..cf4925be4e1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -564,7 +564,7 @@ [% END %] $(function() { - $("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, { + $("#suggestt").kohaTable({ "order": [[ 1, "asc" ]], "columnDefs": [ [% IF ( loggedinusername ) %]{ "targets": [ 0 ], "sortable": false, "searchable": false }[% END %], @@ -587,7 +587,7 @@ target: -1 } }, - })); + }); [% IF ( loggedinusername ) %]$("span.clearall").html(""+_("Clear all")+"<\/a>"); $("span.checkall").html(""+_("Select all")+"<\/a>"); $("#CheckAll").on("click",function(e){ diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt index 9c167ad8d32..2f907cdc49d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt @@ -259,21 +259,21 @@ } }); - $("#mytagst").dataTable($.extend(true, {}, dataTablesDefaults, { - "sorting": [[ 2, "asc" ]], - "columnDefs": [ - { "targets": [ 0 ], "sortable": false, "searchable": false }, - { "sType": "anti-the", "aTargets" : [ "anti-the" ] }, - { "className": 'dtr-control', "orderable": false, "targets": -1 }, - { responsivePriority: 1, targets: 2 } + $("#mytagst").kohaTable({ + sorting: [[2, "asc"]], + columnDefs: [ + { targets: [0], sortable: false, searchable: false }, + { sType: "anti-the", aTargets: ["anti-the"] }, + { className: "dtr-control", orderable: false, targets: -1 }, + { responsivePriority: 1, targets: 2 }, ], - "responsive": { + responsive: { details: { - type: 'column', - target: -1 - } + type: "column", + target: -1, + }, }, - })); + }); }); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt index 0e34c229b6b..2a71cdcef75 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt @@ -145,20 +145,20 @@ [% INCLUDE 'datatables.inc' %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index a2b2f208fd2..16dce0edbef 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -1205,7 +1205,7 @@ $(this).on("init.dt", function() { tableInit( $(this).attr("id") ); }) - .dataTable($.extend(true, {}, dataTablesDefaults, { + .kohaTable({ "sorting" : [[ thIndex, 'asc' ]], "dom": '<"top"<"table_entries"><"table_controls"fB>>t', "columnDefs": [ @@ -1242,22 +1242,20 @@ } } ] - })); + }); }); var dataTables = $("#recalls-table,#article-requests-table"); dataTables.each(function(){ - $(this).dataTable($.extend(true, {}, dataTablesDefaults, { - "searching": false, - "paging": false, - "info": false, - "responsive": { - "details": { "type": 'column',"target": -1 } + $(this).kohaTable({ + searching: false, + paging: false, + info: false, + responsive: { + details: { type: "column", target: -1 }, }, - "columnDefs": [ - { "className": 'dtr-control', "orderable": false, "targets": -1 } - ], - })); + columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }], + }); }); $('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (event) { dTables.DataTable().responsive.recalc(); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 92c4b69146a..26f243e0b64 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -592,27 +592,27 @@ var dTables = $("#loanTable, #holdst, #finestable"); dTables.each(function(){ var thIndex = $(this).find("th.psort").index(); - $(this).dataTable($.extend(true, {}, dataTablesDefaults, { - "sorting" : [[ thIndex, 'asc' ]], - "dom": '<"top"<"table_entries"><"table_controls"f>>t<"clear">', - "columnDefs": [ - { "targets": [ "nosort" ],"sortable": false,"searchable": false }, - { "targets": [ "noshow" ], "visible": false, "searchable": false }, - { "type": "anti-the", "targets" : [ "anti-the" ] }, - { "visible": false, "targets" : [ "hidden" ] }, - { "className": 'dtr-control', "orderable": false, "targets": -1 } + $(this).kohaTable({ + sorting: [[thIndex, "asc"]], + dom: '<"top"<"table_entries"><"table_controls"f>>t<"clear">', + columnDefs: [ + { targets: ["nosort"], sortable: false, searchable: false }, + { targets: ["noshow"], visible: false, searchable: false }, + { type: "anti-the", targets: ["anti-the"] }, + { visible: false, targets: ["hidden"] }, + { className: "dtr-control", orderable: false, targets: -1 }, ], - "language": { - "search": "_INPUT_", - "searchPlaceholder": _("Search") + language: { + search: "_INPUT_", + searchPlaceholder: _("Search"), }, - "responsive": { + responsive: { details: { - type: 'column', - target: -1 - } - } - })); + type: "column", + target: -1, + }, + }, + }); }); $('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (event) { diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js b/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js index 560803fffb2..2091ddfd780 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js @@ -186,9 +186,7 @@ $(document).ready(function() { }); } // Initialise the table - $('#'+service.id ).dataTable( - $.extend(true, {}, dataTablesDefaults, tableDef) - ); + $('#'+service.id ).kohaTable(tableDef); }); } -- 2.34.1