+ my $text_block = $id ? SL::DB::Manager::RequirementSpecTextBlock->find_by(id => $id) : undef;
+
+ return $text_block ? $text_block->output_position : undef;
+}
+
+sub init_predefined_texts {
+ return SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted;
+}
+
+sub init_js {
+ my ($self) = @_;
+ $self->js(SL::ClientJS->new);
+}
+
+sub invalidate_version {
+ my ($self) = @_;
+
+ my $html = $self->render('requirement_spec/_version', { output => 0 },
+ requirement_spec => SL::DB::RequirementSpec->new(id => $::form->{requirement_spec_id} || $self->text_block->requirement_spec_id)->load);
+ return $self->js->html('#requirement_spec_version', $html);
+}
+
+sub add_new_text_block_form {
+ my ($self, %params) = @_;
+
+ croak "Missing parameter output_position" unless defined($params{output_position}) && ($params{output_position} ne '');
+ croak "Missing parameter requirement_spec_id" unless $params{requirement_spec_id};
+
+ $self->text_block(SL::DB::RequirementSpecTextBlock->new(
+ requirement_spec_id => $params{requirement_spec_id},
+ output_position => $params{output_position},
+ ));
+
+ my $id_base = join('_', 'new_text_block', Time::HiRes::gettimeofday(), int rand 1000000000000);
+ my $html = $self->render('requirement_spec_text_block/_form', { output => 0 }, id_base => $id_base, insert_after => $params{insert_after_id});