]> wagnertech.de Git - kivitendo-erp.git/blob - SL/Presenter/Part.pm
ajax_autocomplete umgestellt auf get_models und inline JSON (20% schneller als template)
[kivitendo-erp.git] / SL / Presenter / Part.pm
1 package SL::Presenter::Part;
2
3 use strict;
4
5 use Exporter qw(import);
6 our @EXPORT = qw(part_picker);
7
8 sub part_picker {
9   my ($self, $name, $value, %params) = @_;
10   my $name_e    = $self->escape($name);
11
12   my $ret =
13     $self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => 'part_autocomplete', type => 'hidden') .
14     $self->input_tag("", delete $params{type}, id => $self->name_to_id("$name_e\_type"), type => 'hidden') .
15     $self->input_tag("", (ref $value && $value->can('description')) ? $value->description : '', id => $self->name_to_id("$name_e\_name"), %params) .
16     $self->input_tag("", delete $params{column}, id => $self->name_to_id("$name_e\_column"), type => 'hidden');
17
18   $self->html_tag('span', $ret, class => 'part_picker');
19 }
20
21 1;
22
23 __END__
24
25 =encoding utf-8
26
27 =head1 NAME
28
29 SL::Presenter::Part - Part lelated presenter stuff
30
31 =head1 SYNOPSIS
32
33 see L<SL::Presenter>
34
35 =head1 DESCRIPTION
36
37 see L<SL::Presenter>
38
39 =head1 FUNCTIONS
40
41 =over 4
42
43 =item C<part_picker NAME, VALUE, PARAMS>
44
45 All-in-one picker widget for parts. The name will be both id and name of the
46 resulting hidden C<id> input field. An additional dummy input will be generated
47 which is used to find parts. For a detailed description of it's behaviour, see
48 section C<PART PICKER SPECIFICATION>.
49
50 C<VALUE> can be an id or C<Rose::DB:Object> instance.
51
52 If C<PARAMS> contains C<type> only parts of this type will be used for autocompletion.
53
54 Obsolete parts will by default not displayed for selection. However they are
55 accepted as default values and can persist during updates.
56
57 =back
58
59 =head1 BUGS
60
61 None yet :)
62
63 =head1 AUTHOR
64
65 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
66
67 =cut