Bug 40161: (bug 38255 follow-up) Fix item type translation JS error

Uncaught (in promise) TypeError: table.row is undefined

We need to use the DataTable object.

Test plan:
Have several languages installed
Edit an item type and click "Translate into other languages" to open
the modal
Translate into another language and note that:
Without this patch you get a JS error in the browser console and the
row is not added to the table
With this patch applied the row is added correctly with your translation

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit be1729ed68)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jonathan Druart 2025-06-18 13:42:28 +02:00 committed by Paul Derscheid
parent 3042fa93d8
commit 625d7ee939
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 3 additions and 2 deletions

View File

@ -198,11 +198,12 @@
$(document).ready(function() {
$(".dialog").hide();
var table = $("#localization").kohaTable({
let table = $("#localization").kohaTable({
dom: "t",
paging: false,
autoWidth: false,
});
let table_dt = table.DataTable();
var languages_select = $('<select name="lang" id="lang"></select>');
[% FOR language IN languages %]
@ -275,7 +276,7 @@
if ( success.error ) {
show_message({ type: 'error_on_insert', data: success });
} else {
var new_row = table.row.add( [ success.id, success.entity, success.code, success.lang, success.translation, "<a href=\"#\" class=\"delete\"><i class=\"fa fa-trash-can\"></i> Delete</a>" ] ).draw().node();
var new_row = table_dt.row.add( [ success.id, success.entity, success.code, success.lang, success.translation, "<a href=\"#\" class=\"delete\"><i class=\"fa fa-trash-can\"></i> Delete</a>" ] ).draw().node();
$( new_row ).attr("id", "row_id_" + success.id ).data("id", success.id );
show_message({ type: 'success_on_insert', data: success });
}