X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FRequirementSpecItem.pm;h=c8119be350eadf93e198c4a802d6040c0d4de165;hb=7038ccd5ea5b42f1c02c46dfa1dd23355d503ee7;hp=0797a3ffdd3eac7831e6e85cfaf0572c4fa10e42;hpb=6bcd3c849d50f9df3b40031e2899b7e14c34875a;p=kivitendo-erp.git diff --git a/SL/Controller/RequirementSpecItem.pm b/SL/Controller/RequirementSpecItem.pm index 0797a3ffd..c8119be35 100644 --- a/SL/Controller/RequirementSpecItem.pm +++ b/SL/Controller/RequirementSpecItem.pm @@ -14,6 +14,7 @@ use SL::Controller::Helper::RequirementSpec; use SL::DB::RequirementSpec; use SL::DB::RequirementSpecComplexity; use SL::DB::RequirementSpecItem; +use SL::DB::RequirementSpecPredefinedText; use SL::DB::RequirementSpecRisk; use SL::Helper::Flash; use SL::JSON; @@ -22,7 +23,7 @@ use SL::Locale::String; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(item visible_item visible_section clicked_item sections) ], - 'scalar --get_set_init' => [ qw(complexities risks js) ], + 'scalar --get_set_init' => [ qw(complexities risks js predefined_texts) ], ); __PACKAGE__->run_before('check_auth'); @@ -155,6 +156,7 @@ sub action_ajax_add_section { ->hide('#column-content > *') ->appendTo($html, '#column-content') ->focus('#new_section_title') + ->reinit_widgets ->render($self); } @@ -197,6 +199,7 @@ sub action_ajax_create { ->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#sections', 'last'), $node) ->jstree->select_node('#tree', '#fb-' . $self->item->id); return $self->add_new_item_form_after_create + ->reinit_widgets ->render($self); } @@ -208,6 +211,7 @@ sub action_ajax_create { ->replaceWith('#' . $prefix . '_form', $html) ->hide('#section-list-empty') ->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#fb-' . $self->item->parent_id, 'last'), $node) + ->reinit_widgets ->jstree->select_node('#tree', '#fb-' . $self->item->id); $self->replace_bottom($self->item->parent) if $type eq 'sub-function-block'; @@ -239,9 +243,10 @@ sub action_ajax_edit { ->remove("#edit_section_form") ->insertAfter($html, '#section-header-' . $self->item->id) ->jstree->select_node('#tree', '#fb-' . $self->item->id) - ->focus("#edit_section_title") ->val('#current_content_type', 'section') ->val('#current_content_id', $self->item->id) + ->reinit_widgets + ->focus("#edit_section_title") ->render($self); return; } @@ -258,10 +263,12 @@ sub action_ajax_edit { ->hide($content_top_id) ->remove("#${id_base}_form") ->insertAfter($html, $content_top_id) + ->run('kivi.requirement_spec.init_function_block_keypress_events', "${id_base}_form") ->jstree->select_node('#tree', '#fb-' . $self->item->id) - ->focus("#${id_base}_description") ->val('#current_content_type', $self->item->item_type) ->val('#current_content_id', $self->item->id) + ->reinit_widgets + ->focus("#${id_base}_description") ->render($self); } @@ -292,6 +299,9 @@ sub action_ajax_update { ->html('#section-header-' . $self->item->id, $html) ->show('#section-header-' . $self->item->id) ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $::request->presenter->requirement_spec_item_tree_node_title($self->item)) + ->prop('#fb-' . $self->item->id . ' a', 'title', $self->item->content_excerpt) + ->addClass('#fb-' . $self->item->id . ' a', 'tooltip') + ->reinit_widgets ->render($self); } @@ -306,6 +316,9 @@ sub action_ajax_update { $self->js ->remove('#' . $prefix . '_form') ->replaceWith('#' . $id_prefix . 'top-' . $self->item->id, $html_top) + ->prop('#fb-' . $self->item->id . ' a', 'title', $self->item->content_excerpt) + ->addClass('#fb-' . $self->item->id . ' a', 'tooltip') + ->reinit_widgets ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $::request->presenter->requirement_spec_item_tree_node_title($self->item)); $self->replace_bottom($self->item, id_prefix => $id_prefix); @@ -484,7 +497,7 @@ sub action_ajax_paste { sub check_auth { my ($self) = @_; - $::auth->assert('sales_quotation_edit'); + $::auth->assert('requirement_spec_edit'); } sub load_requirement_spec_item { @@ -516,6 +529,10 @@ sub init_risks { return SL::DB::Manager::RequirementSpecRisk->get_all_sorted; } +sub init_predefined_texts { + return SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted(where => [ useable_for_sections => 1 ]); +} + sub init_js { my ($self) = @_; $self->js(SL::ClientJS->new); @@ -550,7 +567,7 @@ sub select_node { sub create_dependency_item { my $self = shift; - [ $_[0]->id, $self->presenter->truncate(join(' ', grep { $_ } ($_[1], $_[0]->fb_number, $_[0]->description))) ]; + [ $_[0]->id, $self->presenter->truncate(join(' ', grep { $_ } ($_[1], $_[0]->fb_number, $_[0]->description_as_stripped_html))) ]; } sub create_dependencies { @@ -600,6 +617,9 @@ sub add_new_item_form { return $self->js ->action($params{insert_position}, $html, $params{display_reference}) + ->action_if($self->item->item_type eq 'sub-function-block', 'show', '#sub-function-block-container-' . $self->item->parent_id) + ->run('kivi.requirement_spec.init_function_block_keypress_events', "${id_base}_form") + ->reinit_widgets ->focus("#${id_base}_description"); } @@ -607,18 +627,53 @@ sub add_new_item_form_after_create { my ($self, %params) = @_; my $created_item = $self->item; - my $is_section = $created_item->item_type eq 'section'; + + my ($new_item_type, $new_parent_id, $insert_position, $insert_reference, $display_reference); + if ($created_item->item_type eq 'section') { + # $created_item is section, new one will be function-block + $new_item_type = 'function-block'; + $new_parent_id = $created_item->id; + $insert_position = 'appendTo'; + $display_reference = '#section-list'; + + } elsif (!$::form->{shift_in_out}) { + # $created_item is function-block or sub-function-block, new one will be the same + $new_item_type = $created_item->item_type; + $new_parent_id = $created_item->parent_id; + $insert_position = 'insertAfter'; + $insert_reference = $created_item->id; + $display_reference = '#' . $created_item->item_type . '-' . $created_item->id; + + } elsif ($created_item->item_type eq 'function-block') { + # $created_item is function-block, new one will be sub-function-block + $new_item_type = 'sub-function-block'; + $new_parent_id = $created_item->id; + $insert_position = 'appendTo'; + $display_reference = '#sub-function-block-container-' . $created_item->id; + + } else { + # $created_item is sub-function-block, new one will be function-block + $new_item_type = 'function-block'; + $new_parent_id = $created_item->parent->parent_id; + $insert_position = 'insertAfter'; + $insert_reference = $created_item->parent_id; + $display_reference = '#function-block-' . $created_item->parent_id; + } + + $::lxdebug->message(LXDebug::DEBUG1(), + "OLD item_type " . $created_item->item_type . " ; NEW item_type $new_item_type ; parent_id $new_parent_id ; " . + "insert_position $insert_position ; insert_reference $insert_reference ; display_reference $display_reference"); $self->item(SL::DB::RequirementSpecItem->new( requirement_spec_id => $created_item->requirement_spec_id, - parent_id => $is_section ? $created_item->id : $created_item->parent_id, - item_type => $is_section ? 'function-block' : $created_item->item_type, + parent_id => $new_parent_id, + item_type => $new_item_type, )); $self->add_new_item_form( - insert_reference => $created_item->id, - insert_position => $is_section ? 'appendTo' : 'insertAfter', - display_reference => $is_section ? '#section-list' : '#' . $created_item->item_type . '-' . $created_item->id, + insert_reference => $insert_reference, + insert_position => $insert_position, + display_reference => $display_reference, ); }