From f001cc32a3ce42262b37c6c22fe8ecbd0c32f966 Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Fri, 2 May 2014 18:38:20 -0300 Subject: [PATCH] Bug 11638: Remove HTML from addbiblio.pl This patch extracts variables with HTML from addbiblio.pl and an instance of CGI::scrolling_list As it changes how MARC editor show input fields, I prefer not add patches for other cases mentioned on Comment #1 To test: 1. Verify there are no regressions on MARC editor Add/Edit records, modify values 2. Update translation file for a language, check new string 'Tag editor' About the error message on error when deleting biblio, it must be localized but the script is not trying to use a template file, only prints a basic html and aborts. Perhaps a way of handling errors more gracefully is needed, but again it need to be solved on it's own bug. Updated test plan Signed-off-by: Chris Cormack Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- cataloguing/addbiblio.pl | 168 ++++++++---------- .../prog/en/modules/cataloguing/addbiblio.tt | 28 ++- 2 files changed, 105 insertions(+), 91 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 118bfc2db1..5b06706863 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -239,18 +239,15 @@ sub build_authorized_values_list { } } $authorised_values_sth->finish; - return CGI::scrolling_list( - -name => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield, - -values => \@authorised_values, - -default => $value, - -labels => \%authorised_lib, - -override => 1, - -size => 1, - -multiple => 0, - -tabindex => 1, - -id => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield, - -class => "input_marceditor", - ); + return { + type => 'select', + id => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield, + name => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield, + default => $value, + values => \@authorised_values, + labels => \%authorised_lib, + }; + } =head2 CreateKey @@ -366,37 +363,33 @@ sub create_input { defined($tagslib->{$tag}->{'a'}->{authtypecode}) and $tagslib->{$tag}->{'a'}->{authtypecode} ne '') { - $subfield_data{marc_value} = - ""; + $subfield_data{marc_value} = { + type => 'text', + id => $subfield_data{id}, + name => $subfield_data{id}, + value => $value, + size => 5, + maxlength => $subfield_data{maxlength}, + readonly => 1, + }; # it's a thesaurus / authority field } elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) { # when authorities auto-creation is allowed, do not set readonly my $is_readonly = !C4::Context->preference("BiblioAddsAuthorities"); - $subfield_data{marc_value} = - " - {$tag}->{$subfield}->{authtypecode}."','biblio'); return false;\" tabindex=\"1\" title=\"Tag editor\">Tag editor - "; + + $subfield_data{marc_value} = { + type => 'text', + id => $subfield_data{id}, + name => $subfield_data{id}, + value => $value, + size => 67, + maxlength => $subfield_data{maxlength}, + readonly => ($is_readonly) ? 1 : 0, + authtype => $tagslib->{$tag}->{$subfield}->{authtypecode}, + }; + # it's a plugin field } elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) { @@ -413,46 +406,44 @@ sub create_input { my $extended_param = plugin_parameters( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop ); my ( $function_name, $javascript ) = plugin_javascript( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop ); - $subfield_data{marc_value} = - " - Tag editor - $javascript"; + $subfield_data{marc_value} = { + type => 'text_complex', + id => $subfield_data{id}, + name => $subfield_data{id}, + value => $value, + size => 67, + maxlength => $subfield_data{maxlength}, + function_name => $function_name, + index_tag => $index_tag, + javascript => $javascript, + }; + } else { warn "Plugin Failed: $plugin"; # supply default input form - $subfield_data{marc_value} = - " - "; + $subfield_data{marc_value} = { + type => 'text', + id => $subfield_data{id}, + name => $subfield_data{id}, + value => $value, + size => 67, + maxlength => $subfield_data{maxlength}, + readonly => 0, + }; + } # it's an hidden field } elsif ( $tag eq '' ) { - $subfield_data{marc_value} = - " - "; + $subfield_data{marc_value} = { + type => 'hidden', + id => $subfield_data{id}, + name => $subfield_data{id}, + value => $value, + size => 67, + maxlength => $subfield_data{maxlength}, + }; + } else { # it's a standard field @@ -466,28 +457,25 @@ sub create_input { && C4::Context->preference("marcflavour") eq "MARC21" ) ) { - $subfield_data{marc_value} = - " - "; + $subfield_data{marc_value} = { + type => 'textarea', + id => $subfield_data{id}, + name => $subfield_data{id}, + value => $value, + }; + } else { - $subfield_data{marc_value} = - " - "; + $subfield_data{marc_value} = { + type => 'text', + id => $subfield_data{id}, + name => $subfield_data{id}, + value => $value, + size => 67, + maxlength => $subfield_data{maxlength}, + readonly => 0, + }; + } } $subfield_data{'index_subfield'} = $index_subfield; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index f446d6e744..5dc1a5ff3a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -610,7 +610,33 @@ function Changefwk(FwkList) { [% END %] - [% subfield_loo.marc_value %] + [% SET mv = subfield_loo.marc_value %] + [% IF ( mv.type == 'text' ) %] + [% IF ( mv.readonly == 1 ) %] + + [% ELSE %] + + [% END %] + [% IF ( mv.authtype ) %] + Tag editor + [% END %] + [% ELSIF ( mv.type == 'text_complex' ) %] + Tag editor[% mv.javascript %] + [% ELSIF ( mv.type == 'hidden' ) %] + + [% ELSIF ( mv.type == 'textarea' ) %] + + [% ELSIF ( mv.type == 'select' ) %] + + [% END %] [% IF ( subfield_loo.repeatable ) %] -- 2.39.5