From 80ed036784a0c4697e4cdf4315e98331b4651744 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Tue, 18 Sep 2012 17:34:51 +0200 Subject: [PATCH 3/3] Bug 7455: Authority subfields are cloned in the wrong field (follow-up 2) --- authorities/authorities.pl | 2 +- cataloguing/addbiblio.pl | 25 ++++--------- koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js | 9 ++--- .../prog/en/modules/authorities/authorities.tt | 38 -------------------- 4 files changed, 12 insertions(+), 62 deletions(-) diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 879c574..14cecd3 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -200,7 +200,7 @@ sub create_input { tabindex=\"1\" readonly=\"readonly\" \/> {$tag}->{$subfield}->{authtypecode}."'); return false;\" tabindex=\"1\" title=\"Tag Editor\">... + onclick=\"openAuth(this.parentNode.getElementsByTagName('input')[1].id,'".$tagslib->{$tag}->{$subfield}->{authtypecode}."','auth'); return false;\" tabindex=\"1\" title=\"Tag Editor\">... "; # it's a plugin field } diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 3db1a65..2d591c6 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -372,7 +372,8 @@ sub create_input { # it's a thesaurus / authority field } elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) { - if (C4::Context->preference("BiblioAddsAuthorities")) { + # when authorities auto-creation is allowed, do not set readonly + my $is_readonly = !C4::Context->preference("BiblioAddsAuthorities"); $subfield_data{marc_value} = " + maxlength=\"".$subfield_data{maxlength}."\"". + ($is_readonly ? "readonly=\"readonly\"" : ""). + "\/> {$tag}->{$subfield}->{authtypecode}."'); return false;\" tabindex=\"1\" title=\"Tag Editor\">\"Tag - "; - } else { - $subfield_data{marc_value} = - "{$tag}->{$subfield}->{authtypecode}."'); return false;\" tabindex=\"1\" title=\"Tag Editor\">\"Tag + onclick=\"openAuth(this.parentNode.parentNode.getElementsByTagName('input')[1].id,'".$tagslib->{$tag}->{$subfield}->{authtypecode}."','biblio'); return false;\" tabindex=\"1\" title=\"Tag Editor\">\"Tag "; - } # it's a plugin field } elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js index 96cdea0..09df5cd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/cataloging.js @@ -33,7 +33,8 @@ function getTagInputnameFilter(tagsubfieldid){ return tagsubfield; } -function openAuth(tagsubfieldid,authtype) { +// if source is "auth", we are editing an authority otherwise it is a biblio +function openAuth(tagsubfieldid,authtype,source) { // let's take the base of tagsubfield information (removing the indexes and the codes var element=document.getElementById(tagsubfieldid); var tagsubfield=getTagInputnameFilter(tagsubfieldid); @@ -47,10 +48,10 @@ function openAuth(tagsubfieldid,authtype) { var subfieldcode=getSubfieldCode(inputs[myindex].name); if (isNaN(parseInt(subfieldcode)) && inputs[myindex].value != "" && subfieldcode!=elementsubfcode){ mainstring=inputs[myindex].value+" "+mainstring; - } + } } - } - newin=window.open("../authorities/auth_finder.pl?authtypecode="+ authtype+ "&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); + } + newin=window.open("../authorities/auth_finder.pl?source="+source+"&authtypecode="+authtype+"&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); } function ExpandField(index) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt index 87919d7..e5714bb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt @@ -102,44 +102,6 @@ function Check(){ } } - -// returns the subfieldcode based upon subfieldid writing -function getSubfieldcode(tagsubfieldid){ - // 3 : tag +3 : tagnumber +4 : number of _ +8 subfield -1 begins at 0 - return tagsubfieldid.substr(3+3+4+8-1,1); -} - -// Take the base of tagsubfield information (removing the subfieldcodes and subfieldindexes) -// returns the filter -function getTagInputnameFilter(tagsubfieldid){ - var tagsubfield=tagsubfieldid.substr(0,tagsubfieldid.lastIndexOf("_")); - var tagcode=tagsubfield.substr(tagsubfield.lastIndexOf("_")); - tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_")); - tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_")); - tagsubfield=tagsubfield+"_."+tagcode; - return tagsubfield; -} - -function openAuth(tagsubfieldid,authtype) { - // let's take the base of tagsubfield information (removing the indexes and the codes - var element=document.getElementById(tagsubfieldid); - var tagsubfield=getTagInputnameFilter(tagsubfieldid); - var elementsubfcode=getSubfieldcode(element.name); - var mainmainstring=element.value; - var mainstring=""; - var inputs = element.parentNode.parentNode.getElementsByTagName("input"); - - for (var myindex =0; myindex