+
+ $::lxdebug->dump(0, "form", $::form);
+
+ $self->init_visible_section($::form->{current_content_id}, $::form->{current_content_type});
+ $self->item(SL::DB::RequirementSpecItem->new(id => $::form->{id})->load);
+
+ my $js = SL::ClientJS->new;
+
+ die "TODO: edit section" if $self->item->get_type =~ m/section/;
+
+ if (!$self->visible_section || ($self->visible_section->id != $self->item->get_section->id)) {
+ my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $self->item);
+ $js->html('#column-content', $html);
+ }
+
+ if ($self->item->get_type =~ m/function-block/) {
+ my $create_item = sub {
+ [ $_[0]->id, $self->presenter->truncate(join(' ', grep { $_ } ($_[1], $_[0]->fb_number, $_[0]->description))) ]
+ };
+ my @dependencies =
+ map { [ $_->fb_number . ' ' . $_->title,
+ [ map { ( $create_item->($_),
+ map { $create_item->($_, '->') } @{ $_->sorted_children })
+ } @{ $_->sorted_children } ] ]
+ } @{ $self->item->requirement_spec->sections };
+
+ my @selected_dependencies = map { $_->id } @{ $self->item->dependencies };
+
+ my $html = $self->render('requirement_spec_item/_function_block_form', { output => 0 }, DEPENDENCIES => \@dependencies, SELECTED_DEPENDENCIES => \@selected_dependencies);
+ my $id_base = $self->item->get_type . '-' . $self->item->id;
+ my $content_top_id = '#' . $self->item->get_type . '-content-top-' . $self->item->id;
+
+ $js->hide($content_top_id)
+ ->remove("#edit_${id_base}_form")
+ ->insertAfter($html, $content_top_id)
+ ->jstree->select_node('#tree', '#fb-' . $self->item->id)
+ ->focus("#edit_${id_base}_description")
+ ->val('#current_content_type', $self->item->get_type)
+ ->val('#current_content_id', $self->item->id)
+ ->render($self);
+ }