1 package SL::Presenter::RequirementSpecItem;
5 use parent qw(Exporter);
7 use Exporter qw(import);
8 our @EXPORT = qw(requirement_spec_item_tree_node_title requirement_spec_item_jstree_data requirement_spec_item_dependency_list);
12 sub requirement_spec_item_tree_node_title {
13 my ($self, $item) = @_;
15 return join(' ', map { $_ || '' } ($item->fb_number, $self->truncate($item->parent_id ? $item->description : $item->title, at => 30), '<' . $item->id . '>'));
18 sub requirement_spec_item_jstree_data {
19 my ($self, $item, %params) = @_;
21 my @children = map { $self->requirement_spec_item_jstree_data($_, %params) } @{ $item->sorted_children };
22 my $type = !$item->parent_id ? 'section' : 'function-block';
25 data => $self->requirement_spec_item_tree_node_title($item),
26 metadata => { id => $item->id, type => $type },
27 attr => { id => "fb-" . $item->id, href => $params{href} || '#', class => $type . '-context-menu' },
28 children => \@children,
32 sub requirement_spec_item_dependency_list {
33 my ($self, $item) = @_;
35 $::locale->language_join([ map { $_->fb_number } @{ $item->dependencies } ]);