From 51db9340638af99ab7f9159540006e877aadb878 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Sun, 27 Apr 2014 00:19:09 -0400 Subject: [PATCH] Bug 12091 - Rebased, but untested still. This cleans up the HTML in auth_subfields_structure.pl by: - removing some more CGI::scrolling_lists. - fixing some attributes - removing some attributes - and using a handy-dandy validation plug-in that Owen pointed me at the other day. --- admin/auth_subfields_structure.pl | 152 +++++++------------- .../en/modules/admin/auth_subfields_structure.tt | 77 +++++++--- 2 files changed, 112 insertions(+), 117 deletions(-) diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl index 321e54c..68961db 100755 --- a/admin/auth_subfields_structure.pl +++ b/admin/auth_subfields_structure.pl @@ -23,6 +23,7 @@ use C4::Output; use C4::Auth; use CGI; use C4::Context; +use C4::Koha; sub string_search { @@ -91,25 +92,14 @@ if ($op eq 'add_form') { push @kohafields, "auth_header.".$field; } - # build authorised value list - $sth2 = $dbh->prepare("select distinct category from authorised_values"); - $sth2->execute; - my @authorised_values; - push @authorised_values,""; - while ((my $category) = $sth2->fetchrow_array) { - push @authorised_values, $category; - } - push (@authorised_values,"branches"); - push (@authorised_values,"itemtypes"); + # build authorised value list + my $authorised_values = C4::Koha::GetAuthorisedValueCategories; + unshift @$authorised_values,""; + push (@$authorised_values,"branches"); + push (@$authorised_values,"itemtypes"); # build thesaurus categories list - $sth2 = $dbh->prepare("select authtypecode from auth_types"); - $sth2->execute; - my @authtypes; - push @authtypes, ""; - while ( ( my $authtypecode ) = $sth2->fetchrow_array ) { - push @authtypes, $authtypecode; - } + my $authtypes = getauthtypes; # build value_builder list my @value_builder=(''); @@ -180,53 +170,37 @@ if ($op eq 'add_form') { -size=>1, -multiple=>0, ); - $row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value', - -id=>"authorised_value$i", - -values=> \@authorised_values, - -default=>$data->{'authorised_value'}, - -size=>1, - -tabindex=>'', - -multiple=>0, - ); - $row_data{frameworkcode} = CGI::scrolling_list(-name=>'frameworkcode', - -id=>"frameworkcode$i", - -values=> \@authtypes, - -default=>$data->{'frameworkcode'}, - -size=>1, - -tabindex=>'', - -multiple=>0, - ); - $row_data{value_builder} = CGI::scrolling_list(-name=>'value_builder', - -id=>"value_builder$i", - -values=> \@value_builder, - -default=>$data->{'value_builder'}, - -size=>1, - -tabindex=>'', - -multiple=>0, - ); - - $row_data{repeatable} = CGI::checkbox(-name=>"repeatable$i", - -checked => $data->{'repeatable'}?'checked':'', - -value => 1, - -label => '', - -id => "repeatable$i"); - $row_data{mandatory} = CGI::checkbox(-name => "mandatory$i", - -checked => $data->{'mandatory'}?'checked':'', - -value => 1, - -label => '', - -id => "mandatory$i"); + $row_data{authorised_value} = { + id => "authorised_value$i", + codes => $authorised_values, + default => $data->{'authorised_value'}, + }; + $row_data{frameworkcode} = { + id => "frameworkcode$i", + codes => $authtypes, + default => $data->{'frameworkcode'}, + }; + $row_data{value_builder} = { + id => "value_builder$i", + codes => \@value_builder, + default => $data->{'value_builder'}, + }; + $row_data{repeatable} = "{'repeatable'} ? 'checked="checked" ' : '') . + "name=\"repeatable$i\">"; + $row_data{mandatory} = "{'mandatory'} ? 'checked="checked" ' : '' ) . + "name=\"mandatory$i\">"; $row_data{hidden} = CGI::escapeHTML($data->{hidden}) ; - $row_data{isurl} = CGI::checkbox( -name => "isurl$i", - -id => "isurl$i", - -checked => $data->{'isurl'}?'checked':'', - -value => 1, - -label => ''); + $row_data{isurl} = "{'isurl'} ? 'checked="checked" ' : '' ) . + "name=\"isurl$i\">"; $row_data{row} = $i; push(@loop_data, \%row_data); $i++; } # add more_subfields empty lines for add if needed - for (my $i=1;$i<=$more_subfields;$i++) { + for (my $j=1;$j<=$more_subfields;$j++) { my %row_data; # get a fresh hash for the row data $row_data{'new_subfield'} = 1; $row_data{tab} = CGI::scrolling_list(-name=>'tab', @@ -248,7 +222,6 @@ if ($op eq 'add_form') { }, -default=>"", -size=>1, - -tabindex=>'', -multiple=>0, ); $row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden', @@ -287,30 +260,14 @@ if ($op eq 'add_form') { # -multiple=>0, # ); $row_data{tagsubfieldinput} = "{'tagsubfield'}."\" size=\"1\" id=\"tagsubfield\" maxlength=\"1\" />"; - $row_data{tagsubfieldinput} = - ""; $row_data{tagsubfield} = $data->{'tagsubfield'}; $row_data{liblibrarian} = ""; $row_data{libopac} = ""; $row_data{seealso} = ""; $row_data{hidden} = "000"; - $row_data{repeatable} = CGI::checkbox( -name=> 'repeatable', - -id => "repeatable$i", - -checked => '', - -value => 1, - -label => ''); - $row_data{mandatory} = CGI::checkbox( -name=> 'mandatory', - -id => "mandatory$i", - -checked => '', - -value => 1, - -label => ''); - $row_data{isurl} = CGI::checkbox(-name => 'isurl', - -id => "isurl$i", - -checked => '', - -value => 1, - -label => ''); + $row_data{repeatable} = ""; + $row_data{mandatory} = ""; + $row_data{isurl} = ""; $row_data{kohafield}= CGI::scrolling_list( -name=>'kohafield', -id => "kohafield$i", -values=> \@kohafields, @@ -318,30 +275,23 @@ if ($op eq 'add_form') { -size=>1, -multiple=>0, ); - $row_data{frameworkcode} = CGI::scrolling_list(-name=>'frameworkcode', - -id=>'frameworkcode', - -values=> \@authtypes, - -default=>$data->{'frameworkcode'}, - -size=>1, - -tabindex=>'', - -multiple=>0, - ); - $row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value', - -id => 'authorised_value', - -values=> \@authorised_values, - -size=>1, - -tabindex=>'', - -multiple=>0, - ); - $row_data{value_builder} = CGI::scrolling_list(-name=>'value_builder', - -id=>'value_builder', - -values=> \@value_builder, - -default=>$data->{'value_builder'}, - -size=>1, - -tabindex=>'', - -multiple=>0, - ); + $row_data{frameworkcode} = { + id => 'frameworkcode', + codes => $authtypes, + default => $data->{'frameworkcode'}, + }; + $row_data{authorised_value} = { + id => 'authorised_value', + codes => $authorised_values, + default => $data->{'authorised_values'}, + }; + $row_data{value_builder} = { + id => 'value_builder', + codes => \@value_builder, + default => $data->{'value_builder'}, + }; $row_data{row} = $i; + ++$i; push(@loop_data, \%row_data); } $template->param('use_heading_flags_p' => 1); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt index 94d53bf..7c31113 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt @@ -76,20 +76,17 @@ function displayMoreConstraint(numlayer){ [% FOREACH loo IN loop %]
    - - [% IF ( loo.new_subfield ) %] -
  1. [% loo.tagsubfieldinput %] 
  2. - [% ELSE %] -
  3. - -
  4. - [% END %] + [% IF ( loo.new_subfield ) %] +
  5. [% loo.tagsubfieldinput %] 
  6. + [% ELSE %] +
  7. + [% END %]
  8. [% loo.repeatable %] 
  9. [% loo.mandatory %] 
  10. -
  11. -
  12. +
  13. +
  14. - [%- IF ( loo.tab.default == -1 ) -%] [%- ELSE -%] @@ -110,7 +107,7 @@ function displayMoreConstraint(numlayer){ Display
    1. - [%- IF ( loo.ohidden.default == 0 ) -%] @@ -135,7 +132,7 @@ function displayMoreConstraint(numlayer){
    2. [% loo.isurl %] (if checked, it means that the subfield is a URL and can be clicked)
    3. - +
@@ -143,9 +140,57 @@ function displayMoreConstraint(numlayer){
  • Help input
      -
    1. [% loo.authorised_value %]
    2. -
    3. [% loo.frameworkcode %]
    4. -
    5. [% loo.value_builder %]
    6. +
    7. + + +
    8. +
    9. + + +
    10. +
    11. + + +
  • -- 1.7.9.5