From feb625ce50af6765498feb2ab15912e0286f48a9 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 edit template 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. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- .../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 15ed36d6a5..21ec946db8 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.39.5