Bug 24393: Remove event attributes from patron clubs list template
authorOwen Leonard <oleonard@myacpl.org>
Thu, 9 Jan 2020 19:09:31 +0000 (19:09 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 20 Jan 2020 14:03:51 +0000 (14:03 +0000)
This patch removes some instances of the "onclick" attributes from the
template that lists patron clubs and templates.

To test, apply the patch and go to Tools -> Patron clubs.

 - Test the process of deleting a club template. Clicking the "Delete"
   button should trigger a confirmation. Confirming should delete the
   template.

 - Test the process of deleting a club. In the "Clubs" section of the
   page, click the "Actions" menu next to any club. Clicking the
   "Delete" link should trigger a confirmation. Confirming should delete
   the club.

 - Also in the "Clubs" section of the page, find a club which has
   enrollments. Select "Search to hold" from the "Actions" menu. It
   should take you to the advanced search. On the search results page
   you should have the option to place a hold for the club you selected.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
koha-tmpl/intranet-tmpl/prog/en/includes/clubs-table.inc
koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt

index 62027b1..0686953 100644 (file)
                                         </a>
                                     </li>
                                     <li>
-                                        <a href="#" onclick='ConfirmDeleteClub([% c.id | html %], "[% c.name | html %]", $(this) ); return false;'>
+                                        <a href="#" class="delete_club" data-id="[% c.id | html %]" data-name="[% c.name | html %]">
                                             <i class="fa fa-trash"></i> Delete
                                         </a>
                                     </li>
                                 [% END %]
                                 [% IF ( c.club_enrollments.count ) %]
                                     <li>
-                                        <a href="#" onclick="SearchToHold([% c.id | html %])">
+                                        <a href="#" class="club_hold_search" data-id="[% c.id | html %]">
                                             <i class="fa fa-search"></i> Search to hold
                                         </a>
                                     </li>
index e4176a9..2258635 100644 (file)
@@ -87,7 +87,7 @@
                                             <a class="btn btn-xs btn-default" style="white-space:nowrap"  href="/cgi-bin/koha/clubs/templates-add-modify.pl?id=[% t.id | html %]">
                                                 <i class="fa fa-pencil"></i> Edit
                                             </a>
-                                            <a class="btn btn-xs btn-default" href="#" onclick='ConfirmDeleteTemplate([% t.id | html %], "[% t.name | html %]", $(this) ); return false;'>
+                                            <a class="btn btn-xs btn-default delete_template" href="#" data-id="[% t.id | html %]" data-name="[% t.name | html %]">
                                                 <i class="fa fa-trash"></i> Delete
                                             </a>
                                         [% END %]
                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
                 ]
             } ));
+
+            $(".delete_club").on("click", function(e){
+                e.preventDefault();
+                var club_id = $(this).data("id");
+                var club_name = $(this).data("name");
+                ConfirmDeleteClub( club_id, club_name );
+            });
+
+            $(".delete_template").on("click", function(e){
+                e.preventDefault();
+                var template_id = $(this).data("id");
+                var template_name = $(this).data("name");
+                ConfirmDeleteTemplate( template_id, template_name );
+            });
+
+            $(".club_hold_search").on("click", function(e){
+                e.preventDefault;
+                var club_id = $(this).data("id");
+                SearchToHold( club_id );
+            });
         });
 
-        function ConfirmDeleteTemplate( id, name, a ) {
+        function ConfirmDeleteTemplate( id, name ) {
             if ( confirm( _("Are you sure you want to delete the club template %s? This will delete all clubs using this template and cancel patron enrollments" ).format(name) ) ) {
                 $.ajax({
                     type: "POST",
             }
         }
 
-        function ConfirmDeleteClub( id, name, a ) {
+        function ConfirmDeleteClub( id, name ) {
             if ( confirm( _("Are you sure you want to delete the club %s? This will cancel all patron enrollments in this club." ).format(name) ) ) {
                 $.ajax({
                     type: "POST",