Bug 37187: Fix deletion of label batches and label templates

This patch uses the new form-submit JS to convert the label management
deletion link from a GET operation to POST.

To test, apply the patch and go to Cataloging -> Label creator.

- Click Manage -> Label batches. Create a batch if necessary.
- Click the "Delete" button in the "Actions" column. You should get a
  confirmation message, "Are you sure you want to delete this?"
  - Test both the confirming and cancelling.
- Perform the same test with Manage -> Label templates.
- From the Manage -> Label batches page, click "edit" on one of the
  batches.
- Right above the "Items in batch number X" is a toolbar which should
  have a button, "Delete batch." Test that it works correctly to delete
  the batch.

Sponsored-by: Athens County Public Libraries
Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Owen Leonard 2024-06-26 14:56:58 +00:00 committed by Katrin Fischer
parent b18664ec45
commit 5f156ad3df
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 8 additions and 16 deletions

View file

@ -124,7 +124,9 @@
<a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add item(s)</a>[% IF ( table_loop ) %]
<a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
<a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash-can"></i> Remove selected items</a>
<a class="btn btn-default" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
<a class="btn btn-default submit-form-link" id="deletebatch" href="#" data-op="cud-delete" data-label_element="batch" data-element_id="[% batch_id | html %]" data-action="/cgi-bin/koha/labels/label-manage.pl" data-method="post" data-confirmation-msg="[% tx("Are you sure you want to delete batch {batch_number}?", { batch_number = batch_id }) %]"><i class="fa fa-minus-square"></i> Delete batch</a>
<a class="btn btn-default" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
<a class="btn btn-default" id="exportitems" href="#"><i class="fa-solid fa-share-from-square"></i> Export selected items</a>
<a class="btn btn-default" id="exportbatch" href="#"><i class="fa-solid fa-share-from-square"></i> Export full batch</a>[% END %]
@ -206,17 +208,8 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'greybox.inc' %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/form-submit.js") | $raw %]
<script>
function DeleteConfirm() {
var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
var answer = confirm(msg);
if (answer) {
window.location = "/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=batch&amp;element_id=[% batch_id | html %]";
}
else {
return; // abort delete
}
}
function dofocus() { // named function req'd for body onload event by some FF and IE7 security models
$(".focus:last").select();
}
@ -343,10 +336,7 @@
Remove();
return false;
});
$("#deletebatch").click(function(){
DeleteConfirm();
return false;
});
$("#deduplicate").click(function(){
DeDuplicate();
return false;

View file

@ -95,7 +95,8 @@
[% IF ( text_field.select_field ) %]
<td class="actions">
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/labels/label-edit-[% label_element |url %].pl?op=edit_form&amp;element_id=[% text_field.field_value |url %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=[% label_element | html %]&amp;element_id=[% text_field.field_value |url %]"><i class="fa fa-trash-can"></i> Delete</a>
<a class="btn btn-default btn-xs submit-form-link" href="#" data-label_element="[% label_element | html %]" data-element_id="[% text_field.field_value | html %]" data-action="label-manage.pl" data-method="post" data-op="cud-delete" data-confirmation-msg="[% t('Are you sure you want to delete this?') | html %]"><i class="fa fa-trash-can"></i> Delete</a>
</td>
[% IF label_element == 'batch' %] <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>[% END %]
[% ELSIF ( text_field.field_value ) %]
@ -134,6 +135,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'greybox.inc' %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("js/form-submit.js") | $raw %]
<script>
function Xport() {
batches= new Array;