X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FPlugin%2FL.pm;h=871e683bf19eda39e6cd76f131712d09c589bc73;hb=a3cf1d2381e1db5ab972e6f0c74ff157012b221a;hp=39b520e842b336967092c18b6c12b611729a3c48;hpb=dc7791df0d3e919e691fb3fd3d7ee20e3c5e7ca1;p=kivitendo-erp.git diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index 39b520e84..871e683bf 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -6,6 +6,8 @@ use List::MoreUtils qw(apply); use List::Util qw(max); use Scalar::Util qw(blessed); +use SL::Presenter; + use strict; { # This will give you an id for identifying html tags and such. @@ -111,6 +113,8 @@ sub select_tag { my $title_sub = delete($attributes{title_sub}); my $default_sub = delete($attributes{default_sub}); + my $with_empty = delete($attributes{with_empty}); + my $empty_title = delete($attributes{empty_title}); my %selected; @@ -128,8 +132,8 @@ sub select_tag { my @options; - if ( delete($attributes{with_empty}) ) { - push(@options, [undef, $attributes{empty_title} || '']); + if ( $with_empty ) { + push(@options, [undef, $empty_title || '']); } my $normalize_entry = sub { @@ -180,7 +184,7 @@ sub select_tag { my $title; if ( $value_title_sub ) { - ($value, $title) = $value_title_sub->($entry); + ($value, $title) = @{ $value_title_sub->($entry) }; } else { $value = $normalize_entry->('value', $entry, $value_sub, $value_key); @@ -279,7 +283,8 @@ sub input_tag { } sub hidden_tag { - return shift->input_tag(@_, type => 'hidden'); + my ($self, $name, $value, @slurp) = @_; + return $self->input_tag($name, $value, _hashify(@slurp), type => 'hidden'); } sub div_tag { @@ -394,34 +399,10 @@ sub customer_picker { my ($self, $name, $value, %params) = @_; my $name_e = _H($name); - $self->hidden_tag($name, (ref $value && $value->can('id')) ? $value->id : '') . - $self->input_tag("$name_e\_name", (ref $value && $value->can('name')) ? $value->name : '', %params) . - $self->javascript(<{layout}->add_javascripts('autocomplete_customer.js'); + + $self->hidden_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => 'customer_autocomplete') . + $self->input_tag("$name_e\_name", (ref $value && $value->can('name')) ? $value->name : '', %params); } # simple version with select_tag @@ -484,27 +465,15 @@ sub tabbed { next if $tab eq ''; - my $selected = $params{selected} == $i; - my $tab_id = "__tab_id_$i"; - push @header, $self->li_tag( - $self->link('', $tab->{name}, rel => $tab_id), - ($selected ? (class => 'selected') : ()) - ); - push @blocks, $self->div_tag($tab->{data}, - id => $tab_id, class => 'tabcontent'); + my $tab_id = "__tab_id_$i"; + push @header, $self->li_tag($self->link('#' . $tab_id, $tab->{name})); + push @blocks, $self->div_tag($tab->{data}, id => $tab_id); } return '' unless @header; - return $self->ul_tag( - join('', @header), id => $id, class => 'shadetabs' - ) . - $self->div_tag( - join('', @blocks), class => 'tabcontentstyle' - ) . - $self->javascript( - qq|var $id = new ddtabcontent("$id");$id.setpersist(true);| . - qq|$id.setselectedClassTarget("link");$id.init();| - ); + + my $ul = $self->ul_tag(join('', @header), id => $id); + return $self->div_tag(join('', $ul, @blocks), class => 'tabwidget'); } sub tab { @@ -665,7 +634,7 @@ sub sortable_table_header { my $by_spec = $sort_spec->{$by}; my %current_sort_params = $controller->get_current_sort_params; my ($image, $new_dir) = ('', $current_sort_params{dir}); - my $title = delete($params{title}) || $by_spec->{title}; + my $title = delete($params{title}) || $::locale->text($by_spec->{title}); if ($current_sort_params{by} eq $by) { my $current_dir = $current_sort_params{dir} ? 'up' : 'down'; @@ -687,11 +656,7 @@ sub paginate_controls { my %paginate_params = $controller->get_current_paginate_params; my %template_params = ( - pages => { - cur => $paginate_params{page}, - max => $paginate_params{num_pages}, - common => $paginate_params{common_pages}, - }, + pages => \%paginate_params, url_maker => sub { my %url_params = _hashify(@_); $url_params{ $paginate_spec->{FORM_PARAMS}->[0] } = delete $url_params{page}; @@ -701,9 +666,7 @@ sub paginate_controls { }, ); - my $output; - $controller->_template_obj->process('templates/webpages/common/paginate.html', \%template_params, \$output); - return $output; + return SL::Presenter->get->render('common/paginate', %template_params); } 1; @@ -916,9 +879,6 @@ C. Example: L.tab(LxERP.t8('Custom Variables'), 'part/_cvar_tab.html', if => SELF.display_cvar_tab), ]) %] -An optional attribute is C, which accepts the ordinal of a tab which -should be selected by default. - =item C Creates a generic input tag or textarea tag, depending on content size. The