1 package SL::Presenter::Project;
5 use parent qw(Exporter);
7 use Exporter qw(import);
8 our @EXPORT = qw(project project_picker);
13 my ($self, $project, %params) = @_;
15 return '' unless $project;
17 $params{display} ||= 'inline';
19 croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
21 my $description = $project->full_description(style => $params{style});
22 my $callback = $params{callback} ? '&callback=' . $::form->escape($params{callback}) : '';
25 $params{no_link} ? '' : '<a href="controller.pl?action=Project/edit&id=' . $self->escape($project->id) . $callback . '">',
26 $self->escape($description),
27 $params{no_link} ? '' : '</a>',
29 return $self->escaped_text($text);
33 my ($self, $name, $value, %params) = @_;
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';
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);
45 $::request->layout->add_javascripts('autocomplete_project.js');
46 $::request->presenter->need_reinit_widgets($id);
48 $self->html_tag('span', $ret, class => 'project_picker');
61 SL::Presenter::Project - Presenter module for project Rose::DB objects
65 my $project = SL::DB::Manager::Project->get_first;
66 my $html = SL::Presenter->get->project($project, display => 'inline');
72 =item C<project $object, %params>
74 Returns a rendered version (actually an instance of
75 L<SL::Presenter::EscapedText>) of the project object C<$customer>.
77 C<%params> can include:
83 Either C<inline> (the default) or C<table-cell>. At the moment both
84 representations are identical and produce the project's description
85 (controlled by the C<style> parameter) linked to the corresponding
90 Determines what exactly will be output. Can be one of the values with
91 C<both> being the default if it is missing:
95 =item C<projectnumber> (or simply C<number>)
97 Outputs only the project's number.
99 =item C<projectdescription> (or simply C<description>)
101 Outputs only the project's description.
105 Outputs the project's number followed by its description in
106 parenthesis (e.g. "12345 (Secret Combinations)"). If the project's
107 description is already part of the project's number then it will not
114 If falsish (the default) then the project's description will be linked to
115 the "edit project" dialog from the master data menu.
127 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>