Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d90408d8

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID d90408d8d3aa5db131d333144b5ef7c1bd372b2a
  • Vorgänger 51fec310
  • Nachfolger 603481b2

Pflichtenhefte: nach Änderung an Textblöcken Version invalidieren

Unterschiede anzeigen:

SL/Controller/RequirementSpecTextBlock.pm
16 16

  
17 17
use Rose::Object::MakeMethods::Generic
18 18
(
19
  scalar                  => [ qw(requirement_spec text_block) ],
19
  scalar                  => [ qw(text_block) ],
20 20
  'scalar --get_set_init' => [ qw(predefined_texts) ],
21 21
);
22 22

  
......
79 79
  my $id_base = join('_', 'new_text_block', Time::HiRes::gettimeofday(), int rand 1000000000000);
80 80
  my $html    = $self->render('requirement_spec_text_block/_form', { output => 0 }, id_base => $id_base, insert_after => $::form->{id});
81 81

  
82
  $js->action($::form->{id} ? 'insertAfter' : 'appendTo', $html, '#text-block-' . ($::form->{id} || 'list'))
82
  $self->invalidate_version($js)
83
     ->action($::form->{id} ? 'insertAfter' : 'appendTo', $html, '#text-block-' . ($::form->{id} || 'list'))
83 84
     ->focus('#' . $id_base . '_title')
84 85
     ->render($self);
85 86
}
......
124 125
  my $html = $self->render('requirement_spec_text_block/_text_block', { output => 0 }, text_block => $self->text_block);
125 126
  my $node = $self->presenter->requirement_spec_text_block_jstree_data($self->text_block);
126 127

  
127
  SL::ClientJS->new
128
  $self->invalidate_version
128 129
    ->replaceWith('#' . $::form->{form_prefix} . '_form', $html)
129 130
    ->jstree->create_node('#tree', $insert_after ? ('#tb-' . $insert_after, 'after') : ('#tb-' . ($attributes->{output_position} == 0 ? 'front' : 'back'), 'last'), $node)
130 131
    ->jstree->select_node('#tree', '#tb-' . $self->text_block->id)
......
148 149

  
149 150
  my $html = $self->render('requirement_spec_text_block/_text_block', { output => 0 }, text_block => $self->text_block);
150 151

  
151
  SL::ClientJS->new
152
  $self->invalidate_version
152 153
    ->remove('#' . $prefix . '_form')
153 154
    ->replaceWith('#text-block-' . $self->text_block->id, $html)
154 155
    ->jstree->rename_node('#tree', '#tb-' . $self->text_block->id, $self->text_block->title)
......
170 171

  
171 172
  $self->text_block->delete;
172 173

  
173
  $js->jstree->delete_node('#tree', '#tb-' . $self->text_block->id)
174
  $self->invalidate_version($js)
175
     ->jstree->delete_node('#tree', '#tb-' . $self->text_block->id)
174 176
     ->render($self);
175 177
}
176 178

  
......
205 207

  
206 208
  # $::lxdebug->dump(0, "form", $::form);
207 209

  
208
  return $self->render(\'', { type => 'json' }) if $::form->{current_content_type} !~ m/^text-block/;
210
  return $self->invalidate_version->render($self) if $::form->{current_content_type} !~ m/^text-block/;
209 211

  
210 212
  my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type}) // -1;
211 213
  my $new_where     = $self->text_block->output_position;
......
246 248
    }
247 249
  }
248 250

  
249
  $self->render($js);
251
  $self->invalidate_version($js)
252
    ->render($self);
250 253
}
251 254

  
252 255
sub action_ajax_copy {
......
281 284
  }
282 285

  
283 286
  my $node = $self->presenter->requirement_spec_text_block_jstree_data($self->text_block);
284
  $js->jstree->create_node('#tree', $::form->{id} ? ('#tb-' . $::form->{id}, 'after') : ("#tb-${front_back}", 'last'), $node)
285
     ->render($self);
287
  $self->invalidate_version($js)
288
    ->jstree->create_node('#tree', $::form->{id} ? ('#tb-' . $::form->{id}, 'after') : ("#tb-${front_back}", 'last'), $node)
289
    ->render($self);
286 290
}
287 291

  
288 292
#
289 293
# filters
290 294
#
291 295

  
292
sub load_requirement_spec {
293
  my ($self) = @_;
294
  $self->requirement_spec(SL::DB::RequirementSpec->new(id => $::form->{requirement_spec_id})->load || die "No such requirement spec");
295
}
296

  
297 296
sub load_requirement_spec_text_block {
298 297
  my ($self) = @_;
299 298
  $self->text_block(SL::DB::RequirementSpecTextBlock->new(id => $::form->{id})->load || die "No such requirement spec text block");
......
320 319
  return SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted;
321 320
}
322 321

  
322
sub invalidate_version {
323
  my ($self, $js) = @_;
324

  
325
  $js           ||= SL::ClientJS->new;
326
  my $html        = $self->render('requirement_spec/_version', { output => 0 },
327
                                  requirement_spec => SL::DB::RequirementSpec->new(id => $::form->{requirement_spec_id} || $self->text_block->requirement_spec_id)->load);
328
  return $js->html('#requirement_spec_version', $html);
329
}
330

  
323 331
1;

Auch abrufbar als: Unified diff