1 package SL::Presenter::RequirementSpecItem;
5 use SL::Presenter::Text qw(truncate);
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);
12 sub requirement_spec_item_tree_node_title {
15 return join(' ', map { $_ || '' } ($item->fb_number, truncate($item->parent_id ? $item->description_as_stripped_html : $item->title, at => 30)));
18 sub tree_node_title { goto &requirement_spec_item_tree_node_title }
20 sub requirement_spec_item_jstree_data {
21 my ($item, %params) = @_;
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;
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,
36 sub jstree_data { goto &requirement_spec_item_jstree_data }
38 sub requirement_spec_item_dependency_list {
41 $::locale->language_join([ map { $_->fb_number } @{ $item->dependencies } ]);
44 sub dependency_list { goto &requirement_spec_item_dependency_list }