From: G. Richardson Date: Wed, 13 Nov 2013 12:25:14 +0000 (+0100) Subject: Presenter für Part hinzugefügt X-Git-Tag: release-3.1.0beta1~22^2~164 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f33995ff79013afbf0543453a73dd745354b129a;p=kivitendo-erp.git Presenter für Part hinzugefügt Presenter Code um HTML Links für Artikel, Dienstleistungen und Erzeugnisse zu erstellen. --- 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