Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 84bf9475

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 84bf9475a9637122604fbecb6c331022e10755c7
  • Vorgänger 5723fbf9
  • Nachfolger 3bbe01f7

Refactoring: Listenanzeige in eigene Funktion ausgelagert

Unterschiede anzeigen:

SL/Controller/RequirementSpecTextBlock.pm
5 5
use parent qw(SL::Controller::Base);
6 6

  
7 7
use Carp;
8
use Params::Validate ();
8 9
use Time::HiRes ();
9 10

  
10 11
use SL::ClientJS;
......
43 44

  
44 45
  # $::lxdebug->message(0, "cur $current_where new $new_where");
45 46

  
46
  if (!defined($current_where) || ($new_where != $current_where)) {
47
    my $text_blocks = SL::DB::Manager::RequirementSpecTextBlock->get_all_sorted(where => [ output_position => $new_where, requirement_spec_id => $::form->{requirement_spec_id} ]);
48
    my $html        = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $new_where);
49

  
50
    $self->js
51
       ->html('#column-content', $html)
52
       ->val('#current_content_type', 'text-blocks-' . (0 == $new_where ? 'front' : 'back'))
53
       ->val('#current_content_id',   $::form->{clicked_id});
54
  }
47
  $self->show_list(output_position => $new_where, id => $::form->{clicked_id}) if ($new_where != ($current_where // -1));
55 48

  
56 49
  $self->render($self->js);
57 50
}
......
62 55
  my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type}) // -1;
63 56
  my $new_where     = $self->output_position_from_id($::form->{id})                                                  // $::form->{output_position};
64 57

  
65
  if ($new_where != $current_where) {
66
    my $text_blocks = SL::DB::Manager::RequirementSpecTextBlock->get_all_sorted(where => [ output_position => $new_where, requirement_spec_id => $::form->{requirement_spec_id} ]);
67
    my $html        = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $new_where);
68

  
69
    $self->js->html('#column-content', $html);
70
  }
58
  $self->show_list(output_position => $new_where) if $new_where != $current_where;
71 59

  
72 60
  $self->add_new_text_block_form(output_position => $new_where, insert_after_id => $::form->{id}, requirement_spec_id => $::form->{requirement_spec_id});
73 61

  
......
78 66
  my ($self) = @_;
79 67

  
80 68
  my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type}) // -1;
81
  if ($self->text_block->output_position != $current_where) {
82
    my $text_blocks = $self->text_block->get_full_list;
83
    my $html        = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $self->text_block->output_position);
84 69

  
85
    $self->js
86
       ->html('#column-content', $html)
87
       ->val('#current_content_type', 'text-block')
88
       ->val('#current_content_id',   $self->text_block->id);
70
  if ($self->text_block->output_position != $current_where) {
71
    $self->show_list(output_position => $self->text_block->output_position, id => $self->text_block->id, requirement_spec_id => $self->text_block->requirement_spec_id);
89 72
  }
90 73

  
91 74
  my $html = $self->render('requirement_spec_text_block/_form', { output => 0 });
......
209 192
  if (($old_where != $new_where) && ($::form->{current_content_id} == $self->text_block->id)) {
210 193
    # The currently selected text block is dragged to the opposite
211 194
    # text block location. Re-render the whole content column.
212
    my $text_blocks = SL::DB::Manager::RequirementSpecTextBlock->get_all_sorted(where => [ output_position => $new_where ]);
213
    my $html        = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $new_where);
214

  
215
    $self->js
216
       ->val('#current_content_type', 'text-blocks-' . ($new_where == 0 ? 'front' : 'back'))
217
       ->html('#column-content', $html);
195
    $self->show_list(output_position => $new_where, id => $id);
218 196

  
219 197
  } else {
220 198
    if ($old_where == $current_where) {
......
341 319
     ->focus('#' . $id_base . '_title');
342 320
}
343 321

  
322
sub show_list {
323
  my $self   = shift;
324
  my %params = Params::Validate::validate(@_, { output_position => 1, id => 0, requirement_spec_id => 0, });
325

  
326
  $params{requirement_spec_id} ||= $::form->{requirement_spec_id};
327
  croak "Unknown requirement_spec_id" if !$params{requirement_spec_id};
328

  
329
  my $text_blocks = SL::DB::Manager::RequirementSpecTextBlock->get_all_sorted(where => [ output_position => $params{output_position}, requirement_spec_id => $params{requirement_spec_id} ]);
330
  my $html        = $self->render('requirement_spec_text_block/ajax_list', { output => 0 }, TEXT_BLOCKS => $text_blocks, output_position => $params{output_position});
331

  
332
  $self->js->html('#column-content', $html);
333

  
334
  if ($params{id}) {
335
    $self->js
336
     ->val('#current_content_type', 'text-blocks-' . (0 == $params{output_position} ? 'front' : 'back'))
337
     ->val('#current_content_id',   $params{id});
338
  }
339

  
340
  return $self->js;
341
}
342

  
344 343
1;

Auch abrufbar als: Unified diff