Revision 9a71fdb6
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/RequirementSpecItem.pm | ||
---|---|---|
167 | 167 |
->render($self); |
168 | 168 |
} |
169 | 169 |
|
170 |
die 'TODO: create item'; |
|
170 |
my $template = 'requirement_spec_item/_' . (apply { s/-/_/g; $_ } $type); |
|
171 |
my $html = $self->render($template, { output => 0 }, requirement_spec_item => $self->item, id_prefix => $type eq 'function-block' ? '' : 'sub-'); |
|
172 |
my $node = $self->presenter->requirement_spec_item_jstree_data($self->item); |
|
173 |
|
|
174 |
$js->replaceWith('#' . $prefix . '_form', $html) |
|
175 |
->hide('#section-list-empty') |
|
176 |
->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#fb-' . $self->item->parent_id, 'last'), $node) |
|
177 |
->jstree->select_node('#tree', '#fb-' . $self->item->id); |
|
178 |
|
|
179 |
$self->replace_bottom($js, $self->item->parent) if $type eq 'sub-function-block'; |
|
180 |
|
|
181 |
$js->render($self); |
|
171 | 182 |
} |
172 | 183 |
|
173 | 184 |
sub action_ajax_edit { |
... | ... | |
270 | 281 |
sub action_ajax_delete { |
271 | 282 |
my ($self) = @_; |
272 | 283 |
|
273 |
my $js = SL::ClientJS->new; |
|
284 |
my $js = SL::ClientJS->new; |
|
285 |
my $full_list = $self->item->get_full_list; |
|
274 | 286 |
|
275 | 287 |
$self->item->delete; |
276 | 288 |
|
... | ... | |
297 | 309 |
|
298 | 310 |
$self->replace_bottom($js, $self->item->parent_id) if $type eq 'sub-function-block'; |
299 | 311 |
|
300 |
if (1 == scalar @{ $self->item->get_full_list }) {
|
|
312 |
if (1 == scalar @{ $full_list }) { |
|
301 | 313 |
if ($type eq 'function-block') { |
302 | 314 |
$js->show('#section-list-empty'); |
303 | 315 |
} elsif ($type eq 'sub-function-block') { |
... | ... | |
400 | 412 |
sub add_function_block { |
401 | 413 |
my ($self, $new_type) = @_; |
402 | 414 |
|
403 |
die "Invalid new_type '$new_type'" if $new_type !~ m/^(?:sub-)?function-block$/; |
|
404 |
die "Missing parameter 'id'" if !$::form->{id}; |
|
405 |
die "Missing parameter 'requirement_spec_id'" if !$::form->{requirement_spec_id}; |
|
415 |
my $clicked_id = $::form->{id} || ($self->visible_item ? $self->visible_item->id : undef); |
|
406 | 416 |
|
407 |
my $clicked_item = SL::DB::RequirementSpecItem->new(id => $::form->{id})->load; |
|
417 |
die "Invalid new_type '$new_type'" if $new_type !~ m/^(?:sub-)?function-block$/; |
|
418 |
die "Missing parameter 'id' and no visible item" if !$clicked_id; |
|
419 |
die "Missing parameter 'requirement_spec_id'" if !$::form->{requirement_spec_id}; |
|
420 |
|
|
421 |
my $clicked_item = SL::DB::RequirementSpecItem->new(id => $clicked_id)->load; |
|
408 | 422 |
my $clicked_type = $clicked_item->get_type; |
409 | 423 |
|
410 | 424 |
die "Invalid clicked_type '$clicked_type'" if $clicked_type !~ m/^(?: section | (?:sub-)? function-block )$/x; |
... | ... | |
430 | 444 |
SELECTED_DEPENDENCIES => [], |
431 | 445 |
requirement_spec_item => $self->item, |
432 | 446 |
id_base => $id_base, |
433 |
insert_after => $insert_reference,
|
|
447 |
insert_after => $insert_position eq 'insertAfter' ? $insert_reference : undef,
|
|
434 | 448 |
); |
435 | 449 |
|
436 | 450 |
my $js = SL::ClientJS->new; |
... | ... | |
449 | 463 |
# $::lxdebug->message(0, "alright! clicked ID " . $::form->{id} . " type $clicked_type new_type $new_type insert_pos $insert_position ref " . ($insert_reference // '<undef>') . " parent $parent_id display_ref $display_reference"); |
450 | 464 |
|
451 | 465 |
$js->action($insert_position, $html, $display_reference) |
452 |
->focus("#${id_base}_description") |
|
453 |
->render($self); |
|
466 |
->focus("#${id_base}_description"); |
|
467 |
|
|
468 |
$js->show('#sub-function-block-container-' . $parent_id) if $new_type eq 'sub-function-block'; |
|
469 |
|
|
470 |
$js->render($self); |
|
454 | 471 |
} |
455 | 472 |
|
456 | 473 |
1; |
js/requirement_spec.js | ||
---|---|---|
209 | 209 |
return find_item_id(opt.$trigger) == undefined; |
210 | 210 |
} |
211 | 211 |
|
212 |
function disable_add_function_block_command(key, opt) { |
|
213 |
if (find_item_id(opt.$trigger)) |
|
214 |
return false; |
|
215 |
return opt.$trigger.attr('id') != "section-list-empty"; |
|
216 |
} |
|
217 |
|
|
212 | 218 |
function submit_edit_item_form(id_base) { |
213 | 219 |
var id = $('#' + id_base + '_id').val(); |
214 | 220 |
var url = "controller.pl?" + $('#' + id_base + '_form').serialize(); |
... | ... | |
221 | 227 |
return true; |
222 | 228 |
} |
223 | 229 |
|
224 |
function cancel_edit_item_form(form_id_base, to_show) {
|
|
230 |
function cancel_edit_item_form(form_id_base, options) {
|
|
225 | 231 |
$('#' + form_id_base + '_form').remove(); |
226 |
if (to_show) |
|
227 |
$(to_show).show(); |
|
232 |
if (!options) |
|
233 |
return; |
|
234 |
if (options.to_show) |
|
235 |
$(options.to_show).show(); |
|
236 |
if (options.to_hide_if_empty && (1 == $(options.to_hide_if_empty).children().size())) |
|
237 |
$(options.to_hide_if_empty).hide(); |
|
228 | 238 |
} |
templates/webpages/requirement_spec/show.html | ||
---|---|---|
125 | 125 |
selector: '.section-context-menu', |
126 | 126 |
items: { |
127 | 127 |
add_section: { name: "[% LxERP.t8('Add section') %]", icon: "add", callback: standard_item_ajax_call }, |
128 |
add_function_block: { name: "[% LxERP.t8('Add function block') %]", icon: "add", callback: standard_item_ajax_call, disabled: disable_edit_item_commands },
|
|
128 |
add_function_block: { name: "[% LxERP.t8('Add function block') %]", icon: "add", callback: standard_item_ajax_call, disabled: disable_add_function_block_command },
|
|
129 | 129 |
sep1: "---------", |
130 | 130 |
edit: { name: "[% LxERP.t8('Edit') %]", icon: "edit", callback: standard_item_ajax_call, disabled: disable_edit_item_commands }, |
131 | 131 |
delete: { name: "[% LxERP.t8('Delete') %]", icon: "delete", callback: ask_delete_item, disabled: disable_edit_item_commands }, |
templates/webpages/requirement_spec_item/_function_block_form.html | ||
---|---|---|
1 | 1 |
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%][%- USE JavaScript -%][%- USE P -%][% SET style="width: 500px" %] |
2 | 2 |
[% DEFAULT id_base = 'edit_function_block_' _ SELF.item.id %] |
3 |
[%- SET a_options = '' %] |
|
4 |
[%- IF SELF.item.id %] |
|
5 |
[%- SET a_options = "to_show: '#" _ SELF.item.get_type _ "-content-top-" _ SELF.item.id _ "'" %] |
|
6 |
[%- END %] |
|
7 |
[%- IF SELF.item.get_type == 'sub-function-block' %] |
|
8 |
[%- SET a_options = a_options ? a_options _ ', ' : a_options %] |
|
9 |
[%- SET a_options = a_options _ "to_hide_if_empty: '#sub-function-block-container-" _ SELF.item.parent_id _ "'" %] |
|
10 |
[%- END %] |
|
3 | 11 |
<form method="post" id="[% id_base %]_form" class="function-block-form"> |
4 | 12 |
[% L.hidden_tag(id_base _ '_id', SELF.item.id) %] |
5 | 13 |
[% L.hidden_tag(id_base _ '.requirement_spec_id', SELF.item.requirement_spec_id) %] |
... | ... | |
41 | 49 |
|
42 | 50 |
<p> |
43 | 51 |
[% L.button_tag('submit_edit_item_form("' _ id_base _ '")', LxERP.t8('Save')) %] |
44 |
<a href="#" onclick="cancel_edit_item_form('[% id_base %]', '[% '#' _ SELF.item.get_type _ '-content-top-' _ SELF.item.id %]')">[%- LxERP.t8("Cancel") %]</a>
|
|
52 |
<a href="#" onclick="cancel_edit_item_form('[% id_base %]', { [% a_options %] })">[%- LxERP.t8("Cancel") %]</a>
|
|
45 | 53 |
</p> |
46 | 54 |
</form> |
templates/webpages/requirement_spec_item/_section_form.html | ||
---|---|---|
30 | 30 |
|
31 | 31 |
<p> |
32 | 32 |
[% L.button_tag('submit_edit_item_form("' _ id_base _ '")', LxERP.t8('Save')) %] |
33 |
<a href="#" onclick="cancel_edit_item_form('[% id_base %]', '[% hidden %]')">[%- LxERP.t8("Cancel") %]</a>
|
|
33 |
<a href="#" onclick="cancel_edit_item_form('[% id_base %]', { to_show: '[% hidden %]' })">[%- LxERP.t8("Cancel") %]</a>
|
|
34 | 34 |
</p> |
35 | 35 |
</form> |
Auch abrufbar als: Unified diff
Pflichtenheftitems: Neuanlegen von (Unter)Funktionsblöcken