From 786437b68e64cc7c8496792b2a34717f60ca3a22 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 16 Aug 2013 13:17:24 +0200 Subject: [PATCH] =?utf8?q?Pflichtenheftitems=20&=20-textbl=C3=B6cke:=20Too?= =?utf8?q?ltips=20im=20Baum=20mit=20Inhaltsauszug=20anzeigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/RequirementSpecItem.pm | 4 ++++ SL/Controller/RequirementSpecTextBlock.pm | 2 ++ SL/DB/RequirementSpecItem.pm | 8 ++++++++ SL/DB/RequirementSpecTextBlock.pm | 7 +++++++ SL/Presenter/RequirementSpecItem.pm | 4 ++-- SL/Presenter/RequirementSpecTextBlock.pm | 4 ++-- js/kivi.js | 4 ++++ templates/webpages/requirement_spec/show.html | 12 ++++++++---- 8 files changed, 37 insertions(+), 8 deletions(-) diff --git a/SL/Controller/RequirementSpecItem.pm b/SL/Controller/RequirementSpecItem.pm index 490f28451..d6b343f0e 100644 --- a/SL/Controller/RequirementSpecItem.pm +++ b/SL/Controller/RequirementSpecItem.pm @@ -197,6 +197,7 @@ sub action_ajax_create { ->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#sections', 'last'), $node) ->jstree->select_node('#tree', '#fb-' . $self->item->id); return $self->add_new_item_form_after_create + ->reinit_widgets ->render($self); } @@ -208,6 +209,7 @@ sub action_ajax_create { ->replaceWith('#' . $prefix . '_form', $html) ->hide('#section-list-empty') ->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#fb-' . $self->item->parent_id, 'last'), $node) + ->reinit_widgets ->jstree->select_node('#tree', '#fb-' . $self->item->id); $self->replace_bottom($self->item->parent) if $type eq 'sub-function-block'; @@ -293,6 +295,7 @@ sub action_ajax_update { ->html('#section-header-' . $self->item->id, $html) ->show('#section-header-' . $self->item->id) ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $::request->presenter->requirement_spec_item_tree_node_title($self->item)) + ->prop('#fb-' . $self->item->id, 'title', $self->item->content_excerpt) ->render($self); } @@ -307,6 +310,7 @@ sub action_ajax_update { $self->js ->remove('#' . $prefix . '_form') ->replaceWith('#' . $id_prefix . 'top-' . $self->item->id, $html_top) + ->prop('#fb-' . $self->item->id, 'title', $self->item->content_excerpt) ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $::request->presenter->requirement_spec_item_tree_node_title($self->item)); $self->replace_bottom($self->item, id_prefix => $id_prefix); diff --git a/SL/Controller/RequirementSpecTextBlock.pm b/SL/Controller/RequirementSpecTextBlock.pm index dc3d281c8..9f70e1bab 100644 --- a/SL/Controller/RequirementSpecTextBlock.pm +++ b/SL/Controller/RequirementSpecTextBlock.pm @@ -110,6 +110,7 @@ sub action_ajax_create { ->jstree->create_node('#tree', $insert_after ? ('#tb-' . $insert_after, 'after') : ('#tb-' . ($attributes->{output_position} == 0 ? 'front' : 'back'), 'last'), $node) ->jstree->select_node('#tree', '#tb-' . $self->text_block->id); $self->add_new_text_block_form(output_position => $self->text_block->output_position, insert_after_id => $self->text_block->id, requirement_spec_id => $self->text_block->requirement_spec_id) + ->reinit_widgets ->render($self); } @@ -135,6 +136,7 @@ sub action_ajax_update { ->replaceWith('#text-block-' . $self->text_block->id, $html) ->run(SORTABLE_PICTURE_LIST()) ->jstree->rename_node('#tree', '#tb-' . $self->text_block->id, $self->text_block->title) + ->prop('#tb-' . $self->text_block->id, 'title', $self->text_block->content_excerpt) ->render($self); } diff --git a/SL/DB/RequirementSpecItem.pm b/SL/DB/RequirementSpecItem.pm index 49d915845..dc710b4de 100644 --- a/SL/DB/RequirementSpecItem.pm +++ b/SL/DB/RequirementSpecItem.pm @@ -7,6 +7,7 @@ use List::MoreUtils qw(any); use Rose::DB::Object::Helpers; use Rose::DB::Object::Util; +use SL::Common (); use SL::DB::MetaSetup::RequirementSpecItem; use SL::DB::Manager::RequirementSpecItem; use SL::DB::Helper::ActsAsList; @@ -124,6 +125,13 @@ sub child_type { return $self->item_type eq 'section' ? 'function-block' : 'sub-function-block'; } +sub content_excerpt { + my ($self) = @_; + + return Common::truncate($self->description // '', at => 200); +} + + 1; __END__ diff --git a/SL/DB/RequirementSpecTextBlock.pm b/SL/DB/RequirementSpecTextBlock.pm index 421293a87..9c59731ec 100644 --- a/SL/DB/RequirementSpecTextBlock.pm +++ b/SL/DB/RequirementSpecTextBlock.pm @@ -7,6 +7,7 @@ use List::MoreUtils qw(any); use Rose::DB::Object::Helpers; use Rose::DB::Object::Util; +use SL::Common (); use SL::DB::MetaSetup::RequirementSpecTextBlock; use SL::DB::Manager::RequirementSpecTextBlock; use SL::DB::Helper::ActsAsList; @@ -65,4 +66,10 @@ sub pictures_sorted { return [ sort { $a->position <=> $b->position } $self->pictures ]; } +sub content_excerpt { + my ($self) = @_; + + return Common::truncate($self->text // '', at => 200); +} + 1; diff --git a/SL/Presenter/RequirementSpecItem.pm b/SL/Presenter/RequirementSpecItem.pm index c62032517..357f8c540 100644 --- a/SL/Presenter/RequirementSpecItem.pm +++ b/SL/Presenter/RequirementSpecItem.pm @@ -20,13 +20,13 @@ sub requirement_spec_item_jstree_data { my @children = map { $self->requirement_spec_item_jstree_data($_, %params) } @{ $item->children_sorted }; my $type = !$item->parent_id ? 'section' : 'function-block'; - my $class = $type . '-context-menu'; + my $class = $type . '-context-menu tooltip'; $class .= ' flagged' if $item->is_flagged; return { data => $self->requirement_spec_item_tree_node_title($item), metadata => { id => $item->id, type => $type }, - attr => { id => "fb-" . $item->id, href => $params{href} || '#', class => $class }, + attr => { id => "fb-" . $item->id, href => $params{href} || '#', class => $class, title => $item->content_excerpt }, children => \@children, }; } diff --git a/SL/Presenter/RequirementSpecTextBlock.pm b/SL/Presenter/RequirementSpecTextBlock.pm index c0b983a7c..8a209d373 100644 --- a/SL/Presenter/RequirementSpecTextBlock.pm +++ b/SL/Presenter/RequirementSpecTextBlock.pm @@ -14,13 +14,13 @@ use SL::JSON; sub requirement_spec_text_block_jstree_data { my ($self, $text_block, %params) = @_; - my $class = 'text-block-context-menu'; + my $class = 'text-block-context-menu tooltip'; $class .= ' flagged' if $text_block->is_flagged; return { data => $text_block->title || '', metadata => { id => $text_block->id, type => 'text-block' }, - attr => { id => "tb-" . $text_block->id, href => $params{href} || '#', class => $class }, + attr => { id => "tb-" . $text_block->id, href => $params{href} || '#', class => $class, title => $text_block->content_excerpt }, }; } diff --git a/js/kivi.js b/js/kivi.js index ac008725a..bdae4c42c 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -40,6 +40,10 @@ namespace("kivi", function(ns) { var func = kivi.get_function_by_name('local_reinit_widgets'); if (func) func(); + + ns.run_once_for('.tooltip', 'tooltip', function(elt) { + $(elt).tooltip(); + }); }; ns.submit_ajax_form = function(url, form_selector, additional_data) { diff --git a/templates/webpages/requirement_spec/show.html b/templates/webpages/requirement_spec/show.html index f01c0b2eb..bc4d5dbd3 100644 --- a/templates/webpages/requirement_spec/show.html +++ b/templates/webpages/requirement_spec/show.html @@ -86,7 +86,14 @@ $(function() { [%- END -%] ]; - $('#tree').jstree({ + $('#tree') + .bind('loaded.jstree', function() { + kivi.reinit_widgets(); +[% IF SELF.requirement_spec_item %] + $.jstree._reference("#tree").select_node('#fb-[% SELF.requirement_spec_item.id %]', true); +[% END %] + }) + .jstree({ core: { animation: 0, initially_open: initially_open, @@ -107,9 +114,6 @@ $(function() { }) .bind("move_node.jstree", kivi.requirement_spec.tree_node_moved) .bind("click.jstree", kivi.requirement_spec.tree_node_clicked); -[% IF SELF.requirement_spec_item %] - $.jstree._reference("#tree").select_node('#fb-[% SELF.requirement_spec_item.id %]', true); -[% END %] kivi.requirement_spec.create_context_menus([% SELF.requirement_spec.is_template ? 'true' : 'false' %]); $('#requirement_spec_tabs').on("tabsbeforeactivate", kivi.requirement_spec.tabs_before_activate); -- 2.20.1