From: Moritz Bunkus Date: Wed, 6 Mar 2013 16:05:25 +0000 (+0100) Subject: Löschen von Textblöcken X-Git-Tag: release-3.2.0beta~467^2~242 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f3cfe3bd1d0be609d699ce8c2d31a9b1e94272de;p=kivitendo-erp.git Löschen von Textblöcken --- diff --git a/SL/Controller/RequirementSpecTextBlock.pm b/SL/Controller/RequirementSpecTextBlock.pm index 21cf29e63..e0529da1c 100644 --- a/SL/Controller/RequirementSpecTextBlock.pm +++ b/SL/Controller/RequirementSpecTextBlock.pm @@ -17,7 +17,7 @@ use Rose::Object::MakeMethods::Generic scalar => [ qw(requirement_spec text_block) ], ); -__PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit update dragged_and_dropped)]); +__PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit ajax_update ajax_delete dragged_and_dropped)]); # # actions @@ -70,12 +70,13 @@ sub action_ajax_edit { my $html = $self->render('requirement_spec_text_block/_form', { output => 0 }, PREDEFINED_TEXTS => $predefined_texts); $js->hide('#text-block-' . $self->text_block->id) + ->remove('#edit_text_block_' . $self->text_block->id . '_form') ->insertAfter($html, '#text-block-' . $self->text_block->id) ->jstree->select_node('#tree', '#tb-' . $self->text_block->id) ->render($self); } -sub action_update { +sub action_ajax_update { my ($self, %params) = @_; my $prefix = $::form->{form_prefix} || 'text_block'; @@ -96,6 +97,24 @@ sub action_update { ->render($self); } +sub action_ajax_delete { + my ($self) = @_; + + my $js = SL::ClientJS->new; + + my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type}) // -1; + if ($self->text_block->output_position == $current_where) { + $js->remove('#edit_text_block_' . $self->text_block->id . '_form') + ->remove('#text-block-' . $self->text_block->id); + + $js->show('#text-block-list-empty') if 1 == scalar @{ $self->text_block->get_full_list }; + } + + $self->text_block->delete; + + $js->jstree->delete_node('#tree', '#tb-' . $self->text_block->id) + ->render($self); +} sub action_dragged_and_dropped { my ($self) = @_; @@ -154,10 +173,6 @@ sub action_dragged_and_dropped { } } - $::lxdebug->message(0, "old $old_where current $current_where new $new_where"); - - $::lxdebug->dump(0, "actions", $js); - $self->render($js); } diff --git a/js/requirement_spec.js b/js/requirement_spec.js index a9e19e2af..f7b52e642 100644 --- a/js/requirement_spec.js +++ b/js/requirement_spec.js @@ -205,7 +205,7 @@ function delete_text_block(key, opt) { function submit_edit_text_block_form(id_base) { var url = "controller.pl?" + $('#' + id_base + '_form').serialize(); var data = { - action: 'RequirementSpecTextBlock/update.js', + action: 'RequirementSpecTextBlock/ajax_update', id: $('#' + id_base + '_id').val(), form_prefix: id_base }; diff --git a/templates/webpages/requirement_spec/show.html b/templates/webpages/requirement_spec/show.html index 8df8c00ff..cb5cda92a 100644 --- a/templates/webpages/requirement_spec/show.html +++ b/templates/webpages/requirement_spec/show.html @@ -28,7 +28,7 @@ [% L.hidden_tag('current_content_id', SELF.requirement_spec_item.id) %]
- [%- IF SELF.requirement_spec_item && SELF.requirement_spec_item.id -%] + [%- IF SELF.requirement_spec_item -%] [%- INCLUDE 'requirement_spec_item/_single_section.html' requirement_spec_item=SELF.requirement_spec_item -%] [%- ELSE -%] no section @@ -101,7 +101,10 @@ plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ] }) .bind("move_node.jstree", requirement_spec_tree_node_moved) - .bind("click.jstree", requirement_spec_tree_node_clicked) + .bind("click.jstree", requirement_spec_tree_node_clicked); +[%- IF SELF.requirement_spec_item -%] + $.jstree._reference("#tree").select_node('fb-[% SELF.requirement_spec_item.id %]', true); +[%- END -%] }); function ask_delete_text_block(key, opt) {