Revision fac8417d
Von Moritz Bunkus vor mehr als 9 Jahren hinzugefügt
SL/Presenter/Project.pm | ||
---|---|---|
5 | 5 |
use parent qw(Exporter); |
6 | 6 |
|
7 | 7 |
use Exporter qw(import); |
8 |
our @EXPORT = qw(project); |
|
8 |
our @EXPORT = qw(project project_picker);
|
|
9 | 9 |
|
10 | 10 |
use Carp; |
11 | 11 |
|
... | ... | |
29 | 29 |
return $self->escaped_text($text); |
30 | 30 |
} |
31 | 31 |
|
32 |
sub project_picker { |
|
33 |
my ($self, $name, $value, %params) = @_; |
|
34 |
|
|
35 |
$value = SL::DB::Manager::Project->find_by(id => $value) if $value && !ref $value; |
|
36 |
my $id = delete($params{id}) || $self->name_to_id($name); |
|
37 |
my @classes = $params{class} ? ($params{class}) : (); |
|
38 |
push @classes, 'project_autocomplete'; |
|
39 |
|
|
40 |
my $ret = |
|
41 |
$self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) . |
|
42 |
join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(customer_id)) . |
|
43 |
$self->input_tag("", ref $value ? $value->displayable_name : '', id => "${id}_name", %params); |
|
44 |
|
|
45 |
$::request->layout->add_javascripts('autocomplete_project.js'); |
|
46 |
$::request->presenter->need_reinit_widgets($id); |
|
47 |
|
|
48 |
$self->html_tag('span', $ret, class => 'project_picker'); |
|
49 |
} |
|
50 |
|
|
32 | 51 |
1; |
33 | 52 |
|
34 | 53 |
__END__ |
Auch abrufbar als: Unified diff
Project-Picker basierend auf Part-Picker