Bugzilla – Attachment 53004 Details for
Bug 16763
Remove the use of "onclick" from record matching rules form
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF]Bug 16763: Remove the use of "onclick" from record matching rules form
SIGNED-OFFBug-16763-Remove-the-use-of-onclick-from.patch (text/plain), 14.28 KB, created by
Héctor Eduardo Castro Avalos
on 2016-06-30 19:32:43 UTC
(
hide
)
Description:
[SIGNED-OFF]Bug 16763: Remove the use of "onclick" from record matching rules form
Filename:
MIME Type:
Creator:
Héctor Eduardo Castro Avalos
Created:
2016-06-30 19:32:43 UTC
Size:
14.28 KB
patch
obsolete
>From 2af5c954fa9df3081ae6d8794756c9ad3d3f95ff Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >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 <hector.hecaxmmx@gmail.com> >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 ); >+ }) >+}) > //]]> > </script> > <style type="text/css"> >@@ -197,7 +163,7 @@ function CheckRuleForm(f) { > [% ELSE %] > <h2>Add record matching rule</h2> > [% END %] >-<form action="[% script_name %]" name="Aform" method="post"> >+<form action="[% script_name %]" name="Aform" method="post" class="validated"> > <input type="hidden" name="op" value="[% confirm_op %]" /> > <fieldset class="rows"> > <ol> >@@ -209,19 +175,19 @@ function CheckRuleForm(f) { > [% code %] > [% ELSE %] > <label for="code" class="required">Matching rule code: </label> >- <input type="text" id="code" name="code" size="10" maxlength="10" /> <span class="required">Required</span> >+ <input type="text" id="code" name="code" size="10" maxlength="10" class="required" required="required" /> <span class="required">Required</span> > [% END %] > </li> > <li><label for="description" class="required">Description: </label> > <input type="text" id="description" name="description" size="50" maxlength="250" >- value="[% description |html %]" /> <span class="required">Required</span> >+ value="[% description |html %]" class="required" required="required" /> <span class="required">Required</span> > </li> > <li><label for="threshold" class="required">Match threshold: </label> > <input type="text" id="threshold" name="threshold" size="5" maxlength="5" >- value="[% threshold |html %]" /> <span class="required">Required</span> >+ value="[% threshold |html %]" class="required" required="required" /> <span class="required">Required</span> > </li> > <li><label for="record_type" class="required">Record type: </label> >- <select id="record_type" name="record_type"> >+ <select id="record_type" name="record_type" class="required" required="required" > > [% IF ( record_type == "authority" ) %] > <option value="biblio">Bibliographic record</option> > <option value="authority" selected="selected">Authority record</option> >@@ -237,13 +203,20 @@ function CheckRuleForm(f) { > <fieldset class="rows" id="match_points"> > <h4>Match points</h4> > [% IF ( edit_matching_rule ) %] >- [% IF ( matchpoints ) %]<p id="addMatchPoint" style="display:none;">[% ELSE %]<p id="addMatchPoint">[% END %]<a href="#" class="button" onclick="InsertMatchpoint('mp_1', 'mp_template'); return false;">Add match point</a></p> >- [% ELSE %]<p id="addMatchPoint" style="display:none;"><a href="#" class="button" onclick="InsertMatchpoint('mp_1', 'mp_template'); return false;">Add match point</a></p>[% END %] >+ [% IF ( matchpoints ) %] >+ <p id="addMatchPoint" style="display:none;"> >+ [% ELSE %] >+ <p id="addMatchPoint"> >+ [% END %] >+ <a href="#" class="insert_match_point button" data-loc="mp_1" data-index="mp_template"><i class="fa fa-plus"></i> Add match point</a></p> >+ [% ELSE %] >+ <p id="addMatchPoint" style="display:none;"><a href="#" class="insert_match_point button" data-loc="mp_1" data-index="mp_template"><i class="fa fa-plus"></i> Add match point</a></p> >+ [% END %] > [% IF ( edit_matching_rule ) %] > [% FOREACH matchpoint IN matchpoints %] > <div id="mp_[% matchpoint.mp_num %]" class="matchgroup"> > <fieldset class="rows"> >- <legend>Match point [% matchpoint.mp_num %] | <a href="#" class="button" onclick="InsertMatchpoint('mp_[% matchpoint.mp_num %]', 'mp_template'); return false;">Add match point</a> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;">Remove this match point</a></legend> >+ <legend>Match point [% matchpoint.mp_num %] | <a href="#" class="insert_match_point button" data-loc="mp_[% matchpoint.mp_num %]" data-index="mp_template"><i class="fa fa-plus"></i> Add match point</a> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;"><i class="fa fa-trash"></i> Remove this match point</a></legend> > <ol> > <li> > <label for="mp_[% matchpoint.mp_num %]_search_index">Search index: </label> >@@ -295,7 +268,7 @@ function CheckRuleForm(f) { > [% FOREACH norm IN component.norms %] > <li id="mp_[% matchpoint.mp_num %]_c_[% component.comp_num %]_n_[% norm.norm_num %]"> > <label for="mp_[% matchpoint.mp_num %]_c_[% component.comp_num %]_n__[% norm.norm_num %]_norm">Normalization rule: </label> >- <input type="text" id="mp_[% norm.mp_num %]_c_[% component.comp_num %]_n__[% norm.norm_num %]_norm" >+ <input type="text" id="mp_[% matchpoint.mp_num %]_c_[% component.comp_num %]_n__[% norm.norm_num %]_norm" > name="mp_[% matchpoint.mp_num %]_c_[% component.comp_num %]_n_[% norm.norm_num %]_norm" > value="[% norm.norm |html %]" > size="20" maxlength="50" /> >@@ -313,7 +286,7 @@ function CheckRuleForm(f) { > [% ELSE %] > <div id="mp_1" class="matchgroup"> > <fieldset class="rows"> >- <legend>Match point 1 | <a href="#" class="button" onclick="InsertMatchpoint('mp_1', 'mp_template'); return false;">Add match point</a> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;">Remove this match point</a></legend> >+ <legend>Match point 1 | <a href="#" class="insert_match_point button" data-loc="mp_1" data-index="mp_template"><i class="fa fa-plus"></i> Add match point</a> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;"><i class="fa fa-trash"></i> Remove this match point</a></legend> > <ol> > <li> > <label for="mp_1_search_index">Search index: </label> >@@ -360,13 +333,13 @@ function CheckRuleForm(f) { > <fieldset class="rows" id="match_checks"> > <h4>Required match checks</h4> > [% IF ( edit_matching_rule ) %] >- [% IF ( matchchecks ) %]<p id="addMatchCheck" style="display:none;">[% ELSE %]<p id="addMatchCheck">[% END %]<a href="#" class="button" onclick="InsertMatchcheck('mc_1', 'mc_template'); return false;">Add match check</a></p> >- [% ELSE %]<p id="addMatchCheck" style="display:none;"><a href="#" class="button" onclick="InsertMatchcheck('mc_1', 'mc_template'); return false;">Add match check</a></p>[% END %] >+ [% IF ( matchchecks ) %]<p id="addMatchCheck" style="display:none;">[% ELSE %]<p id="addMatchCheck">[% END %]<a href="#" class="insert_match_check button" data-loc="mc_1" data-index="mc_template"><i class="fa fa-plus"></i> Add match check</a></p> >+ [% ELSE %]<p id="addMatchCheck" style="display:none;"><a href="#" class="insert_match_check button" data-loc="mc_1" data-index="mc_template"><i class="fa fa-plus"></i> Add match check</a></p>[% END %] > [% IF ( edit_matching_rule ) %] > [% FOREACH matchcheck IN matchchecks %] > <div id="mc_[% matchcheck.mc_num %]" class="matchgroup"> > <fieldset class="rows"> >- <legend>Match check [% matchcheck.mc_num %]<a href="#" class="button" onclick="InsertMatchcheck('mc_[% matchcheck.mc_num %]', 'mc_template'); return false;">Add match check</a> | <a href="#" class="button" onclick="DeleteMatchcheck(this); return false;">Remove this match check</a></legend> >+ <legend>Match check [% matchcheck.mc_num %] | <a href="#" class="insert_match_check button" data-loc="mc_[% matchcheck.mc_num %]" data-index="mc_template"><i class="fa fa-plus"></i> Add match check</a> | <a href="#" class="delete_match_check button"><i class="fa fa-trash"></i> Remove this match check</a></legend> > <input type="hidden" id="mc_[% matchcheck.mc_num %]_id" name="mc_[% matchcheck.mc_num %]_id" value="1" /> > [% FOREACH src_component IN matchcheck.src_components %] > <fieldset class="rows" id="mc_[% src_component.mc_num %]_src_c_[% src_component.comp_num %]"> >@@ -463,7 +436,7 @@ function CheckRuleForm(f) { > [% ELSE %] > <div id="mc_1" class="matchgroup"> > <fieldset class="rows"> >- <legend>Match check 1 | <a href="#" class="button" onclick="InsertMatchcheck('mc_1', 'mc_template'); return false;">Add match check</a> | <a href="#" class="button" onclick="DeleteMatchcheck(this); return false;">Remove this match check</a></legend> >+ <legend>Match check 1 | <a href="#" class="insert_match_check button" data-loc="mc_1" data-index="mc_template"><i class="fa fa-plus"></i> Add match check</a> | <a href="#" class="delete_match_check button"><i class="fa fa-trash"></i> Remove this match check</a></legend> > <input type="hidden" id="mc_1_id" name="mc_1_id" value="1" /> > <fieldset class="rows" id="mc_1_src_c_1"> > <legend>Source (incoming) record check field</legend> >@@ -522,13 +495,8 @@ function CheckRuleForm(f) { > [% END %] > </fieldset> > <fieldset class="action"> >- [% IF ( edit_matching_rule ) %] >- <input type="button" value="Save" >- onclick="CheckMatchingRuleForm(this.form)" /> >- [% ELSE %] >- <input type="button" value="Save" >- onclick="CheckMatchingRuleForm(this.form)" /> >- [% END %] >+ <input type="submit" value="Save" /> >+ > <a class="cancel" href="/cgi-bin/koha/admin/matching-rules.pl">Cancel</a> > </fieldset> > </form> >@@ -590,7 +558,7 @@ function CheckRuleForm(f) { > [% IF ( matching_rule_form ) %] > <div id="mp_template" class="matchgroup" style="display:none;"> > <fieldset class="rows"> >- <legend>Match point <span class="counter"></span> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;">Remove this match point</a></legend> >+ <legend>Match point <span class="counter"></span> | <a href="#" class="button" onclick="DeleteMatchpoint(this); return false;"><i class="fa fa-trash"></i> Remove this match point</a></legend> > <ol> > <li> > <label for="mp_num_search_index">Search index: </label> >@@ -633,7 +601,7 @@ function CheckRuleForm(f) { > > <div id="mc_template" class="matchgroup" style="display:none"> > <fieldset class="rows"> >- <legend>Match check <span class="counter"></span> | <a href="#" class="button" onclick="DeleteMatchcheck(this); return false;">Remove this match check</a></legend> >+ <legend>Match check <span class="counter"></span> | <a href="#" class="delete_match_check button"><i class="fa fa-trash"></i> Remove this match check</a></legend> > <input type="hidden" id="mc_num_id" name="mc_num_id" value="1" /> > <fieldset class="rows" id="mc_num_src_c_1"> > <legend>Source (incoming) record check field</legend> >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16763
:
52499
|
53004
|
54487