From 1c93bb3267252e6b62320126acc388f7321c0876 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 2 May 2025 16:13:20 +0100 Subject: [PATCH] Bug 39779: (QA follow-up) Undo revert and instead call .api() This patch leaves Laura's patch intact for the record, but effectively reverts it's reversion of bug 38255 in which all ajax DataTables were converted to a standard kohaTable instantiation structure. We need a DataTable() api in subsequent uses of the table and not the jQuery object that kohaTable returns so I update all calls to saleDataTable to sale_kohaTable.api() which returns us the DataTable() api instance from the dataTable jQuery object. Signed-off-by: Martin Renvoize --- koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt index b2de99c85bd..a1eca52972b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt @@ -335,7 +335,7 @@ $(document).ready(function() { const sale_table = document.getElementById('sale'); - const saleDataTable = $("#sale").DataTable({ + const sale_kohaTable = $("#sale").kohaTable({ "paginate": false, "searching": false, "info": false, @@ -364,7 +364,7 @@ "rowCallback": function( row, data ) { const total = data[1] * data[2]; data[3] = total; - saleDataTable.cell(row, 3).invalidate(); + sale_kohaTable.api().cell(row, 3).invalidate(); }, "footerCallback": function(tfoot, data, start, end, display) { let total_price = 0; @@ -387,7 +387,7 @@ }); $("#sale").on("click", "button.drop", function(){ - saleDataTable.row($(this).parents('tr')).remove().draw(false); + sale_kohaTable.api().row($(this).parents('tr')).remove().draw(false); }); // Set up editable columns based on header classes @@ -430,7 +430,7 @@ function updateCell() { const newValue = input.value.trim() || originalContent; // Fallback to original content cell.textContent = newValue; // Set the final value in the cell - saleDataTable.cell(cell).data(newValue).invalidate().draw(false); // Update DataTable data + sale_kohaTable.api().cell(cell).data(newValue).invalidate().draw(false); // Update dataTable data } } }); @@ -448,7 +448,7 @@ $("#invoices").on("click", ".add_button", function(e) { e.preventDefault(); - fnClickAddRow(saleDataTable, $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') ); + fnClickAddRow(sale_kohaTable.api(), $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') ); if($('#invoices_filter').find('input[type=search]').val() !== ''){ items_table.DataTable().search('').draw(); } @@ -494,12 +494,12 @@ }); } - // now, process the current & fresh contents of the saleDataTable + // now, process the current & fresh contents of the sale_kohaTable if (change != undefined && change.innerHTML > 0.00 && !checked) { e.preventDefault(); $("#confirm_change_form").modal("show"); } else { - var rows = saleDataTable.data().toArray(); + var rows = sale_kohaTable.api().data().toArray(); rows.forEach(function (row, index) { var sale = { code: row[5], -- 2.49.0