Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9ababdb3

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 9ababdb3059dad5a245766a81281d92834595ab0
  • Vorgänger 8042b063
  • Nachfolger e967690d

Refactoring

Unterschiede anzeigen:

SL/Controller/RequirementSpecItem.pm
551 551
             } @{ $self->item->requirement_spec->sections };
552 552
}
553 553

  
554
sub ensure_section_is_shown {
555
  my ($self, %params) = @_;
556

  
557
  return $self->js if $self->is_item_visible;
558

  
559
  # Show section/item to edit if it is not visible.
560
  my $new_section = $self->item->section;
561
  my $html        = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $new_section);
562

  
563
  return $self->js
564
    ->html('#column-content', $html)
565
    ->val('#current_content_type', 'section')
566
    ->val('#current_content_id',   $new_section->id)
567
    ->jstree->select_node('#tree', '#fb-' . $new_section->id);
568
}
569

  
570
sub add_new_item_form {
571
  my ($self, %params) = @_;
572

  
573
  for (qw(insert_position display_reference)) {
574
    croak "Missing parameter $_" if !$params{$_};
575
  }
576
  croak "Missing parameter insert_reference" if ($params{insert_position} eq 'insertAfter') && !$params{insert_reference};
577

  
578
  my $id_base = join('_', 'new_function_block', Time::HiRes::gettimeofday(), int rand 1000000000000);
579
  my $html    = $self->render(
580
    'requirement_spec_item/_function_block_form',
581
    { output => 0 },
582
    DEPENDENCIES          => [ $self->create_dependencies ],
583
    SELECTED_DEPENDENCIES => [],
584
    requirement_spec_item => $self->item,
585
    id_base               => $id_base,
586
    insert_after          => $params{insert_position} eq 'insertAfter' ? $params{insert_reference} : undef,
587
  );
588

  
589
  return $self->js
590
    ->action($params{insert_position}, $html, $params{display_reference})
591
    ->focus("#${id_base}_description");
592
}
593

  
554 594
sub add_function_block {
555 595
  my ($self, $new_type) = @_;
556 596

  
......
575 615
    : $case eq 'sub-function-block:sub-function-block' ? ( 'insertAfter', $clicked_item->id,        $clicked_item->parent_id,         '#sub-function-block-'           )
576 616
    :                                                    die "Invalid combination of 'clicked_type (section)/new_type ($new_type)'";
577 617

  
578
  $self->item(SL::DB::RequirementSpecItem->new(requirement_spec_id => $::form->{requirement_spec_id}, parent_id => $parent_id, item_type => $new_type));
579

  
580 618
  $display_reference .= $insert_reference if $display_reference =~ m/-$/;
581
  my $id_base         = join('_', 'new_function_block', Time::HiRes::gettimeofday(), int rand 1000000000000);
582
  my $html            = $self->render(
583
    'requirement_spec_item/_function_block_form',
584
    { output => 0 },
585
    DEPENDENCIES          => [ $self->create_dependencies ],
586
    SELECTED_DEPENDENCIES => [],
587
    requirement_spec_item => $self->item,
588
    id_base               => $id_base,
589
    insert_after          => $insert_position eq 'insertAfter' ? $insert_reference : undef,
590
  );
591 619

  
592
  my $new_section = $self->item->section;
593
  if (!$self->is_item_visible) {
594
    # Show section/item to edit if it is not visible.
595

  
596
    $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $new_section);
597
    $self->js
598
      ->html('#column-content', $html)
599
      ->val('#current_content_type', 'section')
600
      ->val('#current_content_id',   $new_section->id)
601
      ->jstree->select_node('#tree', '#fb-' . $new_section->id);
602
  }
603

  
604
  # $::lxdebug->message(0, "alright! clicked ID " . $::form->{id} . " type $clicked_type new_type $new_type insert_pos $insert_position ref " . ($insert_reference // '<undef>') . " parent $parent_id display_ref $display_reference");
620
  $self->item(SL::DB::RequirementSpecItem->new(requirement_spec_id => $::form->{requirement_spec_id}, parent_id => $parent_id, item_type => $new_type));
605 621

  
606
  $self->js->action($insert_position, $html, $display_reference)
607
           ->focus("#${id_base}_description");
622
  $self->ensure_section_is_shown;
623
  $self->add_new_item_form(insert_position => $insert_position, insert_reference => $insert_reference, display_reference => $display_reference);
608 624

  
609 625
  $self->js->show('#sub-function-block-container-' . $parent_id) if $new_type eq 'sub-function-block';
610 626

  

Auch abrufbar als: Unified diff