Revision e822adb3
Von Moritz Bunkus vor etwa 10 Jahren hinzugefügt
SL/Controller/RequirementSpec.pm | ||
---|---|---|
265 | 265 |
$self->invalidate_version->render($self); |
266 | 266 |
} |
267 | 267 |
|
268 |
sub action_renumber_sections { |
|
269 |
my ($self) = @_; |
|
270 |
|
|
271 |
my %numbers = map { ($_ => 1) } qw(section function_block); |
|
272 |
my %formats = map { my $method = "${_}_number_format"; ($_ => $self->requirement_spec->type->$method) } qw(section function_block); |
|
273 |
my @items = @{ $self->requirement_spec->sections_sorted }; |
|
274 |
|
|
275 |
$self->requirement_spec->db->with_transaction(sub { |
|
276 |
while (@items) { |
|
277 |
my $item = shift @items; |
|
278 |
my $type = $item->parent_id ? 'function_block' : 'section'; |
|
279 |
|
|
280 |
$item->update_attributes(fb_number => SL::PrefixedNumber->new(number => $formats{$type} || 0)->set_to($numbers{$type})); |
|
281 |
|
|
282 |
$numbers{$type}++; |
|
283 |
|
|
284 |
unshift @items, @{ $item->children_sorted }; |
|
285 |
} |
|
286 |
|
|
287 |
$self->requirement_spec->invalidate_version unless $self->requirement_spec->is_template; |
|
288 |
|
|
289 |
1; |
|
290 |
}); |
|
291 |
|
|
292 |
$self->redirect_to(action => 'show', id => $self->requirement_spec->id); |
|
293 |
} |
|
294 |
|
|
268 | 295 |
# |
269 | 296 |
# filters |
270 | 297 |
# |
Auch abrufbar als: Unified diff
Pflichtenhefte: Funktion Abschnitte/Funktionsblöcke neu nummerieren