cdf05cf3611dbe16e7a516873c9232e68f53dc11
[kivitendo-erp.git] / SL / Presenter / RequirementSpecItem.pm
1 package SL::Presenter::RequirementSpecItem;
2
3 use strict;
4
5 use parent qw(Exporter);
6
7 use Exporter qw(import);
8 our @EXPORT = qw(requirement_spec_item_jstree_data requirement_spec_item_dependency_list);
9
10 use Carp;
11
12 sub requirement_spec_item_jstree_data {
13   my ($self, $item, %params) = @_;
14
15   my @children = map { $self->requirement_spec_item_jstree_data($_, %params) } @{ $item->sorted_children };
16   my $type     = !$item->parent_id ? 'section' : 'functionblock';
17
18   return {
19     data     => join(' ', map { $_ || '' } ($item->fb_number, $item->title)),
20     metadata => { id =>         $item->id, type => $type },
21     attr     => { id => "fb-" . $item->id, href => $params{href} || '#' },
22     children => \@children,
23   };
24 }
25
26 sub requirement_spec_item_dependency_list {
27   my ($self, $item) = @_;
28
29   $::locale->language_join([ map { $_->fb_number } @{ $item->dependencies } ]);
30 }
31
32 1;