From da48028426b0b6513d1fb59fcffb842d3529fbfa Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Fri, 3 Aug 2012 16:24:46 +0200 Subject: [PATCH 2/2] Bug 7455: Authority subfields are cloned in the wrong field (follow-up 1) --- authorities/authorities.pl | 21 ++++++++++++--------- cataloguing/addbiblio.pl | 5 +++-- koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js | 4 ++++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 23653f6..de79238 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,11 @@ 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(), + fixedfield => $tag < 10 ? 1 : 0, ); - 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}; @@ -441,7 +444,7 @@ sub build_tabs { repeatable => $tagslib->{$tag}->{repeatable}, mandatory => $tagslib->{$tag}->{mandatory}, subfield_loop => \@subfields_data, - fixedfield => ($tag < 10)?(1):(0), + fixedfield => $tag < 10 ? 1 : 0, random => CreateKey, ); if ($tag >= 10){ # no indicator for theses tag @@ -481,7 +484,7 @@ sub build_tabs { indicator2 => $indicator2, subfield_loop => \@subfields_data, tagfirstsubfield => $subfields_data[0], - fixedfield => ($tag < 10)?(1):(0) + fixedfield => $tag < 10 ? 1 : 0, ); push @loop_data, \%tag_data ; diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 3db1a65..a509f31 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -327,6 +327,7 @@ sub create_input { value => $value, maxlength => $tagslib->{$tag}->{$subfield}->{maxlength}, random => CreateKey(), + fixedfield => $tag < 10 ? 1 : 0, ); if(exists $mandatory_z3950->{$tag.$subfield}){ @@ -648,7 +649,7 @@ sub build_tabs { repeatable => $tagslib->{$tag}->{repeatable}, mandatory => $tagslib->{$tag}->{mandatory}, subfield_loop => \@subfields_data, - fixedfield => $tag < 10?1:0, + fixedfield => $tag < 10 ? 1 : 0, random => CreateKey, ); if ($tag >= 10){ # no indicator for 00x tags @@ -697,7 +698,7 @@ sub build_tabs { indicator2 => $indicator2, subfield_loop => \@subfields_data, tagfirstsubfield => $subfields_data[0], - fixedfield => $tag < 10?1:0, + fixedfield => $tag < 10 ? 1 : 0, ); push @loop_data, \%tag_data ; 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