From 4ad234198fff37e69137529a6eafbfd647fd6898 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 2 Jan 2018 13:22:03 +0100 Subject: [PATCH] Presenter::CustomerVendor: interface normalisiert MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit es gibt jetzt zusätzlich: - customer_picker - vendor_picker die auf den jeweiligen typ gecrurried sind --- SL/Presenter/CustomerVendor.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SL/Presenter/CustomerVendor.pm b/SL/Presenter/CustomerVendor.pm index 80b85f9e3..4a563e46c 100644 --- a/SL/Presenter/CustomerVendor.pm +++ b/SL/Presenter/CustomerVendor.pm @@ -6,7 +6,7 @@ use SL::Presenter::EscapedText qw(escape is_escaped); use SL::Presenter::Tag qw(input_tag html_tag name_to_id select_tag); use Exporter qw(import); -our @EXPORT_OK = qw(customer_vendor customer vendor customer_vendor_picker); +our @EXPORT_OK = qw(customer_vendor customer vendor customer_vendor_picker customer_picker vendor_picker); use Carp; @@ -46,6 +46,9 @@ sub _customer_vendor { sub customer_vendor_picker { my ($name, $value, %params) = @_; + $params{type} //= 'customer' if 'SL::DB::Customer' eq ref $value; + $params{type} //= 'vendor' if 'SL::DB::Vendor' eq ref $value; + croak 'Unknown "type" parameter' unless $params{type} =~ m{^(?:customer|vendor)$}; croak 'Unknown value class' if $value && ref($value) && (ref($value) !~ m{^SL::DB::(?:Customer|Vendor)$}); @@ -71,7 +74,9 @@ sub customer_vendor_picker { html_tag('span', $ret, class => 'customer_vendor_picker'); } -sub picker { goto &customer_vendor_picker } +sub customer_picker { my ($name, $value, @slurp) = @_; customer_vendor_picker($name, $value, @slurp, type => 'customer') } +sub vendor_picker { my ($name, $value, @slurp) = @_; customer_vendor_picker($name, $value, @slurp, type => 'vendor') } +sub picker { goto &customer_vendor_picker } 1; -- 2.20.1