Bug 16372 - Replace the use of "onclick" for deletion confirmation in some templates
authorOwen Leonard <oleonard@myacpl.org>
Tue, 26 Apr 2016 17:00:42 +0000 (13:00 -0400)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 29 Apr 2016 16:11:14 +0000 (16:11 +0000)
This patch removes the use of event attributes from several templates
where the attributes were used to handle deletion operations. I've
grouped these changes in one patch because each template had only small
changes to be made.

Unrelated change: Reformatted the "no news items" message which is
displayed if there are no news items.

To test, apply the patch and test deletion operations on the following
pages. Clicking "delete" should prompty you to confirm. Test both the
confirm and cancel actions.

- On the staff client home page, test deletion of a news item.
- On the patron lists page, test deletion of a patron list.
- In the patron card creator, choose Manage -> Images. Test the "Delete"
  button for a single image.
- On the news page, test deletion of a single news item.
- On the news page, test deletion of multiple items.

Signed-off-by: Arslan Farooq <arslanone@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt
koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt

index 26d583c..b251d9b 100644 (file)
@@ -7,6 +7,11 @@
 <script type="text/javascript">
 //<![CDATA[
 var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this news item? This cannot be undone.");
+    $(document).ready(function(){
+        $(".news_delete").on("click", function(){
+            return confirmDelete(MSG_CONFIRM_DELETE);
+        });
+    });
 //]]>
 </script>
 </head>
@@ -183,7 +188,7 @@ var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this news item? This
                     <p class="newsfooter"> Posted on [% koha_new.newdate %][% IF( ( newsdisp == 'staff' || newsdisp == 'both' ) && koha_new.borrowernumber ) %] by <span class="newsauthor_title">[% koha_new.author_title %] </span>[% koha_new.author_firstname %] [% koha_new.author_surname %]<br />[% END %]
                         [% IF ( CAN_user_tools ) %]
                             <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% koha_new.idnew %]">Edit</a>
-                             | <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% koha_new.idnew %]" onclick="return confirm(MSG_CONFIRM_DELETE);">Delete</a>
+                             | <a class="news_delete" href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% koha_new.idnew %]">Delete</a>
                              | <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form">New</a>
                         [% END %]
                     </p>
index 3e4ba75..8dd0b60 100644 (file)
             ],
             "sPaginationType": "four_button"
         } ));
+        $(".delete_patron").on("click", function(){
+            $(".dropdown").removeClass("open");
+            var list = $(this).data("list-name");
+            return confirmDelete( _("Are you sure you want to delete the list %s?").format(list) );
+        });
     });
-
-    function ConfirmDelete( list ) {
-        return confirm( _("Are you sure you want to delete the list %s?").format(list) );
-    }
 //]]>
 </script>
 
@@ -67,7 +68,7 @@
                                 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="listactions[% l.patron_list_id %]">
                                     <li><a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id %]"><i class="fa fa-user"></i> Add patrons</a></li>
                                     <li><a href="/cgi-bin/koha/patron_lists/add-modify.pl?patron_list_id=[% l.patron_list_id %]"><i class="fa fa-pencil"></i> Edit list</a></li>
-                                    <li><a href="/cgi-bin/koha/patron_lists/delete.pl?patron_list_id=[% l.patron_list_id %]" onclick='return ConfirmDelete("[% l.name %]")'><i class="fa fa-trash"></i> Delete list</a></li>
+                                    <li><a class="delete_patron" href="/cgi-bin/koha/patron_lists/delete.pl?patron_list_id=[% l.patron_list_id %]" data-list-name="[% l.name %]"><i class="fa fa-trash"></i> Delete list</a></li>
                                     [% IF ( l.patron_list_patrons_rs.count ) %]
                                         <li class="divider"></li>
                                         <li><a href="#" onclick='GB_showCenter(_("Print patron cards from list"), "/cgi-bin/koha/patroncards/print.pl?patronlist_id=[% l.patron_list_id %]", 400, 800);return false;'><i class="fa fa-print"></i> Print patron cards</a></li>
index b2ede43..84b58eb 100644 (file)
@@ -3,7 +3,6 @@
     [% INCLUDE 'doc-head-close.inc' %]
     <script type="text/javascript">
         //<![CDATA[
-            var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this image?");
             function DeleteConfirm() {
                 var results = selected_images("delete");
                 if (results.images != -1) {
@@ -40,6 +39,9 @@
             $("#delete").click(function(){
                 return DeleteConfirm();
             });
+            $(".delete_image").on("click", function(){
+                return confirmDelete( _("Are you sure you want to delete this image?") );
+            });
          });
         //]]>
     </script>
                                     [% FOREACH text_field IN TABL.text_fields %]
                                     [% IF ( text_field.select_field ) %]
                                         <td>
-                                            <a class="btn btn-mini" onclick="return confirm(MSG_CONFIRM_DELETE);" href="/cgi-bin/koha/patroncards/image-manage.pl?op=delete&image_id=[% text_field.field_value %]"><icon class="fa fa-trash"></icon> Delete</a>
+                                            <a class="delete_image btn btn-mini" href="/cgi-bin/koha/patroncards/image-manage.pl?op=delete&image_id=[% text_field.field_value %]"><icon class="fa fa-trash"></icon> Delete</a>
                                         </td>
                                         <td align="center"><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>
                                     [% ELSIF ( text_field.field_value ) %]
index 481fc58..62dd962 100644 (file)
             ],
             "sPaginationType": "full_numbers"
         }));
+        $(".delete_news").on("click", function(){
+            return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
+        });
+        $("#del_form").on("submit",function(){
+            return confirmDelete( _("Are you sure you want to delete the selected news?") );
+        });
     });
     //]]>
     </script>
 [% END %]
 <script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script>
 <script type="text/javascript">//<![CDATA[
-var MSG_CONFIRM_DELETE_NEWS  = _("Are you sure you want to delete the selected news?");
-var MSG_CONFIRM_DELETE_SINGLE = _("Are you sure you want to delete this news item? This cannot be undone.");
-
 tinyMCE.init({
     mode : "textareas",
     theme : "advanced",
@@ -204,7 +207,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
         </form>
         </div>
         [% IF ( opac_news_count ) %]
-        <form name="del_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" onsubmit='return confirm(MSG_CONFIRM_DELETE_NEWS)'>
+        <form id="del_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl">
                 <table id="newst">
                    <thead> <tr>
                         <th>&nbsp;</th>
@@ -252,7 +255,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
                             </td>
                             <td class="actions">
                                 <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew %]" class="btn btn-mini"><i class="fa fa-pencil"></i> Edit</a>
-                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% opac_new.idnew %]" onclick="return confirm(MSG_CONFIRM_DELETE_SINGLE);" class="btn btn-mini"><i class="fa fa-trash"></i> Delete</a>
+                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% opac_new.idnew %]" class="delete_news btn btn-mini"><i class="fa fa-trash"></i> Delete</a>
                             </td>
                         </tr>
                     [% END %]</tbody>
@@ -261,7 +264,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
                 <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
             </form>
         [% ELSE %]
-            <p>No news loaded</p>
+            <div class="dialog message">There are no news items.</div>
         [% END %]
     [% END %]
 </div>