Bug 34478: Correct op name for list edit confirmation

The 'delete_confirm' op leads to a confirmation page, so it's GET.

The patch also consolidates JS for handling deletions, using the same
class for both the delete button in the toolbar and in the table of
lists.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2024-02-23 18:05:16 +00:00 committed by Jonathan Druart
parent 882305704e
commit 63a51acc83
Signed by: jonathan.druart
GPG key ID: A085E712BEF0E0F0
4 changed files with 8 additions and 20 deletions

View file

@ -16,11 +16,11 @@
<ul class="dropdown-menu">
<li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=edit_form&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;referer=[% op | uri %]">Edit list</a></li>
<li>
<a id="deleteshelf_toolbar" href="#">Delete list</a>
<form id="deleteshelf_toolbar_form" action="shelves.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-delete">
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]">
<input type="hidden" name="op" value="cud-delete" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
<button type="submit" class="btn btn-default delete-list">Delete list</button>
</form>
</li>
</ul>

View file

@ -939,20 +939,8 @@
sendList();
return false;
});
$("#deleteshelf").click(function(e){
if(confirm(_("Are you sure you want to delete this list?"))){
return true;
} else {
e.preventDefault();
}
});
$("#deleteshelf_toolbar").on('click',function(e){
if(confirm(_("Are you sure you want to delete this list?"))){
$("#deleteshelf_toolbar_form").submit();
return false;
} else {
e.preventDefault();
}
$(".delete-list").click(function(e){
return confirm(_("Are you sure you want to delete this list?"));
});
});

View file

@ -50,11 +50,11 @@
[%~ action_block = action_block _ ' <form action="shelves.pl" method="post">' ~%]
[%~ action_block = BLOCK ~%][%~ action_block | $raw ~%][%~ INCLUDE 'csrf-token.inc' | trim ~%][%~ END ~%]
[%~ action_block = action_block _ '<input type="hidden" name="shelves" value="1" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="op" value="delete" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="op" value="cud-delete" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber _ '" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="public" value="' _ public _ '" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="referer" value="list" />' ~%]
[%~ action_block = action_block _ '<button type="submit" class="deleteshelf btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Delete</button>' ~%]
[%~ action_block = action_block _ '<button type="submit" class="delete-list btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Delete</button>' ~%]
[%~ action_block = action_block _ '</form>' ~%]
[%~ END ~%]
[%~ IF public AND allow_transfer ~%]

View file

@ -63,7 +63,7 @@ my ( $shelf, $shelfnumber, @messages, $allow_transfer );
if ( $op eq 'add_form' ) {
# Only pass default
$shelf = { allow_change_from_owner => 1 };
} elsif ( $op eq 'cud-edit_form' ) {
} elsif ( $op eq 'edit_form' ) {
$shelfnumber = $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);