From 84205212b45ebaef1969e688fea1eb544cee78f4 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 5 Jan 2011 03:26:30 -0500 Subject: [PATCH] Fix for Bug 5006 - Invalid XHTML in record matching rules template - Rework JavaScript clone routines to use jQuery, to take label "for" into account, to handle incrementing label, and to properly place cloned blocks at the bottom of the group - Rework JavaScript delete routines to use jQuery, to take block label numbers into account, and to show the "add" link if you have deleted the last block. - Correcting markup which nests
inside
- Ensuring labels' "for" attribute matches input IDs - Adding "required" style to required fields Signed-off-by: Nicole Engard Signed-off-by: Chris Cormack --- .../prog/en/css/staff-global.css | 1 + .../prog/en/modules/admin/matching-rules.tmpl | 273 +++++++++--------- 2 files changed, 135 insertions(+), 139 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index 9cc5ba0d10..b6d439d1dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -1919,3 +1919,4 @@ ul.budget_hierarchy li:first-child:after { padding : 1em; margin : 1em 0; } +fieldset.rows+h3 {clear:both;padding-top:.5em;} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tmpl index bfa2ed9392..d0b9a2037b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tmpl @@ -20,75 +20,91 @@ var maxMatchPoint = ; var maxMatchCheck = ; function InsertMatchpoint(loc, index) { - var original= document.getElementById(index); - var clone = original.cloneNode(true); - clone.style.display = 'block'; + var original= $("#"+index); + var clone = original.clone(); + clone.show(); // update IDs and form names maxMatchPoint++; - clone.setAttribute('id', 'mp_' + maxMatchPoint); - var divs = clone.getElementsByTagName('div'); - for (var i = 0; i < divs.length; i++) { - var s = divs[i].getAttribute('id'); + clone.attr('id', 'mp_' + maxMatchPoint); + $("span.counter",clone).html(maxMatchPoint); + $("label",clone).each(function(){ + var s = $(this).attr("for"); if (s.match(/mp_num/)) { - divs[i].setAttribute('id', s.replace(/mp_num/, 'mp_' + maxMatchPoint)); + $(this).attr("for",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); } - } - var inputs = clone.getElementsByTagName('input'); - for (var i = 0; i < inputs.length; i++) { - var s = inputs[i].getAttribute('id'); + }); + + $("div",clone).each(function(){ + var s = $(this).attr("id"); if (s.match(/mp_num/)) { - inputs[i].setAttribute('id', s); - inputs[i].setAttribute('id', s.replace(/mp_num/, 'mp_' + maxMatchPoint)); + $(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); } - var s = inputs[i].getAttribute('name'); - if (s.match(/mp_num/)) { - inputs[i].setAttribute('name', s.replace(/mp_num/, 'mp_' + maxMatchPoint)); + }); + $("input",clone).each(function(){ + var s = $(this).attr("id"); + if(s.match(/mp_num/)){ + $(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); } - } - loc.parentNode.parentNode.insertBefore(clone, loc.nextSibling); + var s = $(this).attr("name"); + if(s.match(/mp_num/)){ + $(this).attr("name",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); + } + }); + $("#match_points").append(clone); } function InsertMatchcheck(loc, index) { - var original= document.getElementById(index); - var clone = original.cloneNode(true); - clone.style.display = 'block'; + var original= $("#"+index); + var clone = original.clone(); + clone.show(); // update IDs and form names maxMatchCheck++; - clone.setAttribute('id', 'mc_' + maxMatchCheck); - var divs = clone.getElementsByTagName('div'); - for (var i = 0; i < divs.length; i++) { - var s = divs[i].getAttribute('id'); + clone.attr('id', 'mc_' + maxMatchCheck); + $("span.counter",clone).html(maxMatchCheck); + $("label",clone).each(function(){ + var s = $(this).attr("for"); if (s.match(/mc_num/)) { - divs[i].setAttribute('id', s.replace(/mc_num/, 'mc_' + maxMatchCheck)); + $(this).attr("for",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); } - } - var inputs = clone.getElementsByTagName('input'); - for (var i = 0; i < inputs.length; i++) { - var s = inputs[i].getAttribute('id'); + }); + + $("div",clone).each(function(){ + var s = $(this).attr("id"); if (s.match(/mc_num/)) { - inputs[i].setAttribute('id', s); - inputs[i].setAttribute('id', s.replace(/mc_num/, 'mc_' + maxMatchCheck)); + $(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); } - var s = inputs[i].getAttribute('name'); - if (s.match(/mc_num/)) { - inputs[i].setAttribute('name', s.replace(/mc_num/, 'mc_' + maxMatchCheck)); + }); + $("input",clone).each(function(){ + var s = $(this).attr("id"); + if(s.match(/mc_num/)){ + $(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); } - } - loc.parentNode.parentNode.insertBefore(clone, loc.nextSibling); + var s = $(this).attr("name"); + if(s.match(/mc_num/)){ + $(this).attr("name",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); + } + }); + $("#match_checks").append(clone); } function DeleteMatchpoint(loc) { - var parentdiv = loc.parentNode.parentNode.parentNode; - parentdiv.parentNode.removeChild(parentdiv); + $(loc).parent().parent().parent().remove(); + if($(".matchgroup",$("#match_points")).length == 0){ + maxMatchPoint = 0; + $("#addMatchPoint").show(); + } } function DeleteMatchcheck(loc) { - var parentdiv = loc.parentNode.parentNode.parentNode; - parentdiv.parentNode.removeChild(parentdiv); + $(loc).parent().parent().parent().remove(); + if($(".matchgroup",$("#match_checks")).length == 0){ + maxMatchCheck = 0; + $("#addMatchCheck").show(); + } } function DoCancel(f) { @@ -145,7 +161,11 @@ function CheckRuleForm(f) { //]]> @@ -188,27 +208,31 @@ function CheckRuleForm(f) { " /> - - + + Required -
  • +
  • " /> + value="" /> Required
  • -
  • +
  • " /> + value="" /> Required
  • -
    - Match points Add matchpoint + +
    +

    Match points

    + +

    Add match point

    + -
    "> +
    " class="matchgroup">
    - Remove this matchpoint + Match Point | ', 'mp_template'); return false;">Add match point | Remove this match point
    1. @@ -224,9 +248,10 @@ function CheckRuleForm(f) { value="" maxlength="5" />
    2. +
    -
    _c_"> -
    +
    _c_"> + Matchpoint components
    1. @@ -256,29 +281,28 @@ function CheckRuleForm(f) { value="" size="5" maxlength="5" />
    2. - -
      _c__n_"> -
    3. - + +
    4. _c__n_"> + _c__n___norm" name="mp__c__n__norm" value="" size="20" maxlength="50" />
    5. -
      - +
    -
    - +
    +
    +
    -
    + -
    +
    - Remove this matchpoint + Match Point 1 | Add match point | Remove this match point
    1. @@ -289,8 +313,9 @@ function CheckRuleForm(f) {
    2. -
      -
      +
    +
    + Matchpoint components
    1. @@ -308,32 +333,31 @@ function CheckRuleForm(f) {
    2. -
      -
    3. +
    4. -
    -
    +
    + +
    - + -
    - -
    - Required match checks Add match check + +
    +

    Required match checks

    + +

    Add match check

    + -
    "> -
    - Remove this match check +
    "> + Match check ', 'mc_template'); return false;">Add match check | Remove this match check _id" name="mc__id" value="1" /> -
      -
      _src_c_"> -
      +
      _src_c_"> Source (incoming) record check field
      1. @@ -365,23 +389,19 @@ function CheckRuleForm(f) { size="5" maxlength="5" />
      2. -
        _src_c__n_"> -
      3. +
      4. _src_c__n_"> _src_c__n__norm" name="mc__src_c__n__norm" value="" size="20" maxlength="50" />
      5. -
      -
      -
      _tgt_c_"> -
      +
      _tgt_c_"> Target (database) record check field
      1. @@ -413,32 +433,25 @@ function CheckRuleForm(f) { size="5" maxlength="5" />
      2. -
        _tgt_c__n_"> -
      3. +
      4. _tgt_c__n_"> _tgt_c__n__norm" name="mc__tgt_c__n__norm" value="" size="20" maxlength="50" />
      5. -
      -
      -
    -
    -
    +
    - Remove this match check + Match check 1 | Add match check | Remove this match check -
      -
      -
      +
      Source (incoming) record check field
      1. @@ -457,17 +470,14 @@ function CheckRuleForm(f) {
      2. -
        -
      3. +
      4. -
      -
      -
      -
      + +
      Target (database) record check field
      1. @@ -486,17 +496,14 @@ function CheckRuleForm(f) {
      2. -
        -
      3. +
      4. -
      -
      -
    +
    @@ -576,9 +583,9 @@ function CheckRuleForm(f) { -
    - - +
    + -