From c5e3197b9f46555125e6f6ea622bd4ecaacd8bde Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 28 Nov 2024 16:20:24 +0100 Subject: [PATCH] Bug 38255: Replace dataTable constructor with kohaTable - Staff Signed-off-by: Lucas Gass --- .../prog/en/modules/acqui/basket.tt | 15 +- .../prog/en/modules/acqui/basketgroup.tt | 52 +++--- .../prog/en/modules/acqui/booksellers.tt | 18 +- .../prog/en/modules/acqui/invoice-files.tt | 12 +- .../prog/en/modules/acqui/invoice.tt | 28 ++- .../prog/en/modules/acqui/invoices.tt | 14 +- .../en/modules/acqui/newordersubscription.tt | 12 +- .../en/modules/acqui/newordersuggestion.tt | 12 +- .../prog/en/modules/acqui/ordered.tt | 10 +- .../prog/en/modules/acqui/parcel.tt | 31 ++-- .../prog/en/modules/acqui/parcels.tt | 6 +- .../prog/en/modules/acqui/spent.tt | 10 +- .../prog/en/modules/acqui/supplier.tt | 10 +- .../prog/en/modules/acqui/uncertainprice.tt | 10 +- .../prog/en/modules/acqui/z3950_search.tt | 18 +- .../en/modules/admin/additional-fields.tt | 19 +- .../prog/en/modules/admin/aqbudgetperiods.tt | 25 +-- .../modules/admin/auth_subfields_structure.tt | 10 +- .../en/modules/admin/auth_tag_structure.tt | 10 +- .../modules/admin/branch_transfer_limits.tt | 13 +- .../prog/en/modules/admin/cash_registers.tt | 12 +- .../prog/en/modules/admin/credit_types.tt | 4 +- .../prog/en/modules/admin/debit_types.tt | 4 +- .../prog/en/modules/admin/koha2marclinks.tt | 10 +- .../prog/en/modules/admin/localization.tt | 14 +- .../en/modules/admin/marc-overlay-rules.tt | 4 +- .../prog/en/modules/admin/marctagstructure.tt | 10 +- .../prog/en/modules/admin/oai_servers.tt | 10 +- .../prog/en/modules/admin/overdrive.tt | 10 +- .../en/modules/admin/systempreferences.tt | 14 +- .../prog/en/modules/admin/z3950servers.tt | 10 +- .../prog/en/modules/catalogue/detail.tt | 12 +- .../en/modules/catalogue/search-history.tt | 18 +- .../modules/cataloguing/z3950_auth_search.tt | 14 +- .../prog/en/modules/circ/article-requests.tt | 25 +-- .../prog/en/modules/circ/checkout-notes.tt | 14 +- .../circ/circulation_batch_checkouts.tt | 16 +- .../prog/en/modules/circ/on-site_checkouts.tt | 2 +- .../prog/en/modules/circ/returns.tt | 15 +- .../prog/en/modules/circ/transfers_to_send.tt | 16 +- .../en/modules/circ/transferstoreceive.tt | 16 +- .../prog/en/modules/clubs/club-enrollments.tt | 12 +- .../prog/en/modules/clubs/clubs.tt | 26 ++- .../prog/en/modules/clubs/patron-clubs-tab.tt | 12 +- .../en/modules/labels/label-edit-batch.tt | 16 +- .../prog/en/modules/labels/label-manage.tt | 12 +- .../en/modules/members/alert-subscriptions.tt | 3 +- .../prog/en/modules/members/discharges.tt | 4 +- .../prog/en/modules/members/notices.tt | 8 +- .../modules/members/purchase-suggestions.tt | 12 +- .../prog/en/modules/members/statistics.tt | 8 +- .../prog/en/modules/members/update-child.tt | 14 +- .../prog/en/modules/patron_lists/lists.tt | 12 +- .../modules/patron_lists/patron-lists-tab.tt | 12 +- .../prog/en/modules/patroncards/edit-batch.tt | 18 +- .../intranet-tmpl/prog/en/modules/pos/pay.tt | 4 +- .../prog/en/modules/pos/register.tt | 8 +- .../prog/en/modules/pos/registers.tt | 8 +- .../en/modules/recalls/recalls_to_pull.tt | 14 +- .../en/modules/recalls/recalls_waiting.tt | 12 +- .../en/modules/reports/cash_register_stats.tt | 8 +- .../modules/reports/guided_reports_start.tt | 4 +- .../prog/en/modules/reports/itemtypes.tt | 8 +- .../prog/en/modules/reports/serials_stats.tt | 6 +- .../prog/en/modules/reserve/request.tt | 9 +- .../prog/en/modules/serials/claims.tt | 14 +- .../en/modules/serials/serials-collection.tt | 20 +-- .../prog/en/modules/serials/serials-search.tt | 50 +++--- .../serials/subscription-numberpatterns.tt | 10 +- .../prog/en/modules/tags/list.tt | 12 +- .../prog/en/modules/tools/access_files.tt | 10 +- .../en/modules/tools/additional-contents.tt | 14 +- .../en/modules/tools/batch_delete_records.tt | 36 ++-- .../modules/tools/batch_extend_due_dates.tt | 32 ++-- .../tools/batch_record_modification.tt | 32 ++-- .../prog/en/modules/tools/holidays.tt | 26 +-- .../en/modules/tools/manage-marc-import.tt | 4 +- .../prog/en/modules/tools/overduerules.tt | 12 +- .../prog/en/modules/tools/problem-reports.tt | 14 +- .../prog/en/modules/tools/quotes-upload.tt | 2 +- .../prog/en/modules/virtualshelves/shelves.tt | 4 +- .../intranet-tmpl/prog/js/addorderiso2709.js | 16 +- koha-tmpl/intranet-tmpl/prog/js/authtype.js | 14 +- .../intranet-tmpl/prog/js/biblio_framework.js | 14 +- koha-tmpl/intranet-tmpl/prog/js/cart.js | 20 +-- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 2 +- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 16 +- .../prog/js/elasticsearch-mappings.js | 16 +- koha-tmpl/intranet-tmpl/prog/js/holds.js | 2 +- .../prog/js/marc_subfields_structure.js | 14 +- .../prog/js/pages/preferences.js | 16 +- .../prog/js/pages/tags-review.js | 14 +- koha-tmpl/intranet-tmpl/prog/js/recalls.js | 14 +- .../prog/js/rotating-collections.js | 16 +- .../intranet-tmpl/prog/js/subscription-add.js | 4 +- .../ERM/EHoldingsEBSCOTitlePackagesList.vue | 163 +++++++++--------- .../ERM/EHoldingsLocalTitlePackagesList.vue | 3 +- .../ERM/EHoldingsLocalTitlesFormImport.vue | 110 ++++++------ .../prog/js/vue/components/ResourceBase | 0 99 files changed, 755 insertions(+), 826 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceBase diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index 3ba9f929461..f08c3e5553d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -1159,17 +1159,18 @@ $(document).ready(function() { var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'basket', 'orders', 'json' ) | $raw %]; [% IF !(Koha.Preference('EDIFACT') && ediaccount) %] + // FIXME This cannot work correctly without bKohaColumnsUseNames table_settings['columns'].splice(18, 1); [% END %] - KohaTable("orders", { - "pagingType": "full", - "autoWidth": false, - "exportColumns": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18[% IF (Koha.Preference('EDIFACT') && ediaccount) %],19[% END %]], + $("#orders").kohaTable({ + pagingType: "full", + autoWidth: false, + exportColumns: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18[% IF (Koha.Preference('EDIFACT') && ediaccount) %],19[% END %]], }, table_settings); - var cancelledorderst = $("#cancelledorderst").dataTable($.extend(true, {}, dataTablesDefaults, { - "pagingType": "full" - } ) ); + $("#cancelledorderst").kohaTable({ + pagingType: "full" + }); $("#reopenform").on("submit",function(e){ var skip = [% IF ( skip_confirm_reopen ) %] 1 [% ELSE %] 0 [% END %]; var is_confirmed = skip || confirm(_("Are you sure you want to reopen this basket?")); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt index 8278005b2ff..c98ea862c2e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt @@ -399,34 +399,32 @@ $("#basket_groups a[href='#opened']").tab("show"); [% END %] [% UNLESS ( grouping ) %] - $("table").dataTable($.extend(true, {}, dataTablesDefaults, { - "columnDefs": [ - { "targets": [ -1 ], "orderable": false, "searchable": false }, - ], - "autoWidth": false, - "pagingType": "full" - } )); + let dt_params = { + columnDefs: [{ targets: [-1], orderable: false, searchable: false }], + autoWidth: false, + pagingType: "full", + }; + $("#ungrouped").kohaTable(dt_params); + $("#grouped").kohaTable(dt_params); + $("#basket_group_opened").kohaTable(dt_params); + $("#basket_group_closed").kohaTable(dt_params); [% ELSE %] - grouped = $("#grouped").DataTable($.extend(true, {}, dataTablesDefaults, { - "dom": 't', - "columnDefs": [ - { 'sortable': false, 'targets': [ 'NoSort' ] } - ], - 'autoWidth': false, - "language": { - "emptyTable": _("There are no baskets in this group") - } - } )); - ungrouped = $("#ungrouped").DataTable($.extend(true, {}, dataTablesDefaults, { - "dom": 't', - "columnDefs": [ - { 'sortable': false, 'targets': [ 'NoSort' ] } - ], - 'autoWidth': false, - "language": { - "emptyTable": _("There are no ungrouped baskets") - } - } )); + grouped = $("#grouped").kohaTable({ + dom: "t", + columnDefs: [{ sortable: false, targets: ["NoSort"] }], + autoWidth: false, + language: { + emptyTable: _("There are no baskets in this group"), + }, + }); + ungrouped = $("#ungrouped").kohaTable({ + dom: "t", + columnDefs: [{ sortable: false, targets: ["NoSort"] }], + autoWidth: false, + language: { + emptyTable: _("There are no ungrouped baskets"), + }, + }); [% END %] $("#basketgroupcolumns").on("click", ".addtogroup", function(){ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt index efd6a578fb7..16428f244b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt @@ -263,16 +263,14 @@ [% Asset.js("js/acq.js") | $raw %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 0d3d2a16ed2..b3ade8daa82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -372,19 +372,21 @@ }); if ( $("#receivedt").length ) { - var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, { - "stateSave": true, // We do not have table settings on this table - "pageLength": 10, - "lengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], - "columnDefs": [ - { "targets": [ 5, -1 ], "orderable": false, "searchable": false }, + var receivedt = $("#receivedt").kohaTable({ + stateSave: true, // We do not have table settings on this table + pageLength: 10, + lengthMenu: [ + [5, 10, 20, 50, 100, -1], + [5, 10, 20, 50, 100, _("All")], ], - "columns": [ - { "type": "html" }, - { "type": "html" }, - { "type": "html" }, - { "type": "num-html" }, - { "type": "anti-the" }, + columnDefs: [{ targets: [5, -1], orderable: false, searchable: false }], + columns: [ + { type: "html" }, + { type: "html" }, + { type: "html" }, + { type: "num-html" }, + { type: "anti-the" }, + null, null, null, null, @@ -392,10 +394,9 @@ null, null, null, - null ], - "pagingType": "full" - })); + pagingType: "full", + }); } var options = { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt index 14653654fc1..c4d00f246c4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -263,9 +263,9 @@ [% INCLUDE 'datatables.inc' %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt index 4ef054da936..5995fae3b6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt @@ -690,12 +690,12 @@ } $(document).ready(function() { - var contractst = $("#contractst").dataTable($.extend(true, {}, dataTablesDefaults, { - "columnDefs": [ - { "orderable": false, "searchable": false, "targets": [ 'NoSort' ] } + var contractst = $("#contractst").kohaTable({ + columnDefs: [ + { orderable: false, searchable: false, targets: [ 'NoSort' ] } ], - "dom": 't' - } ) ); + dom: 't' + } ); $('body').on('click', '.delete-contact', null, delete_contact); $('#add-contact').click(add_contact); $('body').on('click', '.contact_acqprimary', null, function () { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt index 820e49373cd..8415f0373c1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt @@ -183,12 +183,10 @@ [% INCLUDE 'datatables.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt index 638cd39ab40..54d7b4c7618 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt @@ -310,14 +310,17 @@ $('#selecttable').submit(); }); - $("#fieldst").dataTable($.extend(true, {}, dataTablesDefaults, { - "autoWidth": false, - "dom": 't<"bottom pager"ilpf>', - "pagingType": 'full', - "lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]], - "pageLength": 20, - "order": [[ 0, "asc" ]], - })); + $("#fieldst").kohaTable({ + autoWidth: false, + dom: 't<"bottom pager"ilpf>', + pagingType: "full", + lengthMenu: [ + [10, 20, 50, 100, -1], + [10, 20, 50, 100, "All"], + ], + pageLength: 20, + order: [[0, "asc"]], + }); $("#add_field").on('submit', function() { if ( $("#marcfield").length && $("select[name='authorised_value_category']").length ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt index d9fc1223c3e..3ce557eb3c8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt @@ -565,18 +565,19 @@ $("#budgetsTabs li:eq([% tab | html %]) a").tab("show"); [% END %] - $("#activeperiodst,#inactiveperiodst").dataTable($.extend(true, {}, dataTablesDefaults, { - "columnDefs": [ - { "targets": [ -1 ], "orderable": false, "searchable": false }, - ], - "pagingType": "full", - "autoWidth": false - } ) ); + let dt_params = { + columnDefs: [{ targets: [-1], orderable: false, searchable: false }], + pagingType: "full", + autoWidth: false, + }; + + $("#activeperiodst").kohaTable(dt_params); + $("#inactiveperiodst").kohaTable(dt_params); [% IF close_form %] - $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, { - "dom": "t" - })); + $("#budgeth").kohaTable({ + dom: "t", + }); $("#move_form").submit(function(){ var budget_from = "[% budget_period_description | html %]"; var budget_to = $("#to_budget_period_id").find("option:selected").html(); @@ -586,7 +587,7 @@ }); [% END %] [% IF closed %] - var oTable = $("#closed_report").dataTable($.extend(true, {}, dataTablesDefaults, { + var oTable = $("#closed_report").kohaTable({ // The following is a c/p from aqbudgets.tt and is a candidate for refactoring. "drawCallback": function ( oSettings ) { if ( oSettings.aiDisplay.length == 0 ) @@ -622,7 +623,7 @@ "orderFixed": [[ 1, 'asc' ]], "autoWidth": false, "pagingType": "full_numbers" - })); + }); [% END %] $("#add_modify_budget").validate({ rules: { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt index 9afca612843..e68e58a45ff 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt @@ -411,13 +411,11 @@ [% Asset.js("js/admin-menu.js") | $raw %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt index 71cc0446c89..85b33038154 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt @@ -167,12 +167,13 @@ }) }); - $(".sorted").dataTable($.extend(true, {}, dataTablesDefaults, { - "columnDefs": [ - { "targets": [ -1 ], "orderable": false, "searchable": false }, - ], - "paginate": false - })); + + [% FOREACH codes_loo IN codes_loop %] + $("#[% codes_loo.code | html %]table").kohaTable({ + columnDefs: [{ targets: [-1], orderable: false, searchable: false }], + paginate: false, + }); + [% END %] }); [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cash_registers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cash_registers.tt index 43e99fe29aa..2250ea8f8d6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cash_registers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cash_registers.tt @@ -264,13 +264,11 @@ } $(document).ready(function() { - var crtable = $("#table_cash_registers").DataTable($.extend(true, {}, dataTablesDefaults, { - "columnDefs": [ - { "targets": [ -1, -2 ], "orderable": false, "searchable": false }, - ], - "order": [[ 1, "asc" ]], - "paginationType": "full", - })); + var crtable = $("#table_cash_registers").kohaTable({ + columnDefs: [{ targets: [-1, -2], orderable: false, searchable: false }], + order: [[1, "asc"]], + paginationType: "full", + }); $("#branch_filter").on("change", function(){ // Table must be filtered by the