From bbb64b749be1968111352fa757b0a881e9b6cd2d Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 9 Jan 2020 17:45:47 +0000 Subject: [PATCH] Bug 24391: Remove event attributes from patron clubs templates This patch removes "onclick" attributes from the template for adding and editing patron club templates. To test, apply the patch and go to Tools -> Patron clubs -> New club template. Test the process of adding and deleting both club and enrollment fields. Test during the template add process and when editing an existing template. --- .../prog/en/modules/clubs/templates-add-modify.tt | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt index 15ed36d6a59..21ec946db8b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/templates-add-modify.tt @@ -1,5 +1,6 @@ [% USE Branches %] [% USE AuthorisedValues %] +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Patron clubs › [% IF club_template %] @@ -124,7 +125,7 @@ [% END %] </div> <fieldset class="action"> - <a href="#" onclick="$('#new-field-template').clone().attr('id','').show().appendTo('#club-template-fields'); return false;"> + <a href="#" class="add_club_field"> <i class="fa fa-plus"></i> Add new field </a> </fieldset> @@ -169,7 +170,7 @@ [% END %] </div> <fieldset class="action"> - <a href="#" onclick="$('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); return false;"> + <a href="#" class="add_enrollment_field"> <i class="fa fa-plus"></i> Add new field </a> </fieldset> @@ -209,7 +210,7 @@ </select> </li> </ol> - <fieldset class="action"><a href="#" onclick="$(this).parent().parent().remove(); return false;"><i class="fa fa-trash"></i> Delete field</a></fieldset> + <fieldset class="action"><a href="#" class="delete_club_field"><i class="fa fa-trash"></i> Delete field</a></fieldset> <hr/> </div> @@ -236,7 +237,32 @@ </select> </li> </ol> - <fieldset class="action"><a href="#" onclick="$(this).parent().parent().remove(); return false;"><i class="fa fa-trash"></i> Delete field</a></fieldset> + <fieldset class="action"><a href="#" class="delete_enrollment_field"><i class="fa fa-trash"></i> Delete field</a></fieldset> </div> + +[% MACRO jsinclude BLOCK %] + <script> + $("body").on("click", ".add_club_field", function(e){ + e.preventDefault(); + $("#new-field-template").clone().attr("id","").show().appendTo("#club-template-fields"); + }); + + $("body").on("click", ".delete_club_field", function(e){ + e.preventDefault(); + $(this).parent().parent().remove(); + }); + + $("body").on("click", ".delete_enrollment_field", function(e){ + e.preventDefault(); + $(this).parent().parent().remove(); + }); + + $("body").on("click", ".add_enrollment_field", function(e){ + e.preventDefault(); + $('#new-enrollment-field-template').clone().attr('id','').show().appendTo('#club-template-enrollment-fields'); + }); + </script> +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] -- 2.11.0