Bug 34478: (follow-up) patroncards: cud-delete from edit-batch and manage

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Marcel de Rooy 2024-02-23 10:02:16 +00:00 committed by Jonathan Druart
parent e2125d00e1
commit 195cccd4ef
No known key found for this signature in database
GPG Key ID: A085E712BEF0E0F0
2 changed files with 27 additions and 10 deletions

View File

@ -147,6 +147,10 @@
<input type="hidden" name="batch_id" value="" />
<input type="hidden" name="label_id" value="" />
</form>
<form id="batch_form" action="/cgi-bin/koha/patroncards/manage.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="" />
</form>
[% ELSE %]
<fieldset class="rows" style="border-bottom: 0px; border: 0px;">
<ol><li>
@ -176,7 +180,10 @@
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/patroncards/manage.pl?op=delete&amp;card_element=batch&amp;element_id=[% batch_id | html %]";
$('#batch_form input[name="op"]').val('cud-delete');
$('#batch_form').append( '<input type="hidden" name="element_id" value="[% batch_id | html %]" />' );
$('#batch_form').append( '<input type="hidden" name="card_element" value="batch" />' );
$('#batch_form').submit();
} else {
return; // abort delete
}

View File

@ -96,11 +96,15 @@
[% FOREACH text_field IN table_loo.text_fields %]
[% IF ( text_field.select_field ) %]
<td>
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/patroncards/edit-[% card_element | html %].pl?op=edit&element_id=[% text_field.field_value | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
[% IF ( print ) %]<a class="btn btn-default btn-xs export" data-batch-id="[% text_field.field_value |url %]" href="/cgi-bin/koha/patroncards/print.pl?batch_id=[% text_field.field_value |url %]"><i class="fa-solid fa-share-from-square"></i> Export</a>[% END %]
<a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element | html %]&element_id=[% text_field.field_value | html %]"><i class="fa fa-trash-can"></i> Delete</a>
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/patroncards/edit-[% card_element | html %].pl?op=edit&element_id=[% text_field.field_value | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
[% IF ( print ) %]
<a class="btn btn-default btn-xs export" data-batch-id="[% text_field.field_value |url %]" href="/cgi-bin/koha/patroncards/print.pl?batch_id=[% text_field.field_value |url %]"><i class="fa-solid fa-share-from-square"></i> Export</a>
[% END %]
<a class="btn btn-default btn-xs delete" href="#" data-element-id="[% text_field.field_value | html %]"><i class="fa fa-trash-can"></i> Delete</a>
</td>
[% IF ( print ) %]<td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>[% END %]
[% IF ( print ) %]
<td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
[% END %]
[% ELSIF ( text_field.field_value ) %]
<td>[% text_field.field_value | html %]</td>
[% ELSE %]
@ -138,6 +142,10 @@
</fieldset>
[% END %]
</form>
<form id="manage_form" method="post" action="/cgi-bin/koha/patroncards/manage.pl">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="op" value="" />
</form>
[% ELSE %]
<div class="dialog message">
@ -277,10 +285,6 @@
Edit();
return false;
});
$("#delete").click(function(){
DeleteConfirm();
return false;
});
$("#print").click(function(){
Xport();
return false;
@ -290,7 +294,13 @@
return false;
});
$(".delete").on("click", function(){
return confirmDelete( _("Are you sure you want to delete this?") );
if( confirmDelete( _("Are you sure you want to delete this?") ) ) {
$('#manage_form input[name="op"]').val('cud-delete');
$('#manage_form').append( '<input type="hidden" name="card_element" value="[% card_element | html %]" />' );
var id = $(this).data('element-id');
$('#manage_form').append( '<input type="hidden" name="element_id" value="' + id + '" />' );
$('#manage_form').submit();
}
});
$(".export").on("click", function(e){
e.preventDefault();