Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9a71fdb6

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 9a71fdb60ef0a0dcc50b858d34b552f937880778
  • Vorgänger 85c4af4a
  • Nachfolger 49644f8f

Pflichtenheftitems: Neuanlegen von (Unter)Funktionsblöcken

Unterschiede anzeigen:

SL/Controller/RequirementSpecItem.pm
167 167
      ->render($self);
168 168
  }
169 169

  
170
  die 'TODO: create item';
170
  my $template = 'requirement_spec_item/_' . (apply { s/-/_/g; $_ } $type);
171
  my $html     = $self->render($template, { output => 0 }, requirement_spec_item => $self->item, id_prefix => $type eq 'function-block' ? '' : 'sub-');
172
  my $node     = $self->presenter->requirement_spec_item_jstree_data($self->item);
173

  
174
  $js->replaceWith('#' . $prefix . '_form', $html)
175
     ->hide('#section-list-empty')
176
     ->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#fb-' . $self->item->parent_id, 'last'), $node)
177
     ->jstree->select_node('#tree', '#fb-' . $self->item->id);
178

  
179
  $self->replace_bottom($js, $self->item->parent) if $type eq 'sub-function-block';
180

  
181
  $js->render($self);
171 182
}
172 183

  
173 184
sub action_ajax_edit {
......
270 281
sub action_ajax_delete {
271 282
  my ($self) = @_;
272 283

  
273
  my $js = SL::ClientJS->new;
284
  my $js        = SL::ClientJS->new;
285
  my $full_list = $self->item->get_full_list;
274 286

  
275 287
  $self->item->delete;
276 288

  
......
297 309

  
298 310
    $self->replace_bottom($js, $self->item->parent_id) if $type eq 'sub-function-block';
299 311

  
300
    if (1 == scalar @{ $self->item->get_full_list }) {
312
    if (1 == scalar @{ $full_list }) {
301 313
      if ($type eq 'function-block') {
302 314
        $js->show('#section-list-empty');
303 315
      } elsif ($type eq 'sub-function-block') {
......
400 412
sub add_function_block {
401 413
  my ($self, $new_type) = @_;
402 414

  
403
  die "Invalid new_type '$new_type'"            if $new_type !~ m/^(?:sub-)?function-block$/;
404
  die "Missing parameter 'id'"                  if !$::form->{id};
405
  die "Missing parameter 'requirement_spec_id'" if !$::form->{requirement_spec_id};
415
  my $clicked_id = $::form->{id} || ($self->visible_item ? $self->visible_item->id : undef);
406 416

  
407
  my $clicked_item = SL::DB::RequirementSpecItem->new(id => $::form->{id})->load;
417
  die "Invalid new_type '$new_type'"               if $new_type !~ m/^(?:sub-)?function-block$/;
418
  die "Missing parameter 'id' and no visible item" if !$clicked_id;
419
  die "Missing parameter 'requirement_spec_id'"    if !$::form->{requirement_spec_id};
420

  
421
  my $clicked_item = SL::DB::RequirementSpecItem->new(id => $clicked_id)->load;
408 422
  my $clicked_type = $clicked_item->get_type;
409 423

  
410 424
  die "Invalid clicked_type '$clicked_type'" if $clicked_type !~ m/^(?: section | (?:sub-)? function-block )$/x;
......
430 444
    SELECTED_DEPENDENCIES => [],
431 445
    requirement_spec_item => $self->item,
432 446
    id_base               => $id_base,
433
    insert_after          => $insert_reference,
447
    insert_after          => $insert_position eq 'insertAfter' ? $insert_reference : undef,
434 448
  );
435 449

  
436 450
  my $js = SL::ClientJS->new;
......
449 463
  # $::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");
450 464

  
451 465
  $js->action($insert_position, $html, $display_reference)
452
     ->focus("#${id_base}_description")
453
     ->render($self);
466
     ->focus("#${id_base}_description");
467

  
468
  $js->show('#sub-function-block-container-' . $parent_id) if $new_type eq 'sub-function-block';
469

  
470
  $js->render($self);
454 471
}
455 472

  
456 473
1;

Auch abrufbar als: Unified diff