BankTransaction: vergessene Textübersetzung bei Buchung erstellen
[kivitendo-erp.git] / SL / Presenter / RequirementSpecItem.pm
1 package SL::Presenter::RequirementSpecItem;
2
3 use strict;
4
5 use SL::Presenter::Text qw(truncate);
6
7 use Exporter qw(import);
8 our @EXPORT_OK = qw(requirement_spec_item_tree_node_title requirement_spec_item_jstree_data requirement_spec_item_dependency_list);
9
10 use Carp;
11
12 sub requirement_spec_item_tree_node_title {
13   my ($item) = @_;
14
15   return join(' ', map { $_ || '' } ($item->fb_number, truncate($item->parent_id ? $item->description_as_stripped_html : $item->title, at => 30)));
16 }
17
18 sub tree_node_title { goto &requirement_spec_item_tree_node_title }
19
20 sub requirement_spec_item_jstree_data {
21   my ($item, %params) = @_;
22
23   my @children = map { requirement_spec_item_jstree_data($_, %params) } @{ $item->children_sorted };
24   my $type     = !$item->parent_id ? 'section' : 'function-block';
25   my $class    = $type . '-context-menu tooltip';
26   $class      .= ' flagged' if $item->is_flagged;
27
28   return {
29     data     => requirement_spec_item_tree_node_title($item),
30     metadata => { id =>         $item->id, type => $type },
31     attr     => { id => "fb-" . $item->id, href => $params{href} || '#', class => $class, title => $item->content_excerpt },
32     children => \@children,
33   };
34 }
35
36 sub jstree_data { goto &requirement_spec_item_jstree_data }
37
38 sub requirement_spec_item_dependency_list {
39   my ($item) = @_;
40
41   $::locale->language_join([ map { $_->fb_number } @{ $item->dependencies } ]);
42 }
43
44 sub dependency_list { goto &requirement_spec_item_dependency_list }
45
46 1;