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_as_stripped_html : $item->title, at => 30)));
 
  18 sub requirement_spec_item_jstree_data {
 
  19   my ($self, $item, %params) = @_;
 
  21   my @children = map { $self->requirement_spec_item_jstree_data($_, %params) } @{ $item->children_sorted };
 
  22   my $type     = !$item->parent_id ? 'section' : 'function-block';
 
  23   my $class    = $type . '-context-menu tooltip';
 
  24   $class      .= ' flagged' if $item->is_flagged;
 
  27     data     => $self->requirement_spec_item_tree_node_title($item),
 
  28     metadata => { id =>         $item->id, type => $type },
 
  29     attr     => { id => "fb-" . $item->id, href => $params{href} || '#', class => $class, title => $item->content_excerpt },
 
  30     children => \@children,
 
  34 sub requirement_spec_item_dependency_list {
 
  35   my ($self, $item) = @_;
 
  37   $::locale->language_join([ map { $_->fb_number } @{ $item->dependencies } ]);