Bug 34478: Comment deletion should be POSTed form

This patch updates the "Delete" button on the comments moderation page
to convert the GET link 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:26:56 +00:00 committed by Jonathan Druart
parent 38b94cf964
commit 87d12dbe3c
No known key found for this signature in database
GPG Key ID: A085E712BEF0E0F0
1 changed files with 13 additions and 1 deletions

View File

@ -98,7 +98,12 @@
</td>
<td class="actions">
[% IF ( status ) %]<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=unapprove&amp;reviewid=[% review.reviewid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-times"></i> Unapprove</a>[% ELSE %]<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=approve&amp;reviewid=[% review.reviewid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-check"></i> Approve</a>[% END %]
<a href="/cgi-bin/koha/reviews/reviewswaiting.pl?op=delete&amp;reviewid=[% review.reviewid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-trash-can" aria-hidden="true"></i> Delete</a>
<form action="/cgi-bin/koha/reviews/reviewswaiting.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="cud-delete" />
<input type="hidden" name="reviewid" value="[% review.reviewid | html %]" />
<button type="submit" class="btn btn-default btn-xs delete-comment"><i class="fa fa-trash-can" aria-hidden="true"></i> Delete</button>
</form>
</td>
</tr>
[% END %]</tbody>
@ -123,6 +128,13 @@
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/tools-menu.js") | $raw %]
<script>
$(document).ready(function(){
$(".delete-comment").on("click", function(){
return confirm( _("Are you sure you want to delete this comment?") );
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]