X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FRequirementSpecTextBlock.pm;h=ca34ede996c29e255038d7746753d47c89842f17;hb=d6fed9b55a11dca1cfd9cd6f43940a945533d318;hp=d6e8c35a66d3c0f8ee7ec7142b885afd7929cd3f;hpb=8f9f54341530291a8ce3b267fdc63b74105f1d29;p=kivitendo-erp.git diff --git a/SL/Controller/RequirementSpecTextBlock.pm b/SL/Controller/RequirementSpecTextBlock.pm index d6e8c35a6..ca34ede99 100644 --- a/SL/Controller/RequirementSpecTextBlock.pm +++ b/SL/Controller/RequirementSpecTextBlock.pm @@ -8,7 +8,6 @@ use Carp; use Params::Validate (); use Time::HiRes (); -use SL::ClientJS; use SL::Clipboard; use SL::Controller::Helper::RequirementSpec; use SL::DB::RequirementSpec; @@ -23,7 +22,7 @@ use constant SORTABLE_PICTURE_LIST => 'kivi.requirement_spec.make_text_block_pic use Rose::Object::MakeMethods::Generic ( scalar => [ qw(text_block) ], - 'scalar --get_set_init' => [ qw(predefined_texts js picture) ], + 'scalar --get_set_init' => [ qw(predefined_texts picture) ], ); __PACKAGE__->run_before('check_auth'); @@ -66,7 +65,7 @@ sub action_ajax_add { $self->add_new_text_block_form(output_position => $new_where, insert_after_id => $::form->{id}, requirement_spec_id => $::form->{requirement_spec_id}); - $self->invalidate_version->render($self); + $self->invalidate_version->render; } sub action_ajax_edit { @@ -103,7 +102,7 @@ sub action_ajax_create { $self->text_block->add_to_list(position => 'after', reference => $insert_after) if $insert_after; my $html = $self->render('requirement_spec_text_block/_text_block', { output => 0 }, text_block => $self->text_block); - my $node = $self->presenter->requirement_spec_text_block_jstree_data($self->text_block); + my $node = $self->text_block->presenter->jstree_data; $self->invalidate_version ->hide('#text-block-list-empty') @@ -185,7 +184,7 @@ sub action_dragged_and_dropped { my $dropped_type = $position ne 'last' ? undef : $::form->{dropped_type} =~ m/^ text-blocks- (?:front|back) $/x ? $::form->{dropped_type} : die "Unknown 'dropped_type' parameter"; my $old_where = $self->text_block->output_position; - $self->text_block->db->do_transaction(sub { + $self->text_block->db->with_transaction(sub { 1; $self->text_block->remove_from_list; $self->text_block->output_position($position =~ m/before|after/ ? $dropped_text_block->output_position : $::form->{dropped_type} eq 'text-blocks-front' ? 0 : 1); @@ -273,7 +272,7 @@ sub action_ajax_paste { $self->js->action($::form->{id} ? 'insertAfter' : 'appendTo', $html, '#text-block-' . ($::form->{id} || 'list')); } - my $node = $self->presenter->requirement_spec_text_block_jstree_data($self->text_block); + my $node = $self->text_block->presenter->jstree_data; $self->invalidate_version ->run(SORTABLE_PICTURE_LIST()) ->jstree->create_node('#tree', $::form->{id} ? ('#tb-' . $::form->{id}, 'after') : ("#tb-${front_back}", 'last'), $node) @@ -434,11 +433,6 @@ sub init_picture { return SL::DB::RequirementSpecPicture->new(id => $::form->{picture_id} || $::form->{id})->load; } -sub init_js { - my ($self) = @_; - $self->js(SL::ClientJS->new); -} - sub invalidate_version { my ($self) = @_; @@ -488,14 +482,14 @@ sub show_list { sub paste_picture { my ($self, $copied) = @_; - if (!$self->text_block->db->do_transaction(sub { + if (!$self->text_block->db->with_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); + return $self->js->error($::locale->text('Saving failed. Error message from the database: #1', $self->text_block->db->error))->render; } my $html = $self->render('requirement_spec_text_block/_text_block_picture', { output => 0 }, picture => $self->picture); @@ -503,7 +497,7 @@ sub paste_picture { $self->invalidate_version ->append('#text-block-' . $self->text_block->id . '-pictures', $html) ->show('#text-block-' . $self->text_block->id . '-pictures') - ->render($self); + ->render; } 1;