Bug 41580: (follow-up) Fixes for errors

- In Cataloging -> Manage staged MARC records: the logic around showing
  the "Edit" button was not correct
- In Tools -> Batch patron modification: There was sometimes an error in
  the console about a variable not existing which can be resolved by
  moving the corresponding (and related) JS into the conditional which
  depends on the table of results existing.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Owen Leonard 2026-01-20 09:27:08 -05:00 committed by Lucas Gass
parent 33661e7e8d
commit 1a3927fe1e
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 44 additions and 41 deletions

View File

@ -588,15 +588,12 @@
'<a href="' + aData['diff_url'] + '">' + _("View") + '</a>'
);
}
if (aData['matched']) {
$('td:eq(6)', nRow).html(
'<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 (perms.CAN_user_editcatalogue_edit_catalogue){
+ '<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>'
}
);
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 (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:eq(6)", nRow).html(buttons);
}
},
});

View File

@ -567,28 +567,46 @@
});
return false;
});
$('select[name="patron_attributes"]').change(function() {
updateAttrValues(this);
} );
$('select[name="patron_attributes"]').change();
$(".clear-date").on("click",function(e){
e.preventDefault();
var fieldID = this.id.replace("clear-date-","");
$("#" + fieldID).val("");
});
$("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
e.preventDefault();
add_attributes();
});
$("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
e.preventDefault();
del_attributes(this);
});
$('form[name="f"]').on("submit", function(){
// Add the checkboxes to the DOM before we submit the form
var form = this;
var checkboxes = $(patron_table).find('input:checkbox:checked').serializeArray();
$.each(checkboxes, function(){
let borrowernumber = this.value;
if(!$(form).find('input[name="borrowernumber"][value="'+borrowernumber+'"]').length){
$(form).append(
$('<input>')
.attr('type', 'hidden')
.attr('name', 'borrowernumber')
.val(borrowernumber)
);
}
});
});
}
$('select[name="patron_attributes"]').change(function () {
updateAttrValues(this);
});
$('select[name="patron_attributes"]').change();
$(".clear-date").on("click", function (e) {
e.preventDefault();
var fieldID = this.id.replace("clear-date-", "");
$("#" + fieldID).val("");
});
$("#cataloguing_additem_newitem").on("click", ".add_attributes", function (e) {
e.preventDefault();
add_attributes();
});
$("#cataloguing_additem_newitem").on("click", ".del_attributes", function (e) {
e.preventDefault();
del_attributes(this);
});
$("#patron_batchmod_form").on("submit", function () {
$("#patron_batchmod_form").on("submit", function(){
/* Reset form fields on inactive tabs */
var tab = $(this).find("ul.nav-tabs li a.active").attr("href");
if (tab == "#usecardnumber_panel") {
@ -600,18 +618,6 @@
$("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val("");
}
});
$('form[name="f"]').on("submit", function () {
// Add the checkboxes to the DOM before we submit the form
var form = this;
var checkboxes = $(patron_table).find("input:checkbox:checked").serializeArray();
$.each(checkboxes, function () {
let borrowernumber = this.value;
if (!$(form).find('input[name="borrowernumber"][value="' + borrowernumber + '"]').length) {
$(form).append($("<input>").attr("type", "hidden").attr("name", "borrowernumber").val(borrowernumber));
}
});
});
});
function updateAttrValues(select_attr) {