Bug 39516: (follow-up) Move table_settings variable

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Lucas Gass 2026-04-29 19:08:23 +00:00
parent 3d02462f73
commit 847fba0505
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 191 additions and 186 deletions

View File

@ -467,6 +467,7 @@
Koha.addPermissions({
CAN_user_editcatalogue_edit_catalogue: [% CAN_user_editcatalogue_edit_catalogue ? 1 : 0 | html %],
});
var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'manage-marc-import', 'records-table', 'json' ) | $raw %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
@ -484,208 +485,212 @@
});
if (import_batch_id) {
var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'manage-marc-import', 'records-table', 'json' ) | $raw %];
$("#records-table").kohaTable({
autoWidth: false,
searching: false,
processing: true,
serverSide: true,
ajax: {
url: "batch_records_ajax.pl",
data: function (d) {
d.import_batch_id = import_batch_id;
return d;
},
},
bKohaAjaxSVC: true,
pagingType: "full_numbers",
dom: '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
columns: [
{
data: "import_record_id",
createdCell: function (td) {
$(td).attr("data-colname", "import_record_id");
$("#records-table").kohaTable(
{
autoWidth: false,
searching: false,
processing: true,
serverSide: true,
ajax: {
url: "batch_records_ajax.pl",
data: function (d) {
d.import_batch_id = import_batch_id;
return d;
},
},
{
data: "citation",
createdCell: function (td) {
$(td).attr("data-colname", "citation");
bKohaAjaxSVC: true,
pagingType: "full_numbers",
dom: '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
columns: [
{
data: "import_record_id",
createdCell: function (td) {
$(td).attr("data-colname", "import_record_id");
},
},
},
{
data: "status",
createdCell: function (td) {
$(td).attr("data-colname", "status");
{
data: "citation",
createdCell: function (td) {
$(td).attr("data-colname", "citation");
},
},
},
{
data: "overlay_status",
createdCell: function (td) {
$(td).attr("data-colname", "overlay_status");
{
data: "status",
createdCell: function (td) {
$(td).attr("data-colname", "status");
},
},
},
{
data: null,
defaultContent: "",
createdCell: function (td) {
$(td).attr("data-colname", "match_details");
{
data: "overlay_status",
createdCell: function (td) {
$(td).attr("data-colname", "overlay_status");
},
},
},
{
data: null,
defaultContent: "",
createdCell: function (td) {
$(td).attr("data-colname", "match_score_breakdown");
{
data: null,
defaultContent: "",
createdCell: function (td) {
$(td).attr("data-colname", "match_details");
},
},
},
{
data: null,
defaultContent: "",
createdCell: function (td) {
$(td).attr("data-colname", "diff");
{
data: null,
defaultContent: "",
createdCell: function (td) {
$(td).attr("data-colname", "match_score_breakdown");
},
},
},
{
data: "matched",
createdCell: function (td) {
$(td).attr("data-colname", "matched");
{
data: null,
defaultContent: "",
createdCell: function (td) {
$(td).attr("data-colname", "diff");
},
},
},
],
rowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
var record_details_url = record_type == "auth" ? "/cgi-bin/koha/authorities/detail.pl?authid=" : "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
var record_edit_url = record_type == "auth" ? "/cgi-bin/koha/authorities/authorities.pl?authid=" : "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=";
{
data: "matched",
createdCell: function (td) {
$(td).attr("data-colname", "matched");
},
},
],
rowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
var record_details_url = record_type == "auth" ? "/cgi-bin/koha/authorities/detail.pl?authid=" : "/cgi-bin/koha/catalogue/detail.pl?biblionumber=";
var record_edit_url = record_type == "auth" ? "/cgi-bin/koha/authorities/authorities.pl?authid=" : "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=";
var additional_details = "";
if (aData["author"]) {
additional_details += " " + escape_str(aData["author"]) + " ";
}
if (aData["isbn"]) {
additional_details += " (" + escape_str(aData["isbn"]) + ") ";
}
if (aData["issn"]) {
additional_details += " (" + escape_str(aData["issn"]) + ") ";
}
$("td[data-colname='citation']", nRow).html('<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData["import_record_id"] + '&viewas=html" class="previewMARC">' + escape_str(aData["citation"]) + "</a> " + additional_details);
$("td[data-colname='status']", nRow).html(
aData["status"] == "imported"
? _("Imported")
: aData["status"] == "ignored"
? _("Ignored")
: aData["status"] == "reverted"
? _("Reverted")
: aData["status"] == "staged"
? _("Staged")
: aData["status"] == "error"
? _("Error")
: aData["status"]
);
$("td[data-colname='overlay_status']", nRow).html(
aData["overlay_status"] == "no_match" ? _("No match") : aData["overlay_status"] == "match_applied" ? _("Match applied") : aData["overlay_status"] == "auto_match" ? _("Match found") : aData["overlay_status"]
);
if (aData["matches"].length > 0) {
var any_checked = 0;
$("td[data-colname='match_details']", nRow).html('<ul class="matches"></ul>');
$("td[data-colname='match_score_breakdown']", nRow).html('<ul class="matches"></ul>');
$("td[data-colname='diff']", nRow).html('<ul class="matches"></ul>');
var checked = "";
var disabled = "";
if (aData["status"] == "imported" || aData["status"] == "ignored") {
disabled = " disabled ";
var additional_details = "";
if (aData["author"]) {
additional_details += " " + escape_str(aData["author"]) + " ";
}
aData["matches"].forEach(function (item, index) {
if (item.chosen == 1) {
checked = 'checked="checked"';
any_checked = 1;
}
var match_option = "";
match_option =
'<input type="radio" data-import_record_id="' +
aData["import_record_id"] +
'" class="chosen" name="import_record_id_' +
aData["import_record_id"] +
'_match" value="' +
item.candidate_match_id +
'" ' +
checked +
disabled +
"> ";
var diff_url = "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=%s&importid=%s&id=%s&type=%s";
var match_citation = "";
var matching_msg = "";
if (item.record_type == "auth") {
matching_msg = _("Matches authority %s (score=%s):%s");
if (item.authorized_heading) {
match_citation += item.authorized_heading;
}
} else {
matching_msg = _("Matches bibliographic record %s (score=%s):%s");
if (item.title) {
match_citation += item.title + " ";
}
if (item.author) {
match_citation += item.author;
}
}
$("td[data-colname='match_details'] ul", nRow).append(
'<li><label for="import_record_id_' +
aData["import_record_id"] +
"_match_" +
index +
'">' +
match_option +
matching_msg.format(item.candidate_match_id, item.score, '<a target="_blank" href="' + record_details_url + item.candidate_match_id + '">' + match_citation + "</a></label></li>")
);
var score_breakdown = "";
if (item.composite_scores && Object.keys(item.composite_scores).length > 0) {
score_breakdown = Object.entries(item.composite_scores)
.map(function (e) {
return e[0] + ":" + e[1];
})
.join(", ");
}
$("td[data-colname='match_score_breakdown'] ul", nRow).append("<li>" + (score_breakdown || item.score) + "</li>");
$("td[data-colname='diff'] ul", nRow).append('<li><a href="' + diff_url.format(import_batch_id, aData["import_record_id"], item.candidate_match_id, item.record_type) + '">' + _("View") + "</a></li>");
checked = "";
});
if (!any_checked) {
checked = 'checked="checked"';
if (aData["isbn"]) {
additional_details += " (" + escape_str(aData["isbn"]) + ") ";
}
$("td[data-colname='match_details'] ul", nRow).prepend(
'<li><label><input type="radio" data-import_record_id="' +
aData["import_record_id"] +
'" class="chosen" name="import_record_id_' +
aData["import_record_id"] +
'_match" value="none" ' +
checked +
disabled +
" > " +
_("Ignore matches") +
"</label></li>"
if (aData["issn"]) {
additional_details += " (" + escape_str(aData["issn"]) + ") ";
}
$("td[data-colname='citation']", nRow).html(
'<a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData["import_record_id"] + '&viewas=html" class="previewMARC">' + escape_str(aData["citation"]) + "</a> " + additional_details
);
$("td[data-colname='match_score_breakdown'] ul", nRow).prepend("<li>&nbsp;</li>");
$("td[data-colname='diff'] ul", nRow).prepend("<li>&nbsp;</li>");
}
if (aData["diff_url"]) {
$("td[data-colname='diff']", nRow).html('<a href="' + aData["diff_url"] + '">' + _("View") + "</a>");
}
if (aData["matched"]) {
let buttons = '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url + aData["matched"] + '"><i class="fa-solid fa-eye"></i> ' + _("View") + "</a> ";
if (Koha.permissions.CAN_user_editcatalogue_edit_catalogue) {
buttons += '<a class="btn btn-default btn-xs" target="_blank" href="' + record_edit_url + aData["matched"] + '"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + _("Edit") + "</a>";
$("td[data-colname='status']", nRow).html(
aData["status"] == "imported"
? _("Imported")
: aData["status"] == "ignored"
? _("Ignored")
: aData["status"] == "reverted"
? _("Reverted")
: aData["status"] == "staged"
? _("Staged")
: aData["status"] == "error"
? _("Error")
: aData["status"]
);
$("td[data-colname='overlay_status']", nRow).html(
aData["overlay_status"] == "no_match" ? _("No match") : aData["overlay_status"] == "match_applied" ? _("Match applied") : aData["overlay_status"] == "auto_match" ? _("Match found") : aData["overlay_status"]
);
if (aData["matches"].length > 0) {
var any_checked = 0;
$("td[data-colname='match_details']", nRow).html('<ul class="matches"></ul>');
$("td[data-colname='match_score_breakdown']", nRow).html('<ul class="matches"></ul>');
$("td[data-colname='diff']", nRow).html('<ul class="matches"></ul>');
var checked = "";
var disabled = "";
if (aData["status"] == "imported" || aData["status"] == "ignored") {
disabled = " disabled ";
}
aData["matches"].forEach(function (item, index) {
if (item.chosen == 1) {
checked = 'checked="checked"';
any_checked = 1;
}
var match_option = "";
match_option =
'<input type="radio" data-import_record_id="' +
aData["import_record_id"] +
'" class="chosen" name="import_record_id_' +
aData["import_record_id"] +
'_match" value="' +
item.candidate_match_id +
'" ' +
checked +
disabled +
"> ";
var diff_url = "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=%s&importid=%s&id=%s&type=%s";
var match_citation = "";
var matching_msg = "";
if (item.record_type == "auth") {
matching_msg = _("Matches authority %s (score=%s):%s");
if (item.authorized_heading) {
match_citation += item.authorized_heading;
}
} else {
matching_msg = _("Matches bibliographic record %s (score=%s):%s");
if (item.title) {
match_citation += item.title + " ";
}
if (item.author) {
match_citation += item.author;
}
}
$("td[data-colname='match_details'] ul", nRow).append(
'<li><label for="import_record_id_' +
aData["import_record_id"] +
"_match_" +
index +
'">' +
match_option +
matching_msg.format(item.candidate_match_id, item.score, '<a target="_blank" href="' + record_details_url + item.candidate_match_id + '">' + match_citation + "</a></label></li>")
);
var score_breakdown = "";
if (item.composite_scores && Object.keys(item.composite_scores).length > 0) {
score_breakdown = Object.entries(item.composite_scores)
.map(function (e) {
return e[0] + ":" + e[1];
})
.join(", ");
}
$("td[data-colname='match_score_breakdown'] ul", nRow).append("<li>" + (score_breakdown || item.score) + "</li>");
$("td[data-colname='diff'] ul", nRow).append('<li><a href="' + diff_url.format(import_batch_id, aData["import_record_id"], item.candidate_match_id, item.record_type) + '">' + _("View") + "</a></li>");
checked = "";
});
if (!any_checked) {
checked = 'checked="checked"';
}
$("td[data-colname='match_details'] ul", nRow).prepend(
'<li><label><input type="radio" data-import_record_id="' +
aData["import_record_id"] +
'" class="chosen" name="import_record_id_' +
aData["import_record_id"] +
'_match" value="none" ' +
checked +
disabled +
" > " +
_("Ignore matches") +
"</label></li>"
);
$("td[data-colname='match_score_breakdown'] ul", nRow).prepend("<li>&nbsp;</li>");
$("td[data-colname='diff'] ul", nRow).prepend("<li>&nbsp;</li>");
}
$("td[data-colname='matched']", nRow).html(buttons);
}
if (aData["diff_url"]) {
$("td[data-colname='diff']", nRow).html('<a href="' + aData["diff_url"] + '">' + _("View") + "</a>");
}
if (aData["matched"]) {
let buttons = '<a class="btn btn-default btn-xs" target="_blank" href="' + record_details_url + aData["matched"] + '"><i class="fa-solid fa-eye"></i> ' + _("View") + "</a> ";
if (Koha.permissions.CAN_user_editcatalogue_edit_catalogue) {
buttons += '<a class="btn btn-default btn-xs" target="_blank" href="' + record_edit_url + aData["matched"] + '"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + _("Edit") + "</a>";
}
$("td[data-colname='matched']", nRow).html(buttons);
}
},
},
}, table_settings);
table_settings
);
$("#revert_batch_form").on("submit", function () {
return confirm(_("Are you sure you want to undo the import of this batch into the catalog?"));
});