41 |
41 |
}
|
42 |
42 |
|
43 |
43 |
my $clicked_item = SL::DB::RequirementSpecItem->new(id => $::form->{clicked_id})->load;
|
44 |
|
$self->item($clicked_item->get_section);
|
|
44 |
$self->item($clicked_item->section);
|
45 |
45 |
|
46 |
46 |
if (!$self->visible_section || ($self->visible_section->id != $self->item->id)) {
|
47 |
47 |
$self->render_list($js, $self->item, $clicked_item);
|
... | ... | |
60 |
60 |
|
61 |
61 |
my $old_visible_section = $self->visible_section ? $self->visible_section : undef;
|
62 |
62 |
my $old_parent_id = $self->item->parent_id;
|
63 |
|
my $old_type = $self->item->get_type;
|
|
63 |
my $old_type = $self->item->item_type;
|
64 |
64 |
|
65 |
65 |
$self->item->db->do_transaction(sub {
|
66 |
66 |
$self->item->remove_from_list;
|
... | ... | |
71 |
71 |
my $js = SL::ClientJS->new;
|
72 |
72 |
|
73 |
73 |
$self->item(SL::DB::RequirementSpecItem->new(id => $self->item->id)->load);
|
74 |
|
my $new_section = $self->item->get_section;
|
75 |
|
my $new_type = $self->item->get_type;
|
76 |
|
my $new_visible_section = SL::DB::RequirementSpecItem->new(id => $self->visible_item->id)->load->get_section;
|
|
74 |
my $new_section = $self->item->section;
|
|
75 |
my $new_type = $self->item->item_type;
|
|
76 |
my $new_visible_section = SL::DB::RequirementSpecItem->new(id => $self->visible_item->id)->load->section;
|
77 |
77 |
|
78 |
78 |
return $self->render($js) if !$old_visible_section || ($new_type eq 'section');
|
79 |
79 |
|
80 |
80 |
# From here on $old_visible_section is definitely set.
|
81 |
81 |
|
82 |
82 |
my $old_parent = SL::DB::RequirementSpecItem->new(id => $old_parent_id)->load;
|
83 |
|
my $old_section = $old_parent->get_section;
|
|
83 |
my $old_section = $old_parent->section;
|
84 |
84 |
|
85 |
85 |
# $::lxdebug->message(0, "old sec ID " . $old_section->id . " new " . $new_section->id . " old visible " . $old_visible_section->id . " new visible " . $new_visible_section->id
|
86 |
86 |
# . " PARENT: old " . $old_parent->id . " new " . $self->item->parent_id . '/' . $self->item->parent->id);
|
... | ... | |
115 |
115 |
if ($next_item) {
|
116 |
116 |
$js->insertBefore($html, '#' . $id_prefix . 'function-block-' . $next_item->id);
|
117 |
117 |
} else {
|
118 |
|
my $parent_is_section = $self->item->parent->get_type eq 'section';
|
|
118 |
my $parent_is_section = $self->item->parent->item_type eq 'section';
|
119 |
119 |
$js->appendTo($html, $parent_is_section ? '#section-list' : '#sub-function-block-container-' . $self->item->parent_id);
|
120 |
120 |
$js->show('#sub-function-block-container-' . $self->item->parent_id) if !$parent_is_section;
|
121 |
121 |
}
|
... | ... | |
133 |
133 |
|
134 |
134 |
die "Missing parameter 'requirement_spec_id'" if !$::form->{requirement_spec_id};
|
135 |
135 |
|
136 |
|
$self->item(SL::DB::RequirementSpecItem->new(requirement_spec_id => $::form->{requirement_spec_id}));
|
|
136 |
$self->item(SL::DB::RequirementSpecItem->new(requirement_spec_id => $::form->{requirement_spec_id}, item_type => 'section'));
|
137 |
137 |
|
138 |
|
my $insert_after = $::form->{id} ? SL::DB::RequirementSpecItem->new(id => $::form->{id})->load->get_section->id : undef;
|
|
138 |
my $insert_after = $::form->{id} ? SL::DB::RequirementSpecItem->new(id => $::form->{id})->load->section->id : undef;
|
139 |
139 |
my $html = $self->render('requirement_spec_item/_section_form', { output => 0 }, id_base => 'new_section', insert_after => $insert_after);
|
140 |
140 |
|
141 |
141 |
SL::ClientJS->new
|
... | ... | |
172 |
172 |
$self->item->save;
|
173 |
173 |
$self->item->add_to_list(position => 'after', reference => $insert_after) if $insert_after;
|
174 |
174 |
|
175 |
|
my $type = $self->item->get_type;
|
|
175 |
my $type = $self->item->item_type;
|
176 |
176 |
|
177 |
177 |
if ($type eq 'section') {
|
178 |
178 |
my $node = $self->presenter->requirement_spec_item_jstree_data($self->item);
|
... | ... | |
203 |
203 |
|
204 |
204 |
my $js = SL::ClientJS->new;
|
205 |
205 |
|
206 |
|
if (!$self->visible_section || ($self->visible_section->id != $self->item->get_section->id)) {
|
|
206 |
if (!$self->visible_section || ($self->visible_section->id != $self->item->section->id)) {
|
207 |
207 |
# Show section/item to edit if it is not visible.
|
208 |
208 |
|
209 |
209 |
my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $self->item);
|
210 |
210 |
$js->html('#column-content', $html);
|
211 |
211 |
}
|
212 |
212 |
|
213 |
|
if ($self->item->get_type =~ m/section/) {
|
|
213 |
if ($self->item->item_type =~ m/section/) {
|
214 |
214 |
# Edit the section header, not an item.
|
215 |
215 |
my $html = $self->render('requirement_spec_item/_section_form', { output => 0 });
|
216 |
216 |
|
... | ... | |
231 |
231 |
|
232 |
232 |
my $html = $self->render('requirement_spec_item/_function_block_form', { output => 0 }, DEPENDENCIES => \@dependencies, SELECTED_DEPENDENCIES => \@selected_dependencies);
|
233 |
233 |
my $id_base = 'edit_function_block_' . $self->item->id;
|
234 |
|
my $content_top_id = '#' . $self->item->get_type . '-content-top-' . $self->item->id;
|
|
234 |
my $content_top_id = '#' . $self->item->item_type . '-content-top-' . $self->item->id;
|
235 |
235 |
|
236 |
236 |
$js->hide($content_top_id)
|
237 |
237 |
->remove("#${id_base}_form")
|
238 |
238 |
->insertAfter($html, $content_top_id)
|
239 |
239 |
->jstree->select_node('#tree', '#fb-' . $self->item->id)
|
240 |
240 |
->focus("#${id_base}_description")
|
241 |
|
->val('#current_content_type', $self->item->get_type)
|
|
241 |
->val('#current_content_type', $self->item->item_type)
|
242 |
242 |
->val('#current_content_id', $self->item->id)
|
243 |
243 |
->render($self);
|
244 |
244 |
}
|
... | ... | |
259 |
259 |
|
260 |
260 |
$self->item->save;
|
261 |
261 |
|
262 |
|
my $type = $self->item->get_type;
|
|
262 |
my $type = $self->item->item_type;
|
263 |
263 |
|
264 |
264 |
if ($type eq 'section') {
|
265 |
265 |
# Updated section, now update section header.
|
... | ... | |
315 |
315 |
->val('#current_content_id', '')
|
316 |
316 |
}
|
317 |
317 |
|
318 |
|
} elsif ($self->visible_section && ($self->visible_section->id == $self->item->get_section->id)) {
|
|
318 |
} elsif ($self->visible_section && ($self->visible_section->id == $self->item->section->id)) {
|
319 |
319 |
# Item in currently visible section is deleted.
|
320 |
320 |
|
321 |
|
my $type = $self->item->get_type;
|
|
321 |
my $type = $self->item->item_type;
|
322 |
322 |
$js->remove('#edit_function_block_' . $self->item->id . '_form')
|
323 |
323 |
->remove('#' . $type . '-' . $self->item->id);
|
324 |
324 |
|
... | ... | |
342 |
342 |
|
343 |
343 |
$self->item->update_attributes(is_flagged => !$self->item->is_flagged);
|
344 |
344 |
|
345 |
|
my $is_visible = $self->visible_section && ($self->visible_section->id == $self->item->get_section->id);
|
|
345 |
my $is_visible = $self->visible_section && ($self->visible_section->id == $self->item->section->id);
|
346 |
346 |
|
347 |
347 |
SL::ClientJS->new
|
348 |
|
->action_if($is_visible, 'toggleClass', '#' . $self->item->get_type . '-' . $self->item->id, 'flagged')
|
|
348 |
->action_if($is_visible, 'toggleClass', '#' . $self->item->item_type . '-' . $self->item->id, 'flagged')
|
349 |
349 |
->toggleClass('#fb-' . $self->item->id, 'flagged')
|
350 |
350 |
->render($self);
|
351 |
351 |
}
|
... | ... | |
388 |
388 |
$self->visible_item(SL::DB::Manager::RequirementSpecItem->find_by(id => $content_id));
|
389 |
389 |
return undef unless $self->visible_item;
|
390 |
390 |
|
391 |
|
return $self->visible_section($self->visible_item->get_section);
|
|
391 |
return $self->visible_section($self->visible_item->section);
|
392 |
392 |
}
|
393 |
393 |
|
394 |
394 |
sub init_complexities {
|
... | ... | |
407 |
407 |
my ($self, $js, $item_or_id) = @_;
|
408 |
408 |
|
409 |
409 |
my $item = (ref($item_or_id) ? $item_or_id : SL::DB::RequirementSpecItem->new(id => $item_or_id))->load;
|
410 |
|
my $id_prefix = $item->get_type eq 'function-block' ? '' : 'sub-';
|
|
410 |
my $id_prefix = $item->item_type eq 'function-block' ? '' : 'sub-';
|
411 |
411 |
my $html = $self->render('requirement_spec_item/_function_block_content_bottom', { output => 0 }, requirement_spec_item => $item, id_prefix => $id_prefix);
|
412 |
412 |
return $js->replaceWith('#' . $id_prefix . 'function-block-content-bottom-' . $item->id, $html);
|
413 |
413 |
}
|
... | ... | |
422 |
422 |
sub select_node {
|
423 |
423 |
my ($self, $js, $item) = @_;
|
424 |
424 |
|
425 |
|
$js->val( '#current_content_type', $item->get_type)
|
|
425 |
$js->val( '#current_content_type', $item->item_type)
|
426 |
426 |
->val( '#current_content_id', $item->id)
|
427 |
427 |
->jstree->select_node('#tree', '#fb-' . $item->id);
|
428 |
428 |
}
|
... | ... | |
452 |
452 |
die "Missing parameter 'requirement_spec_id'" if !$::form->{requirement_spec_id};
|
453 |
453 |
|
454 |
454 |
my $clicked_item = SL::DB::RequirementSpecItem->new(id => $clicked_id)->load;
|
455 |
|
my $clicked_type = $clicked_item->get_type;
|
|
455 |
my $clicked_type = $clicked_item->item_type;
|
456 |
456 |
|
457 |
457 |
die "Invalid clicked_type '$clicked_type'" if $clicked_type !~ m/^(?: section | (?:sub-)? function-block )$/x;
|
458 |
458 |
|
... | ... | |
466 |
466 |
: $case eq 'sub-function-block:sub-function-block' ? ( 'insertAfter', $clicked_item->id, $clicked_item->parent_id, '#sub-function-block-' )
|
467 |
467 |
: die "Invalid combination of 'clicked_type (section)/new_type ($new_type)'";
|
468 |
468 |
|
469 |
|
$self->item(SL::DB::RequirementSpecItem->new(requirement_spec_id => $::form->{requirement_spec_id}, parent_id => $parent_id));
|
|
469 |
$self->item(SL::DB::RequirementSpecItem->new(requirement_spec_id => $::form->{requirement_spec_id}, parent_id => $parent_id, item_type => $new_type));
|
470 |
470 |
|
471 |
471 |
$display_reference .= $insert_reference if $display_reference =~ m/-$/;
|
472 |
472 |
my $id_base = join('_', 'new_function_block', Time::HiRes::gettimeofday(), int rand 1000000000000);
|
... | ... | |
482 |
482 |
|
483 |
483 |
my $js = SL::ClientJS->new;
|
484 |
484 |
|
485 |
|
my $new_section = $self->item->get_section;
|
|
485 |
my $new_section = $self->item->section;
|
486 |
486 |
if (!$self->visible_section || ($self->visible_section->id != $new_section->id)) {
|
487 |
487 |
# Show section/item to edit if it is not visible.
|
488 |
488 |
|
Pflichtenheftitems: Typen direkt in Tabelle speichern