Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4f5ea8fb

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 4f5ea8fb2c1a3937b704a17f34d4004aa2d1c473
  • Vorgänger 4119b9b5
  • Nachfolger 7d66fb87

Pflichtenhefversion nach Änderung an Items invalidieren

Unterschiede anzeigen:

SL/Controller/RequirementSpecItem.pm
96 96
  my $new_type            = $self->item->item_type;
97 97
  my $new_visible_section = SL::DB::RequirementSpecItem->new(id => $self->visible_item->id)->load->section;
98 98

  
99
  return $self->render($self->js) if !$old_visible_section || ($new_type eq 'section');
99
  return $self->invalidate_version->render($self) if !$old_visible_section || ($new_type eq 'section');
100 100

  
101 101
  # From here on $old_visible_section is definitely set.
102 102

  
......
108 108

  
109 109
  if ($old_visible_section->id != $new_visible_section->id) {
110 110
    # The currently visible item has been dragged to a different section.
111
    $self->invalidate_version;
111 112
    return $self->render_list($new_section, $self->item)
112 113
      ->render($self);
113 114
  }
......
131 132

  
132 133
  # $::lxdebug->dump(0, "js", $self->js->to_array);
133 134

  
134
  $self->render($self->js);
135
  $self->invalidate_version->render($self);
135 136
}
136 137

  
137 138
sub action_ajax_add_section {
......
181 182

  
182 183
  if ($type eq 'section') {
183 184
    my $node = $self->presenter->requirement_spec_item_jstree_data($self->item);
185
    $self->invalidate_version;
184 186
    return $self->render_list($self->item)
185 187
      ->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#sections', 'last'), $node)
186 188
      ->jstree->select_node('#tree', '#fb-' . $self->item->id)
......
199 201

  
200 202
  $self->replace_bottom($self->item->parent) if $type eq 'sub-function-block';
201 203

  
202
  $self->js->render($self);
204
  $self->invalidate_version->render($self);
203 205
}
204 206

  
205 207
sub action_ajax_edit {
......
271 273

  
272 274
    my $html = $self->render('requirement_spec_item/_section_header', { output => 0 }, requirement_spec_item => $self->item);
273 275

  
274
    return $self->js
276
    return $self->invalidate_version
275 277
      ->remove('#edit_section_form')
276 278
      ->html('#section-header-' . $self->item->id, $html)
277 279
      ->show('#section-header-' . $self->item->id)
......
295 297
  $self->replace_bottom($self->item, id_prefix => $id_prefix);
296 298
  $self->replace_bottom($self->item->parent) if $type eq 'sub-function-block';
297 299

  
298
  $self->js->render($self);
300
  $self->invalidate_version->render($self);
299 301
}
300 302

  
301 303
sub action_ajax_delete {
......
338 340
    }
339 341
  }
340 342

  
341
  $self->js->jstree->delete_node('#tree', '#fb-' . $self->item->id)
342
           ->render($self);
343
  $self->invalidate_version
344
    ->jstree->delete_node('#tree', '#fb-' . $self->item->id)
345
    ->render($self);
343 346
}
344 347

  
345 348
sub action_ajax_flag {
......
457 460
  # Update the current view if required.
458 461
  $self->insert_new_item_in_section_view($self->js) if $self->is_item_visible;
459 462

  
460
  $self->js->render($self);
463
  $self->invalidate_version->render($self);
461 464
}
462 465

  
463 466
#
......
469 472
  $::auth->assert('sales_quotation_edit');
470 473
}
471 474

  
472
sub load_requirement_spec {
473
  my ($self) = @_;
474
  $self->requirement_spec(SL::DB::RequirementSpec->new(id => $::form->{requirement_spec_id})->load || die "No such requirement spec");
475
}
476

  
477 475
sub load_requirement_spec_item {
478 476
  my ($self) = @_;
479
  $self->item(SL::DB::RequirementSpecItem->new(id => $::form->{id})->load || die "No such requirement spec item");
477
  $self->item(SL::DB::RequirementSpecItem->new(id => $::form->{id})->load);
480 478
}
481 479

  
482 480
#
......
616 614
  return $self->visible_section && ($self->visible_section->id == $item->section->id);
617 615
}
618 616

  
617
sub invalidate_version {
618
  my ($self) = @_;
619

  
620
  my $html   = $self->render('requirement_spec/_version', { output => 0 },
621
                             requirement_spec => SL::DB::RequirementSpec->new(id => $::form->{requirement_spec_id} || $self->item->requirement_spec_id)->load);
622
  return $self->js->html('#requirement_spec_version', $html);
623
}
624

  
619 625
1;
SL/DB/RequirementSpecItem.pm
3 3
use strict;
4 4

  
5 5
use Carp;
6
use List::MoreUtils qw(any);
7
use Rose::DB::Object::Helpers;
8
use Rose::DB::Object::Util;
6 9

  
7 10
use SL::DB::MetaSetup::RequirementSpecItem;
8 11
use SL::DB::Manager::RequirementSpecItem;
......
38 41
__PACKAGE__->attr_duration(qw(time_estimation));
39 42

  
40 43
__PACKAGE__->before_save(\&_before_save_create_fb_number);
44
__PACKAGE__->before_save(\  &_before_save_invalidate_requirement_spec_version);
41 45
__PACKAGE__->before_delete(\&_before_delete_delete_children);
46
__PACKAGE__->before_delete(\&_before_delete_invalidate_requirement_spec_version);
42 47

  
43 48
sub _before_delete_delete_children {
44 49
  my ($self) = @_;
......
70 75
  return 1;
71 76
}
72 77

  
78
sub _before_save_invalidate_requirement_spec_version {
79
  my ($self, %params) = @_;
80

  
81
  return 1 if !$self->requirement_spec_id;
82

  
83
  my %changed_columns = map { $_ => 1 } (Rose::DB::Object::Helpers::dirty_columns($self));
84
  my $has_changed     = !Rose::DB::Object::Util::is_in_db($self);
85
  $has_changed      ||= any { $changed_columns{$_} } qw(requirement_spec_id parent_id position fb_number title description);
86

  
87
  if (!$has_changed && $self->id) {
88
    my $old_item = SL::DB::RequirementSpecItem->new(id => $self->id)->load;
89
    $has_changed = join(':', sort map { $_->id } @{ $self->dependencies }) ne join(':', sort map { $_->id } @{ $old_item->dependencies });
90
  }
91

  
92
  $self->requirement_spec->invalidate_version if $has_changed;
93

  
94
  return 1;
95
}
96

  
97
sub _before_delete_invalidate_requirement_spec_version {
98
  my ($self, %params) = @_;
99

  
100
  $self->requirement_spec->invalidate_version if $self->requirement_spec_id;
101

  
102
  return 1;
103
}
104

  
73 105
sub validate {
74 106
  my ($self) = @_;
75 107

  

Auch abrufbar als: Unified diff