From c303907b21eaa74682bbb630e4fa1e8a23c4e7d2 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 15 Jan 2026 15:28:02 -0500 Subject: [PATCH] Bug 41574: (follow-up) More tidying Signed-off-by: Owen Leonard --- .../prog/en/modules/patroncards/edit-batch.tt | 153 +++++++++--------- 1 file changed, 77 insertions(+), 76 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt index 5f515853bb5..a6150632365 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt @@ -187,21 +187,21 @@ var msg = _("Are you sure you want to delete batch %s?").format(batch_id); var answer = confirm(msg); if (answer) { - $('#batch_form input[name="op"]').val('cud-delete'); - $('#batch_form').append( `` ); - $('#batch_form').append( '' ); - $('#batch_form').submit(); + $('#batch_form input[name="op"]').val("cud-delete"); + $("#batch_form").append(``); + $("#batch_form").append(''); + $("#batch_form").submit(); } else { return; // abort delete } - }; + } function Remove() { - items = new Array; + items = new Array(); - if(document.items.action.length > 0) { - for (var i=0; i < document.items.action.length; i++) { + if (document.items.action.length > 0) { + for (var i = 0; i < document.items.action.length; i++) { if (document.items.action[i].checked) { - items.push( document.items.action[i].value ); + items.push(document.items.action[i].value); } } getstr = items.join("&"); @@ -211,105 +211,105 @@ return; // no deletion for single item batch } else { alert(_("Please select at least one patron to delete.")); - return; // no item selected + return; // no item selected } var answer = confirm(msg); if (answer) { - $('#patron_form input[name="op"]').val('cud-remove'); + $('#patron_form input[name="op"]').val("cud-remove"); $('#patron_form input[name="batch_id"]').val(batch_id); $('#patron_form input[name="label_id"]').remove(); - items.forEach( (item_id) => { - $('#patron_form').append( '' ); + items.forEach(item_id => { + $("#patron_form").append(''); }); - $('#patron_form').submit(); + $("#patron_form").submit(); } else { return; // abort delete } - }; + } function Add() { var bor_nums = document.getElementById("bor_num_list"); - if (bor_nums.value == '') { + if (bor_nums.value == "") { return true; } document.forms["add_by_bor_num"].submit(); - return false - }; + return false; + } function add_user(borrowernumber) { var list = $("#bor_num_list").val(); if (list.indexOf(borrowernumber) == -1) { - $("#bor_num_list").val(list+borrowernumber+"\r\n"); + $("#bor_num_list").val(list + borrowernumber + "\r\n"); } else { return -1; } } function DeDuplicate() { - $('#patron_form input[name="op"]').val('cud-dedup'); + $('#patron_form input[name="op"]').val("cud-dedup"); $('#patron_form input[name="batch_id"]').val(batch_id); - $('#patron_form').submit(); + $("#patron_form").submit(); } function Xport(mode) { - if (mode == 'label') { - patroncards= new Array; - if(document.items.action.length > 0) { - for (var i=0; i < document.items.action.length; i++) { + if (mode == "label") { + patroncards = new Array(); + if (document.items.action.length > 0) { + for (var i = 0; i < document.items.action.length; i++) { if (document.items.action[i].checked) { - patroncards.push("label_id=" + document.items.action[i].value); + patroncards.push("label_id=" + document.items.action[i].value); } } if (patroncards.length < 1) { alert(_("Please select at least one card to export.")); - return; // no batch selected + return; // no batch selected } getstr = patroncards.join("&"); } else if (document.items.action.checked) { getstr = document.items.action.value; } else { alert(_("Please select at least one card to export.")); - return; // no batch selected + return; // no batch selected } location.href = `/cgi-bin/koha/patroncards/print.pl?batch_id=${batch_id}&${getstr}`; - } else if (mode == 'batch') { + } else if (mode == "batch") { location.href = `/cgi-bin/koha/patroncards/print.pl?batch_id=${batch_id}`; } else { // some pass-through error trapping just in case... } - }; + } function selected_layout() { if (document.items.action.length) { - for (i=0;i prefs.PatronsPerPage || aLengthMenu[i] == -1 ) { + if (aLengthMenu[i] > prefs.PatronsPerPage || aLengthMenu[i] == -1) { aLengthMenu.splice(i, 0, prefs.PatronsPerPage); aLengthMenuLabel.splice(i, 0, prefs.PatronsPerPage); break; } } - if (has_entries){ + if (has_entries) { $("#description").show(); } else { $("#description").hide(); @@ -322,72 +322,73 @@ pageLength: prefs.PatronsPerPage, autoWidth: false, }); - $("#additems").click(function(){ + $("#additems").click(function () { return Add(); }); - $("#removeitems").click(function(){ + $("#removeitems").click(function () { Remove(); return false; }); - $("#deletebatch").click(function(){ + $("#deletebatch").click(function () { DeleteConfirm(); return false; }); - $("#deduplicate").click(function(){ + $("#deduplicate").click(function () { DeDuplicate(); return false; }); - $("#exportitems").click(function(){ - Xport('label'); + $("#exportitems").click(function () { + Xport("label"); return false; }); - $("#exportbatch").click(function(){ - Xport('batch'); + $("#exportbatch").click(function () { + Xport("batch"); return false; }); - $(".delete").on("click", function(){ - if( confirmDelete( _("Are you sure you want to delete this patron from the card batch?") ) ) { - $('#patron_form input[name="op"]').val('cud-remove'); - $('#patron_form input[name="batch_id"]').val($(this).data('batch-id')); - $('#patron_form input[name="label_id"]').val($(this).data('label-id')); - $('#patron_form').submit(); + $(".delete").on("click", function () { + if (confirmDelete(_("Are you sure you want to delete this patron from the card batch?"))) { + $('#patron_form input[name="op"]').val("cud-remove"); + $('#patron_form input[name="batch_id"]').val($(this).data("batch-id")); + $('#patron_form input[name="label_id"]').val($(this).data("label-id")); + $("#patron_form").submit(); } }); - $(".export").on("click", function(e){ + $(".export").on("click", function (e) { e.preventDefault(); var label_id = $(this).data("label-id"); var batch_id = $(this).data("batch-id"); location.href = "/cgi-bin/koha/patroncards/print.pl?batch_id=" + batch_id + "&label_id=" + label_id; }); - $("#savedesc").click(function(event){ + $("#savedesc").click(function (event) { event.preventDefault(); // prevent form submission var newdescription = $('input[name="description"]').val(); - var batch_id = $(this).data('batch_id'); + var batch_id = $(this).data("batch_id"); var ajaxData = { - 'newdescription': newdescription, - 'batch_id': batch_id, - op: 'cud-set_permission', + newdescription: newdescription, + batch_id: batch_id, + op: "cud-set_permission", csrf_token: $('meta[name="csrf-token"]').attr("content"), }; $.ajax({ - url: '/cgi-bin/koha/svc/creator_batches', - type: 'POST', - dataType: 'json', + url: "/cgi-bin/koha/svc/creator_batches", + type: "POST", + dataType: "json", data: ajaxData, }) - .done(function(data){ - if (data.status == 'success') { - $("input[name='description']").text(data.newdesc); - $("#change-status").text(_("Saved")); - } else { + .done(function (data) { + if (data.status == "success") { + $("input[name='description']").text(data.newdesc); + $("#change-status").text(_("Saved")); + } else { + $("#change-status").text(_("Unable to save description")); + } + }) + .fail(function () { $("#change-status").text(_("Unable to save description")); - } - }).fail(function(){ - $("#change-status").text(_("Unable to save description")); - }); + }); }); }); -- 2.39.5