+sub paste_picture {
+ my ($self, $copied) = @_;
+
+ if (!$self->text_block->db->do_transaction(sub {
+ 1;
+ $self->picture($copied->to_object)->save; # Create new picture from copied data and save
+ $self->text_block->add_pictures($self->picture); # Add new picture to text block
+ $self->text_block->save;
+ })) {
+ $::lxdebug->message(LXDebug::WARN(), "Error: " . $self->text_block->db->error);
+ return $self->js->error($::locale->text('Saving failed. Error message from the database: #1', $self->text_block->db->error))->render($self);
+ }
+
+ my $html = $self->render('requirement_spec_text_block/_text_block_picture', { output => 0 }, picture => $self->picture);
+
+ $self->invalidate_version
+ ->append('#text-block-' . $self->text_block->id . '-pictures', $html)
+ ->show('#text-block-' . $self->text_block->id . '-pictures')
+ ->render($self);
+}
+