From: Sven Schöling Date: Wed, 27 Dec 2017 11:08:54 +0000 (+0100) Subject: Presenter::Tag: date_tag aus Plugin/L verschoben X-Git-Tag: release-3.5.4~543 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5dbd60bfea0c2ca1b3856bddd8dd388acf5aa237;p=kivitendo-erp.git Presenter::Tag: date_tag aus Plugin/L verschoben --- diff --git a/SL/Presenter/Tag.pm b/SL/Presenter/Tag.pm index e5d8d27da..696ec561e 100644 --- a/SL/Presenter/Tag.pm +++ b/SL/Presenter/Tag.pm @@ -4,12 +4,13 @@ use strict; use SL::HTML::Restrict; use SL::Presenter::EscapedText qw(escape); +use Scalar::Util qw(blessed); use Exporter qw(import); our @EXPORT_OK = qw( html_tag input_tag hidden_tag javascript man_days_tag name_to_id select_tag checkbox_tag button_tag submit_tag ajax_submit_tag input_number_tag - stringify_attributes restricted_html textarea_tag link + stringify_attributes restricted_html textarea_tag link date_tag ); our %EXPORT_TAGS = (ALL => \@EXPORT_OK); @@ -330,6 +331,27 @@ sub link { html_tag('a', $content, %params, href => $href); } +sub date_tag { + my ($name, $value, %params) = @_; + + _set_id_attribute(\%params, $name); + my @onchange = $params{onchange} ? (onChange => delete $params{onchange}) : (); + my @classes = $params{no_cal} || $params{readonly} ? () : ('datepicker'); + push @classes, delete($params{class}) if $params{class}; + my %class = @classes ? (class => join(' ', @classes)) : (); + + $::request->layout->add_javascripts('kivi.Validator.js'); + $::request->presenter->need_reinit_widgets($params{id}); + + input_tag( + $name, blessed($value) ? $value->to_lxoffice : $value, + size => 11, + "data-validate" => "date", + %params, + %class, @onchange, + ); +} + 1; __END__ diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index f24ded25a..7403ae4dc 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -81,6 +81,7 @@ sub ajax_submit_tag { return _call_presenter('ajax_submit_tag', sub link { return _call_presenter('link', @_); } sub input_number_tag { return _call_presenter('input_number_tag', @_); } sub textarea_tag { return _call_presenter('textarea_tag', @_); } +sub date_tag { return _call_presenter('date_tag', @_); } sub _set_id_attribute { my ($attributes, $name, $unique) = @_; @@ -152,27 +153,6 @@ sub stylesheet_tag { return $code; } -my $date_tag_id_idx = 0; -sub date_tag { - my ($self, $name, $value, %params) = _hashify(3, @_); - - _set_id_attribute(\%params, $name); - my @onchange = $params{onchange} ? (onChange => delete $params{onchange}) : (); - my @classes = $params{no_cal} || $params{readonly} ? () : ('datepicker'); - push @classes, delete($params{class}) if $params{class}; - my %class = @classes ? (class => join(' ', @classes)) : (); - - $::request->layout->add_javascripts('kivi.Validator.js'); - $::request->presenter->need_reinit_widgets($params{id}); - - return $self->input_tag( - $name, blessed($value) ? $value->to_lxoffice : $value, - size => 11, - "data-validate" => "date", - %params, - %class, @onchange, - ); -} # simple version with select_tag sub vendor_selector {