1 package SL::Presenter::RequirementSpec;
5 use parent qw(Exporter);
7 use Exporter qw(import);
8 our @EXPORT = qw(requirement_spec_text_block_jstree_data
9 requirement_spec_item_jstree_data);
15 sub requirement_spec_text_block_jstree_data {
16 my ($self, $text_block, %params) = @_;
19 data => $text_block->title || '',
20 metadata => { id => $text_block->id, type => 'textblock' },
21 attr => { id => "tb-" . $text_block->id, href => $params{href} || '#' },
25 sub requirement_spec_item_jstree_data {
26 my ($self, $item, %params) = @_;
28 my @children = map { $self->requirement_spec_item_jstree_data($_, %params) } @{ $item->sorted_children };
29 my $type = !$item->parent_id ? 'section' : 'functionblock';
32 data => join(' ', map { $_ || '' } ($item->fb_number, $item->title)),
33 metadata => { id => $item->id, type => $type },
34 attr => { id => "fb-" . $item->id, href => $params{href} || '#' },
35 children => \@children,