Bug 18656 - Require confirmation of deletion of files from patron record
authorOwen Leonard <oleonard@myacpl.org>
Wed, 24 May 2017 13:46:50 +0000 (13:46 +0000)
committerKatrin Fischer <katrin.fischer.83@web.de>
Tue, 13 Jun 2017 20:39:54 +0000 (22:39 +0200)
This patch adds a JavaScript confirm to the deletion of files. It also
styles the file deletion link as a Bootstrap button.

To test, apply the patch and open the "Files" page for a patron who has
files attached.

- Verify that clicking any "delete" link prompts for a confirmation.
- Verify that confirming the dialog triggers the deletion of the correct
  file.
- Verify that canceling the confirmation dialog aborts the deletion.
- Confirm that the "Delete" button looks correct.

Signed-off-by: David Roberts <david.roberts@ptfs-europe.com>

Revision for QA: Replaced '.click(function' with '.on("click",function'

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit a38ffe2d48c35029ef80ea0a4294e36b408cd1a4)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 2bc4791dedc9d266b7aa3a121e62af2dc78354e2)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt

index 15bdc1b..ba4cc1f 100644 (file)
@@ -3,6 +3,19 @@
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Files for [% INCLUDE 'patron-title.inc' %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
+<script type="text/javascript">
+    $(document).ready(function(){
+        $(".confirmdelete").on("click", function(){
+            $(this).parents('tr').addClass("warn");
+            if(confirm(_("Are you sure you want to delete this file?"))){
+                return true;
+            } else {
+                $(this).parents('tr').removeClass("warn");
+                return false;
+            }
+        });
+});
+</script>
 </head>
 <body id="pat_files" class="pat">
 [% INCLUDE 'header.inc' %]
@@ -44,7 +57,7 @@
                                  <td>[% f.file_type %]</td>
                                  <td>[% f.file_description %]</td>
                                  <td>[% f.date_uploaded | $KohaDates %]</td>
-                                 [% IF CAN_user_borrowers %]<td><a href="?borrowernumber=[% borrowernumber %]&amp;op=delete&amp;file_id=[% f.file_id %]">Delete</a></td>[% END %]
+                                 [% IF CAN_user_borrowers %]<td><a class="btn btn-default btn-xs confirmdelete" href="?borrowernumber=[% borrowernumber %]&amp;op=delete&amp;file_id=[% f.file_id %]"><i class="fa fa-trash"></i> Delete</a></td>[% END %]
                             </tr>
                         [% END %]
                     </tbody>