From ccacbcf50237fff55ac85373268154353216301a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 18 Jul 2016 14:44:13 -0400 Subject: [PATCH] [SIGNED-OFF]Bug 16938: Remove the use of "onclick" from batch patrons modification template This patch revises the batch patrons modification template, removing "onclick" attributes from the markup and defining those events in the script. To test you should have at least one extended patron attribute configured. - Apply the patch and go to Tools -> Batch patron modification. - Submit a batch of patrons for modification. - Confirm that the checkbox next to any required field is disabled. - Select a date in the registration date and expiry date fields. Confirm that the "Clear" link next to each empties the correct field. - Click "New" next to a patron attibute. A copy of the patron attribute line should be created. - Click "Delete" next to a cloned patron attribute. The correct line should be removed. Signed-off-by: Hector Castro Works as advertised --- .../prog/en/modules/tools/modborrowers.tt | 25 +++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt index 54227e6..3c12f0a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -58,7 +58,20 @@ $('select[name="patron_attributes"]').change(); - } ); + $(".clear-date").on("click",function(e){ + e.preventDefault(); + var fieldID = this.id.replace("clear-date-",""); + $("#" + fieldID).val(""); + }); + $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){ + e.preventDefault(); + add_attributes(); + }); + $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){ + e.preventDefault(); + del_attributes(this); + }); + }); function updateAttrValues (select_attr) { var attr_code = $(select_attr).val(); @@ -84,8 +97,8 @@ function add_attributes() { var li_node = $("li.attributes:last"); var li_clone = $(li_node).clone(); - if ( $(li_clone).find("a.delete").length == 0 ) { - $(li_clone).append(' Delete'); + if ( $(li_clone).find("a.del_attributes").length == 0 ) { + $(li_clone).append(' Delete'); } $(li_clone).find('select[name="patron_attributes"]').change(function() { updateAttrValues(this); @@ -335,7 +348,7 @@ [% END %] [% IF field.mandatory %] - + [% ELSE %] [% END %] @@ -355,7 +368,7 @@ [% END %] [% IF ( field.type == 'date' ) %] - Clear + Clear [% END %] [% IF field.mandatory %] Required fields cannot be cleared @@ -373,7 +386,7 @@ - New + New [% END %] -- 1.7.10.4