Bug 34478: Item removal deletion should be POSTed form

This patch updates the "Remove" button from items which are in a
rotating collection (in the "Manage items" stage). A GET link is
converted to a posted form.

Unrelated: The JavaScript has also been modified so that it asks for
confirmation.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2024-02-20 19:19:24 +00:00 committed by Jonathan Druart
parent 76aac9b301
commit 38b94cf964
No known key found for this signature in database
GPG Key ID: A085E712BEF0E0F0
2 changed files with 15 additions and 2 deletions

View File

@ -131,7 +131,16 @@
<td>[% INCLUDE 'biblio-title.inc' biblio=collectionItemsLoo link = 1 %]</td>
<td>[% collectionItemsLoo.itemcallnumber | html %]</td>
<td>[% collectionItemsLoo.barcode | html %]</td>
<td><a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% colId | uri %]&amp;barcode=[% collectionItemsLoo.barcode | uri %]&amp;removeItem=1&amp;action=addItem">Remove</a></td>
<td>
<form action="/cgi-bin/koha/rotating_collections/addItems.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-add" />
<input type="hidden" name="colId" value="[% colId | html %]" />
<input type="hidden" name="barcode" value="[% collectionItemsLoo.barcode | html %]" />
<input type="hidden" name="removeItem" value="1" />
<button type="submit" class="btn btn-default btn-xs removeitem"><i class="fa fa-trash"></i> Remove</a>
</form>
</td>
</tr>
[% END %]
</table>

View File

@ -4,8 +4,12 @@ $(document).ready(function(){
$("#barcode").focus();
$(".confirmdelete").click(function(){
return confirm( __("Are you sure you want to delete this rotating collection?"));
});
$(".removeitem").on("click", function(){
$(this).parents('tr').addClass("warn");
if(confirm(__("Are you sure you want to delete this rotating collection?"))){
if(confirm(__("Are you sure you want to remove this item?"))){
$(this).parents('form').submit();
return true;
} else {