From f33995ff79013afbf0543453a73dd745354b129a Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Wed, 13 Nov 2013 13:25:14 +0100 Subject: [PATCH] =?utf8?q?Presenter=20f=C3=BCr=20Part=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Presenter Code um HTML Links für Artikel, Dienstleistungen und Erzeugnisse zu erstellen. --- SL/Presenter/Part.pm | 48 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/SL/Presenter/Part.pm b/SL/Presenter/Part.pm index 4b7b15d3d..daa7d7310 100644 --- a/SL/Presenter/Part.pm +++ b/SL/Presenter/Part.pm @@ -5,7 +5,24 @@ use strict; use SL::DB::Part; use Exporter qw(import); -our @EXPORT = qw(part_picker); +our @EXPORT = qw(part_picker part); + +use Carp; + +sub part { + my ($self, $part, %params) = @_; + + $params{display} ||= 'inline'; + + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; + + my $text = join '', ( + $params{no_link} ? '' : '', + $self->escape($part->partnumber), + $params{no_link} ? '' : '', + ); + return $self->escaped_text($text); +} sub part_picker { my ($self, $name, $value, %params) = @_; @@ -31,11 +48,15 @@ __END__ =head1 NAME -SL::Presenter::Part - Part lelated presenter stuff +SL::Presenter::Part - Part related presenter stuff =head1 SYNOPSIS -see L + # Create an html link for editing/opening a part/service/assembly + my $object = my $object = SL::DB::Manager::Part->get_first; + my $html = SL::Presenter->get->part($object, display => 'inline'); + +see also L =head1 DESCRIPTION @@ -43,8 +64,29 @@ see L =head1 FUNCTIONS +=over 2 + +=item C + +Returns a rendered version (actually an instance of +L) of the part object C<$object> + +C<%params> can include: + =over 4 +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the part's name linked +to the corresponding 'edit' action. + +=back + +=back + +=over 2 + =item C All-in-one picker widget for parts. The name will be both id and name -- 2.20.1