X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FPresenter%2FRequirementSpecItem.pm;h=58be1953d30e6da1ecaad56e2122e28874821d9a;hb=f3324b5ad66924333bf2a313974f6d4d21932707;hp=ed4f56762aa9e7111d83fd9e21534cc1496fd433;hpb=1f592a0f4f88893b5c2cb29b2d10e2d07b444ac0;p=kivitendo-erp.git diff --git a/SL/Presenter/RequirementSpecItem.pm b/SL/Presenter/RequirementSpecItem.pm index ed4f56762..58be1953d 100644 --- a/SL/Presenter/RequirementSpecItem.pm +++ b/SL/Presenter/RequirementSpecItem.pm @@ -2,31 +2,45 @@ package SL::Presenter::RequirementSpecItem; use strict; -use parent qw(Exporter); +use SL::Presenter::Text qw(truncate); use Exporter qw(import); -our @EXPORT = qw(requirement_spec_item_jstree_data requirement_spec_item_dependency_list); +our @EXPORT_OK = qw(requirement_spec_item_tree_node_title requirement_spec_item_jstree_data requirement_spec_item_dependency_list); use Carp; +sub requirement_spec_item_tree_node_title { + my ($item) = @_; + + return join(' ', map { $_ || '' } ($item->fb_number, truncate($item->parent_id ? $item->description_as_stripped_html : $item->title, at => 30))); +} + +sub tree_node_title { goto &requirement_spec_item_tree_node_title } + sub requirement_spec_item_jstree_data { - my ($self, $item, %params) = @_; + my ($item, %params) = @_; - my @children = map { $self->requirement_spec_item_jstree_data($_, %params) } @{ $item->sorted_children }; + my @children = map { requirement_spec_item_jstree_data($_, %params) } @{ $item->children_sorted }; my $type = !$item->parent_id ? 'section' : 'function-block'; + my $class = $type . '-context-menu tooltip'; + $class .= ' flagged' if $item->is_flagged; return { - data => join(' ', map { $_ || '' } ($item->fb_number, $item->title, '<' . $item->id . '>')), + data => requirement_spec_item_tree_node_title($item), metadata => { id => $item->id, type => $type }, - attr => { id => "fb-" . $item->id, href => $params{href} || '#', class => $type . '-context-menu' }, + attr => { id => "fb-" . $item->id, href => $params{href} || '#', class => $class, title => $item->content_excerpt }, children => \@children, }; } +sub jstree_data { goto &requirement_spec_item_jstree_data } + sub requirement_spec_item_dependency_list { - my ($self, $item) = @_; + my ($item) = @_; $::locale->language_join([ map { $_->fb_number } @{ $item->dependencies } ]); } +sub dependency_list { goto &requirement_spec_item_dependency_list } + 1;