Bug 37489: Separate forms for uploading and deleting a patron image

This patch creats a new form for image deletion that is submitted via the 'Delete' button on the modal.

To test:
1) Turon on the 'patronimages' sys pref
2) Visit a patron page, you should see an image module on the left.
3) Click on the image to edit it. Upload a new image.
4) Edit the image again, press delete and confirm the popup.
5) Note that it will not let you delete because of the required file.
6) Apply patch
7) Attempt to delete again, this time it is successful.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 2263d9f3b0)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Sam Lau 2024-07-26 16:17:56 +00:00 committed by Lucas Gass
parent 04b7d7f1ff
commit 812f268d8a
1 changed files with 11 additions and 3 deletions

View File

@ -293,11 +293,19 @@
<input type="hidden" id="cardnumber" name="cardnumber" value="[% patron.cardnumber | html %]" />
<input type="hidden" id="borrowernumber" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<button type="submit" class="btn btn-default btn-xs" name="op" value="cud-Upload"><i class="fa fa-upload"></i> Upload photo</button>
[% IF ( patron.image ) %]
<button id="delpicture" type="submit" class="btn btn-default btn-xs delete" name="op" value="cud-Delete"><i class="fa fa-trash-can"></i> Delete</button>
[% END %]
</div> <!-- /.action -->
</form> <!-- /#picture-upload -->
[% IF ( patron.image ) %]
<form method="post" id="picture-delete" action="/cgi-bin/koha/tools/picture-upload.pl" enctype="multipart/form-data">
<div class="action" style="padding-top:0px;">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" id="image" name="filetype" value="image" />
<input type="hidden" id="cardnumber" name="cardnumber" value="[% patron.cardnumber | html %]" />
<input type="hidden" id="borrowernumber" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
<button id="delpicture" type="submit" class="btn btn-default btn-xs delete" name="op" value="cud-Delete"><i class="fa fa-trash-can"></i> Delete</button>
</div> <!-- /.action -->
</form> <!-- /#picture-delete -->
[% END %]
</div> <!-- /#upload-patron-image -->
<div id="capture-patron-image" class="patroninfo-section">
<h5>Take patron photo</h5>