From 0883327bb18f9b3e809245cde1f0674619b82274 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 | 2 +- .../opac-authoritiessearchresultlist.tt | 20 +++++------ .../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 | 22 ++++++------ .../bootstrap/en/modules/opac-suggestions.tt | 4 +-- .../bootstrap/en/modules/opac-tags.tt | 30 ++++++++-------- .../bootstrap/en/modules/opac-topissues.tt | 28 +++++++-------- .../bootstrap/en/modules/opac-user.tt | 22 ++++++------ .../bootstrap/en/modules/sco/sco-main.tt | 36 +++++++++---------- .../bootstrap/js/ill-availability.js | 4 +-- 17 files changed, 126 insertions(+), 154 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 794d220958a..aceb02c9f06 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 @@ -98,18 +98,18 @@ 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 2361186f7ba..5516ba07437 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt @@ -89,7 +89,7 @@ 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 %] @@ -102,22 +102,22 @@ "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 5410cf76515..5dfb2b398cc 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 @@ -101,7 +101,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 5dbed63b306..3f4c2fd139f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt @@ -544,19 +544,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 638742ab4e8..1bc70627f5b 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 @@ -325,17 +325,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 cb8dafccc7b..7708778a899 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 @@ -207,9 +207,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 78dbee485d2..9ec31d5c025 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 7de5d93ae3c..06a79b2eba3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt @@ -135,18 +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 }, - }, - columnDefs: [ - { targets: ["nosort"], sortable: false, searchable: false }, - { type: "anti-the", targets: ["anti-the"] }, - { className: "dtr-control", orderable: false, targets: -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 }, + ], + }); }); [% 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 9587f799fc8..23e6c98331a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -595,7 +595,7 @@ [% END %] $(function() { - $("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, { + $("#suggestt").kohaTable({ "order": [[ 1, "asc" ]], "columnDefs": [ [% IF ( loggedinusername ) %]{ "targets": [ 0 ], "sortable": false, "searchable": false }[% END %], @@ -618,7 +618,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 c6a6b1fc778..13a442a9352 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt @@ -295,23 +295,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 }, - ], - responsive: { - details: { - type: "column", - target: -1, - }, + $("#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: { + details: { + type: "column", + target: -1, }, - }) - ); + }, + }); }); [% END %] 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 7d83096822f..36c1cea0831 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt @@ -147,22 +147,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 438878a6f15..d63eab89983 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -1204,7 +1204,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": [ @@ -1241,22 +1241,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 e0e60ce1484..5e74f6d6d83 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 @@ -457,27 +457,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 0f3f3e7bd7b..49631c9ce1a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js @@ -199,9 +199,7 @@ $(document).ready(function () { }); }; // Initialise the table - $("#" + service.id).dataTable( - $.extend(true, {}, dataTablesDefaults, tableDef) - ); + $("#" + service.id).kohaTable(tableDef); }); }; }); -- 2.34.1