Permalink
Browse files

Bug 7455: Authority subfields are cloned in the wrong field (follow-u…

…p 2)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Passed-QA-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
  • Loading branch information...
1 parent eabe698 commit 7cf5e2e954b8874b5ddc3d9ecb1bf50ed0b11293 Fridolyn SOMERS committed with jcamins Sep 18, 2012
@@ -199,7 +199,7 @@ sub create_input {
class=\"input_marceditor\"
tabindex=\"1\" \/>
<a href=\"#\" class=\"buttonDot\"
- onclick=\"openAuth(this.parentNode.getElementsByTagName('input')[1].id,'".$tagslib->{$tag}->{$subfield}->{authtypecode}."'); return false;\" tabindex=\"1\" title=\"Tag Editor\">...</a>
+ onclick=\"openAuth(this.parentNode.getElementsByTagName('input')[1].id,'".$tagslib->{$tag}->{$subfield}->{authtypecode}."','auth'); return false;\" tabindex=\"1\" title=\"Tag Editor\">...</a>
";
# it's a plugin field
}
View
@@ -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} =
"<input type=\"text\"
id=\"".$subfield_data{id}."\"
@@ -381,26 +382,12 @@ sub create_input {
class=\"input_marceditor readonly\"
tabindex=\"1\"
size=\"67\"
- maxlength=\"".$subfield_data{maxlength}."\"
- \/>
+ maxlength=\"".$subfield_data{maxlength}."\"".
+ ($is_readonly ? "readonly=\"readonly\"" : "").
+ "\/>
<span class=\"subfield_controls\"><a href=\"#\" class=\"buttonDot\"
- onclick=\"openAuth(this.parentNode.parentNode.getElementsByTagName('input')[1].id,'".$tagslib->{$tag}->{$subfield}->{authtypecode}."'); return false;\" tabindex=\"1\" title=\"Tag Editor\"><img src=\"/intranet-tmpl/prog/img/edit-tag.png\" alt=\"Tag Editor\" /></a></span>
- ";
- } else {
- $subfield_data{marc_value} =
- "<input type=\"text\"
- id=\"".$subfield_data{id}."\"
- name=\"".$subfield_data{id}."\"
- value=\"$value\"
- class=\"input_marceditor readonly\"
- tabindex=\"1\"
- size=\"67\"
- maxlength=\"".$subfield_data{maxlength}."\"
- readonly=\"readonly\"
- \/><span class=\"subfield_controls\"><a href=\"#\" class=\"buttonDot\"
- onclick=\"openAuth(this.parentNode.parentNode.getElementsByTagName('input')[1].id,'".$tagslib->{$tag}->{$subfield}->{authtypecode}."'); return false;\" tabindex=\"1\" title=\"Tag Editor\"><img src=\"/intranet-tmpl/prog/img/edit-tag.png\" alt=\"Tag Editor\" /></a></span>
+ onclick=\"openAuth(this.parentNode.parentNode.getElementsByTagName('input')[1].id,'".$tagslib->{$tag}->{$subfield}->{authtypecode}."','biblio'); return false;\" tabindex=\"1\" title=\"Tag Editor\"><img src=\"/intranet-tmpl/prog/img/edit-tag.png\" alt=\"Tag Editor\" /></a></span>
";
- }
# it's a plugin field
}
elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) {
@@ -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);
@@ -50,7 +51,7 @@ function openAuth(tagsubfieldid,authtype) {
}
}
}
- 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) {
@@ -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<inputs.length;myindex++){
- if (inputs[myindex].name && inputs[myindex].name.match(tagsubfield)){
- 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?source=auth&authtypecode="+ authtype+ "&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes');
-}
-
function AddField(field,cntrepeatfield) {
document.forms['f'].op.value = "addfield";
document.forms['f'].addfield_field.value=field;

0 comments on commit 7cf5e2e

Please sign in to comment.