+ return $self->render(\'', { type => 'json' }) if $::form->{current_content_type} !~ m/^textblock/;
+
+ my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type});
+ my $new_where = $self->text_block->output_position;
+ my $id = $self->text_block->id;
+ my $js = SL::ClientJS->new;
+
+ # $::lxdebug->message(0, "old $old_where current $current_where new $new_where current_CID " . $::form->{current_content_id} . ' selfid ' . $self->text_block->id);
+ if (($old_where != $new_where) && ($::form->{current_content_id} == $self->text_block->id)) {
+ # The currently selected text block is dragged to the opposite
+ # text block location. Re-render the whole content column.
+ my $text_blocks = SL::DB::Manager::RequirementSpecTextBlock->get_all_sorted(where => [ output_position => $new_where ]);
+ my $html = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $new_where);
+
+ $js->val('#current_content_type', 'textblocks-' . ($new_where == 0 ? 'front' : 'back'))
+ ->html('#column-content', $html);
+
+ } else {
+ if ($old_where == $current_where) {
+ $js->remove('#text-block-' . $self->text_block->id);
+
+ if (0 == scalar(@{ SL::DB::Manager::RequirementSpecTextBlock->get_all(where => [ requirement_spec_id => $self->text_block->requirement_spec_id, output_position => $current_where ]) })) {
+ $js->show('#text-block-list-empty');
+ }
+ }
+
+ if ($new_where == $current_where) {
+ $js->hide('#text-block-list-empty');
+
+ my $html = "" . $self->render('requirement_spec_text_block/_text_block', { output => 0 }, text_block => $self->text_block);
+ $html =~ s/^\s+//;
+ my $prior_text_block = $self->text_block->get_previous_in_list;
+
+ if ($prior_text_block) {
+ $js->insertAfter($html, '#text-block-' . $prior_text_block->id);
+ } else {
+ $js->appendTo($html, '#text-block-list');
+ }
+ }
+ }
+
+ $::lxdebug->message(0, "old $old_where current $current_where new $new_where");
+
+ $::lxdebug->dump(0, "actions", $js);
+
+ $self->render($js);