X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/e2cad7d4056cf13ba8df9d4127e76273c56bf305..1f592a0f4f88893b5c2cb29b2d10e2d07b444ac0:/SL/Controller/RequirementSpecItem.pm?ds=inline diff --git a/SL/Controller/RequirementSpecItem.pm b/SL/Controller/RequirementSpecItem.pm index 9dfdad042..c4f6f6d09 100644 --- a/SL/Controller/RequirementSpecItem.pm +++ b/SL/Controller/RequirementSpecItem.pm @@ -14,7 +14,7 @@ use SL::Locale::String; use Rose::Object::MakeMethods::Generic ( - scalar => [ qw(requirement_spec item) ], + scalar => [ qw(requirement_spec item visible_item visible_section) ], ); # __PACKAGE__->run_before('load_requirement_spec'); @@ -24,6 +24,29 @@ __PACKAGE__->run_before('load_requirement_spec_item', only => [qw(dragged_and_dr # actions # +sub action_ajax_list { + my ($self) = @_; + + my $js = SL::ClientJS->new; + + if (!$::form->{clicked_id}) { + # Clicked on "sections" in the tree. Do nothing. + return $self->render($js); + } + + $self->init_visible_section($::form->{current_content_id}, $::form->{current_content_type}); + $self->item(SL::DB::RequirementSpecItem->new(id => $::form->{clicked_id})->load->get_section); + + if (!$self->visible_section || ($self->visible_section->id != $self->item->id)) { + my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $self->item); + $js->html('#column-content', $html) + ->val('#current_content_type', $self->item->get_type) + ->val('#current_content_id', $self->item->id); + } + + $self->render($js); +} + sub action_new { my ($self) = @_; @@ -108,4 +131,14 @@ sub format_exception { return join "\n", (split m/\n/, $@)[0..4]; } +sub init_visible_section { + my ($self, $content_id, $content_type) = @_; + + return undef unless $content_id; + return undef unless $content_type =~ m/section|function-block/; + + $self->visible_item(SL::DB::RequirementSpecItem->new(id => $content_id)->load); + return $self->visible_section($self->visible_item->get_section); +} + 1;