X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FPresenter%2FRequirementSpec.pm;h=33746df76802412642c76d86e356f96302545d6a;hb=30b4a78c4100ebdcd6e6917fbcbf1d12f4f7b4d6;hp=fe9df960cea18c8b9f35ee54e68147994d5a3397;hpb=54daa586799871ce5ede8f628a03ea55a9660cf5;p=kivitendo-erp.git diff --git a/SL/Presenter/RequirementSpec.pm b/SL/Presenter/RequirementSpec.pm index fe9df960c..33746df76 100644 --- a/SL/Presenter/RequirementSpec.pm +++ b/SL/Presenter/RequirementSpec.pm @@ -2,38 +2,27 @@ package SL::Presenter::RequirementSpec; use strict; -use parent qw(Exporter); +use SL::Presenter::EscapedText qw(escape is_escaped); use Exporter qw(import); -our @EXPORT = qw(requirement_spec_text_block_jstree_data - requirement_spec_item_jstree_data); +our @EXPORT_OK = qw(requirement_spec); use Carp; -use SL::JSON; +sub requirement_spec { + my ($requirement_spec, %params) = @_; -sub requirement_spec_text_block_jstree_data { - my ($self, $text_block, %params) = @_; + $params{display} ||= 'inline'; - return { - data => $text_block->title || '', - metadata => { id => $text_block->id, type => 'textblock' }, - attr => { id => "tb-" . $text_block->id, href => $params{href} || '#' }, - }; -} - -sub requirement_spec_item_jstree_data { - my ($self, $item, %params) = @_; + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; - my @children = map { $self->requirement_spec_item_jstree_data($_, %params) } @{ $item->sorted_children }; - my $type = !$item->parent_id ? 'section' : 'functionblock'; + my $text = join '', ( + $params{no_link} ? '' : '', + escape($requirement_spec->id), + $params{no_link} ? '' : '', + ); - return { - data => join(' ', map { $_ || '' } ($item->fb_number, $item->title)), - metadata => { id => $item->id, type => $type }, - attr => { id => "fb-" . $item->id, href => $params{href} || '#' }, - children => \@children, - }; + is_escaped($text); } 1;