X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FRequirementSpecTextBlock.pm;h=d6e8c35a66d3c0f8ee7ec7142b885afd7929cd3f;hb=a1ea659fc8d83ea24f7ba863c82322ae41131007;hp=b5d83104413e091e186e0e08d40bd04d763a0b29;hpb=402ad79b07e541bf996b3f5f463d3a9ac4705a01;p=kivitendo-erp.git diff --git a/SL/Controller/RequirementSpecTextBlock.pm b/SL/Controller/RequirementSpecTextBlock.pm index b5d831044..d6e8c35a6 100644 --- a/SL/Controller/RequirementSpecTextBlock.pm +++ b/SL/Controller/RequirementSpecTextBlock.pm @@ -18,12 +18,15 @@ use SL::DB::RequirementSpecTextBlock; use SL::Helper::Flash; use SL::Locale::String; +use constant SORTABLE_PICTURE_LIST => 'kivi.requirement_spec.make_text_block_picture_lists_sortable'; + use Rose::Object::MakeMethods::Generic ( scalar => [ qw(text_block) ], 'scalar --get_set_init' => [ qw(predefined_texts js picture) ], ); +__PACKAGE__->run_before('check_auth'); __PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit ajax_update ajax_delete ajax_flag dragged_and_dropped ajax_copy ajax_add_picture)]); # @@ -48,7 +51,9 @@ sub action_ajax_list { $self->show_list(output_position => $new_where, id => $::form->{clicked_id}, set_type => 1) if ($new_where != ($current_where // -1)); - $self->render($self->js); + $self->js + ->run(SORTABLE_PICTURE_LIST()) + ->render($self); } sub action_ajax_add { @@ -81,6 +86,7 @@ sub action_ajax_edit { ->insertAfter($html, '#text-block-' . $self->text_block->id) ->jstree->select_node('#tree', '#tb-' . $self->text_block->id) ->focus('#edit_text_block_' . $self->text_block->id . '_title') + ->reinit_widgets ->render($self); } @@ -102,9 +108,11 @@ sub action_ajax_create { $self->invalidate_version ->hide('#text-block-list-empty') ->replaceWith('#' . $::form->{form_prefix} . '_form', $html) + ->run(SORTABLE_PICTURE_LIST()) ->jstree->create_node('#tree', $insert_after ? ('#tb-' . $insert_after, 'after') : ('#tb-' . ($attributes->{output_position} == 0 ? 'front' : 'back'), 'last'), $node) ->jstree->select_node('#tree', '#tb-' . $self->text_block->id); $self->add_new_text_block_form(output_position => $self->text_block->output_position, insert_after_id => $self->text_block->id, requirement_spec_id => $self->text_block->requirement_spec_id) + ->reinit_widgets ->render($self); } @@ -128,7 +136,11 @@ sub action_ajax_update { $self->invalidate_version ->remove('#' . $prefix . '_form') ->replaceWith('#text-block-' . $self->text_block->id, $html) + ->run(SORTABLE_PICTURE_LIST()) ->jstree->rename_node('#tree', '#tb-' . $self->text_block->id, $self->text_block->title) + ->prop('#tb-' . $self->text_block->id . ' a', 'title', $self->text_block->content_excerpt) + ->addClass('#tb-' . $self->text_block->id . ' a', 'tooltip') + ->reinit_widgets ->render($self); } @@ -221,7 +233,9 @@ sub action_dragged_and_dropped { } } - $self->js->render($self); + $self->js + ->run(SORTABLE_PICTURE_LIST()) + ->render($self); } sub action_ajax_copy { @@ -261,6 +275,7 @@ sub action_ajax_paste { my $node = $self->presenter->requirement_spec_text_block_jstree_data($self->text_block); $self->invalidate_version + ->run(SORTABLE_PICTURE_LIST()) ->jstree->create_node('#tree', $::form->{id} ? ('#tb-' . $::form->{id}, 'after') : ("#tb-${front_back}", 'last'), $node) ->render($self); } @@ -372,10 +387,23 @@ sub action_ajax_paste_picture { $self->paste_picture($copied); } +sub action_reorder_pictures { + my ($self) = @_; + + SL::DB::RequirementSpecPicture->reorder_list(@{ $::form->{picture_id} || [] }); + + $self->render(\'', { type => 'json' }); +} + # # filters # +sub check_auth { + my ($self) = @_; + $::auth->assert('requirement_spec_edit'); +} + sub load_requirement_spec_text_block { my ($self) = @_; $self->text_block(SL::DB::RequirementSpecTextBlock->new(id => $::form->{id})->load || die "No such requirement spec text block"); @@ -399,7 +427,7 @@ sub output_position_from_id { } sub init_predefined_texts { - return SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted; + return SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted(where => [ useable_for_text_blocks => 1 ]); } sub init_picture { @@ -435,6 +463,7 @@ sub add_new_text_block_form { $self->js ->action($params{insert_after_id} ? 'insertAfter' : 'appendTo', $html, '#text-block-' . ($params{insert_after_id} || 'list')) + ->reinit_widgets ->focus('#' . $id_base . '_title'); }