From e33a016a1c56682e984d763653c0aacd6645c037 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 17 Mar 2014 12:36:55 +0100 Subject: [PATCH] Bug 766: Use a TT include instead of a method in the AV plugin Signed-off-by: Bernardo Gonzalez Kriegel This gives a koha-qa error, but on another user/env not. Really don't know Signed-off-by: Katrin Fischer I see the same error, but can't see where this is coming from, code seems to work ok. Works as described, no regressions found. Signed-off-by: Katrin Fischer Signed-off-by: Galen Charlton --- Koha/Template/Plugin/AuthorisedValues.pm | 26 ++--------------- .../prog/en/includes/av-build-dropbox.inc | 29 +++++++++++++++++++ .../prog/en/modules/members/memberentrygen.tt | 5 ++-- 3 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 3013706639..b60819d94f 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -44,34 +44,14 @@ sub GetByCode { return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) ); } - sub Get { my ( $self, $category, $selected, $opac ) = @_; return GetAuthorisedValues( $category, $selected, $opac ); } -sub BuildDropbox { - my ( $self, $name, $category, $default, $params ) = @_; - my $class = $params->{class}; - my $avs = C4::Koha::GetAuthvalueDropbox($category, $default); - my $size = $params->{size} || 20; - my $html; - if ( @$avs ) { - $html = qq||; - } else { - $html .= qq||; - - } - - return encode( 'UTF-8', $html ); +sub GetAuthValueDropbox { + my ( $self, $category, $default ) = @_; + return C4::Koha::GetAuthvalueDropbox($category, $default); } 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc new file mode 100644 index 0000000000..5002842478 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc @@ -0,0 +1,29 @@ +[% USE AuthorisedValues %] +[%# + Parameters: + name: tthe name of the select element + category: the authorised value category + default: the default authorised value to select + class: the css class of the select element + size: the size to use for the input (generated if not authorised value category exist). +%] + +[% SET avs = AuthorisedValues.GetAuthValueDropbox( category, default ) %] +[% DEFAULT + class = '' + size = 20 +%] + +[% IF avs %] + +[% ELSE %] + +[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index c4d0c6a114..430543e618 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1,4 +1,3 @@ -[% USE AuthorisedValues %] [% IF ( opduplicate ) %][% SET focusAction = "clearDupe" %][% END %] [% USE KohaDates %] [% INCLUDE 'doc-head-open.inc' %] @@ -959,7 +958,7 @@ - [% AuthorisedValues.BuildDropbox("sort1", "Bsort1", sort1, { class => focusAction, size => 20 } ) %] + [% PROCESS 'av-build-dropbox.inc' name="sort1", category="Bsort1", default=sort1, class=focusAction, size = 20 %] [% IF ( mandatorysort1 ) %]Required[% END %] [% END %] @@ -971,7 +970,7 @@ - [% AuthorisedValues.BuildDropbox("sort2", "Bsort2", sort2, { class => focusAction, size => 20 } ) %] + [% PROCESS 'av-build-dropbox.inc' name="sort2", category="Bsort2", default=sort2, class=focusAction, size = 20 %] [% IF ( mandatorysort2 ) %]Required[% END %] [% END %] -- 2.39.5