Revision 55e399ab
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/RequirementSpec.pm | ||
---|---|---|
26 | 26 |
use Rose::Object::MakeMethods::Generic |
27 | 27 |
( |
28 | 28 |
scalar => [ qw(requirement_spec_item customers types statuses db_args flat_filter visible_item visible_section) ], |
29 |
'scalar --get_set_init' => [ qw(requirement_spec complexities risks projects copy_source js) ], |
|
29 |
'scalar --get_set_init' => [ qw(requirement_spec complexities risks projects copy_source js current_text_block_output_position) ],
|
|
30 | 30 |
); |
31 | 31 |
|
32 | 32 |
__PACKAGE__->run_before('setup'); |
... | ... | |
218 | 218 |
$self->render('requirement_spec/select_template_to_paste', { layout => 0 }, TEMPLATES => \@templates); |
219 | 219 |
} |
220 | 220 |
|
221 |
sub action_paste_template { |
|
222 |
my ($self, %params) = @_; |
|
223 |
|
|
224 |
my $template = SL::DB::RequirementSpec->new(id => $::form->{template_id})->load; |
|
225 |
my %result = $self->requirement_spec->paste_template($template); |
|
226 |
|
|
227 |
return $self->js->error($self->requirement_spec->error)->render($self) if !%result; |
|
228 |
|
|
229 |
$self->render_pasted_text_block($_) for sort { $a->position <=> $b->position } @{ $result{text_blocks} }; |
|
230 |
$self->render_pasted_section($_) for sort { $a->position <=> $b->position } @{ $result{sections} }; |
|
231 |
|
|
232 |
if (@{ $result{sections} } && (($::form->{current_content_type} || 'sections') eq 'sections') && !$::form->{current_content_id}) { |
|
233 |
$self->render_first_pasted_section_as_list($result{sections}->[0]); |
|
234 |
} |
|
235 |
|
|
236 |
$self->invalidate_version->render($self); |
|
237 |
} |
|
238 |
|
|
221 | 239 |
# |
222 | 240 |
# filters |
223 | 241 |
# |
... | ... | |
263 | 281 |
$self->js(SL::ClientJS->new); |
264 | 282 |
} |
265 | 283 |
|
284 |
sub init_current_text_block_output_position { |
|
285 |
my ($self) = @_; |
|
286 |
$self->current_text_block_output_position($::form->{current_content_type} !~ m/^(?:text-blocks|tb)-(front|back)/ ? -1 : $1 eq 'front' ? 0 : 1); |
|
287 |
} |
|
288 |
|
|
266 | 289 |
sub load_select_options { |
267 | 290 |
my ($self) = @_; |
268 | 291 |
|
... | ... | |
414 | 437 |
return $self->js->html('#requirement_spec_version', $html); |
415 | 438 |
} |
416 | 439 |
|
440 |
sub render_pasted_text_block { |
|
441 |
my ($self, $text_block, %params) = @_; |
|
442 |
|
|
443 |
if ($self->current_text_block_output_position == $text_block->output_position) { |
|
444 |
my $html = $self->render('requirement_spec_text_block/_text_block', { output => 0 }, text_block => $text_block); |
|
445 |
$self->js |
|
446 |
->appendTo($html, '#text-block-list') |
|
447 |
->hide('#text-block-list-empty'); |
|
448 |
} |
|
449 |
|
|
450 |
my $node = $self->presenter->requirement_spec_text_block_jstree_data($text_block); |
|
451 |
my $front_back = $text_block->output_position == 0 ? 'front' : 'back'; |
|
452 |
$self->js |
|
453 |
->jstree->create_node('#tree', "#tb-${front_back}", 'last', $node) |
|
454 |
->jstree->open_node( '#tree', "#tb-${front_back}"); |
|
455 |
} |
|
456 |
|
|
457 |
sub render_pasted_section { |
|
458 |
my ($self, $item, $parent_id) = @_; |
|
459 |
|
|
460 |
my $node = $self->presenter->requirement_spec_item_jstree_data($item); |
|
461 |
$self->js |
|
462 |
->jstree->create_node('#tree', $parent_id ? "#fb-${parent_id}" : '#sections', 'last', $node) |
|
463 |
->jstree->open_node( '#tree', $parent_id ? "#fb-${parent_id}" : '#sections'); |
|
464 |
|
|
465 |
$self->render_pasted_section($_, $item->id) for @{ $item->children_sorted }; |
|
466 |
} |
|
467 |
|
|
468 |
sub render_first_pasted_section_as_list { |
|
469 |
my ($self, $section, %params) = @_; |
|
470 |
|
|
471 |
my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $section); |
|
472 |
$self->js |
|
473 |
->html('#column-content', $html) |
|
474 |
->val( '#current_content_type', $section->item_type) |
|
475 |
->val( '#current_content_id', $section->id) |
|
476 |
->jstree->select_node('#tree', '#fb-' . $section->id); |
|
477 |
} |
|
478 |
|
|
417 | 479 |
1; |
Auch abrufbar als: Unified diff
Pflichtenheftvorlagen einfügen