From 6d9c04462b0dcd218d4f94396c520636d838cbf3 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Tue, 28 Aug 2012 14:55:01 +0200 Subject: [PATCH 2/3] Bug 7455: Authority subfields are cloned in the wrong field (follow-up) --- authorities/authorities.pl | 16 +++++++++------- koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js | 4 ++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/authorities/authorities.pl b/authorities/authorities.pl index f6263d9..879c574 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -152,9 +152,15 @@ sub create_input { $value =~ s/DD/$day/g; } my $dbh = C4::Context->dbh; + + # map '@' as "subfield" label for fixed fields + # to something that's allowed in a div id. + my $id_subfield = $subfield; + $id_subfield = "00" if $id_subfield eq "@"; + my %subfield_data = ( tag => $tag, - subfield => $subfield, + subfield => $id_subfield, marc_lib => substr( $tagslib->{$tag}->{$subfield}->{lib}, 0, 22 ), marc_lib_plain => $tagslib->{$tag}->{$subfield}->{lib}, tag_mandatory => $tagslib->{$tag}->{mandatory}, @@ -162,14 +168,10 @@ sub create_input { repeatable => $tagslib->{$tag}->{$subfield}->{repeatable}, kohafield => $tagslib->{$tag}->{$subfield}->{kohafield}, index => $index_tag, - id => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield, + id => "tag_".$tag."_subfield_".$id_subfield."_".$index_tag."_".$index_subfield, value => $value, + random => CreateKey(), ); - if($subfield eq '@'){ - $subfield_data{id} = "tag_".$tag."_subfield_00_".$index_tag."_".$index_subfield; - } else { - $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield; - } if(exists $mandatory_z3950->{$tag.$subfield}){ $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js index 29ab1eb..96cdea0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js @@ -211,6 +211,10 @@ function CloneField(index, hideMarc, advancedMARCEditor) { } else { // it's a indicator div if(divs[i].getAttribute('id').match(/^div_indicator/)){ + + // setting a new id for the indicator div + divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key); + var inputs = divs[i].getElementsByTagName('input'); inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key); inputs[1].setAttribute('id',inputs[1].getAttribute('id')+new_key); -- 1.7.9.5