From 2af5c954fa9df3081ae6d8794756c9ad3d3f95ff Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 20 Apr 2016 13:55:59 -0400 Subject: [PATCH] [SIGNED-OFF]Bug 16763: Remove the use of "onclick" from record matching rules form This patch revises the record matching rules edit form to remove the use of "onclick" in favor of defining events in JavaScript. Also changed: Custom form validation JS is replaced by use of the built-in validation plugin; Font Awesome icons are added to 'add' and 'remove' links. To test, apply the patch and go to Administration -> Record matching rules. - When adding or editing a record matching rule, the description, match threshold, and record type should be required. - With both match points and match checks, the "add" and "remove" links should work correctly to show a new section with a blank form. "Add" and "remove" links should work correctly whether the form is in a saved state (i.e. the saved data has just been opened for editing), or whether the links have been added to the page as part of an "add" operation. - When adding a match point or a match check, data added in additional entries should be saved correctly. - After removing a match point or match check, the data should be saved correctly. Signed-off-by: Hector Castro Works as advertised --- .../prog/en/modules/admin/matching-rules.tt | 118 +++++++------------- 1 file changed, 43 insertions(+), 75 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt index acb33a7..9e3979f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt @@ -106,58 +106,24 @@ function DeleteMatchcheck(loc) { $("#addMatchCheck").show(); } } - -function DoCancel(f) { - f.op.value=''; - document.Aform.submit(); -} - -function CheckMatchingRuleForm(f) { - var ok=1; - var _alertString=""; - var alertString2; - if (f.code.value.length==0) { - _alertString += "\n- " + _("Matching rule code missing"); - } - if (f.description.value.length==0) { - _alertString += "\n- " + _("Description missing"); - } - if (f.threshold.value.length==0) { - _alertString += "\n- " + _("Threshold missing"); - } - if (_alertString.length==0) { - document.Aform.submit(); - } else { - alertString2 = _("Form not submitted because of the following problem(s)"); - alertString2 += "\n------------------------------------------------------------------------------------\n"; - alertString2 += _alertString; - alert(alertString2); - } -} - -function CheckRuleForm(f) { - var ok=1; - var _alertString=""; - var alertString2; - if (f.sort_rule.value.length==0) { - _alertString += "\n- " + _("Filing rule code missing"); - } - if (f.description.value.length==0) { - _alertString += "\n- " + _("Description missing"); - } - if (f.sort_routine.value.length==0) { - _alertString += "\n- " + _("Sort routine missing"); - } - if (_alertString.length==0) { - document.Aform.submit(); - } else { - alertString2 = _("Form not submitted because of the following problem(s)"); - alertString2 += "\n------------------------------------------------------------------------------------\n"; - alertString2 += _alertString; - alert(alertString2); - } -} - +$(document).ready(function(){ + $("body").on("click",".insert_match_point",function(e){ + e.preventDefault(); + var loc = $(this).data("loc"); + var index = $(this).data("index"); + InsertMatchpoint( loc, index ); + }); + $("body").on("click",".insert_match_check",function(e){ + e.preventDefault(); + var loc = $(this).data("loc"); + var index = $(this).data("index"); + InsertMatchcheck( loc, index ); + }); + $("body").on("click",".delete_match_check",function(e){ + e.preventDefault(); + DeleteMatchcheck( this ); + }) +}) //]]>