Revision a34bdbf7
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
SL/Controller/SimpleSystemSetting.pm | ||
---|---|---|
250 | 250 |
sub action_list { |
251 | 251 |
my ($self) = @_; |
252 | 252 |
|
253 |
$self->setup_list_action_bar; |
|
253 | 254 |
$self->render('simple_system_setting/list', title => $self->config->{titles}->{list}); |
254 | 255 |
} |
255 | 256 |
|
... | ... | |
377 | 378 |
|
378 | 379 |
my $sub_form_template = SL::System::Process->exe_dir . '/templates/webpages/simple_system_setting/_' . $self->type . '_form.html'; |
379 | 380 |
|
381 |
$self->setup_render_form_action_bar; |
|
380 | 382 |
$self->render( |
381 | 383 |
'simple_system_setting/form', |
382 | 384 |
%params, |
... | ... | |
409 | 411 |
$self->{dateformats} = [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ]; |
410 | 412 |
} |
411 | 413 |
|
414 |
# |
|
415 |
# action bar |
|
416 |
# |
|
417 |
|
|
418 |
sub setup_list_action_bar { |
|
419 |
my ($self, %params) = @_; |
|
420 |
|
|
421 |
for my $bar ($::request->layout->get('actionbar')) { |
|
422 |
$bar->add( |
|
423 |
link => [ |
|
424 |
t8('Add'), |
|
425 |
link => $self->url_for(action => 'new', type => $self->type), |
|
426 |
], |
|
427 |
); |
|
428 |
} |
|
429 |
} |
|
430 |
|
|
431 |
sub setup_render_form_action_bar { |
|
432 |
my ($self) = @_; |
|
433 |
|
|
434 |
my $is_new = !$self->object->id; |
|
435 |
my $can_be_deleted = !$is_new |
|
436 |
&& (!$self->object->can("orphaned") || $self->object->orphaned) |
|
437 |
&& (!$self->object->can("can_be_deleted") || $self->object->can_be_deleted); |
|
438 |
|
|
439 |
for my $bar ($::request->layout->get('actionbar')) { |
|
440 |
$bar->add( |
|
441 |
action => [ |
|
442 |
t8('Save'), |
|
443 |
submit => [ '#form', { action => 'SimpleSystemSetting/' . ($is_new ? 'create' : 'update') } ], |
|
444 |
checks => [ 'kivi.validate_form' ], |
|
445 |
accesskey => 'enter', |
|
446 |
], |
|
447 |
|
|
448 |
action => [ |
|
449 |
t8('Delete'), |
|
450 |
submit => [ '#form', { action => 'SimpleSystemSetting/delete' } ], |
|
451 |
confirm => t8('Do you really want to delete this object?'), |
|
452 |
disabled => $is_new ? t8('This object has not been saved yet.') |
|
453 |
: !$can_be_deleted ? t8('The object is in use and cannot be deleted.') |
|
454 |
: undef, |
|
455 |
], |
|
456 |
|
|
457 |
link => [ |
|
458 |
t8('Abort'), |
|
459 |
link => $self->list_url, |
|
460 |
], |
|
461 |
); |
|
462 |
} |
|
463 |
} |
|
464 |
|
|
412 | 465 |
1; |
413 | 466 |
|
414 | 467 |
__END__ |
templates/webpages/simple_system_setting/form.html | ||
---|---|---|
14 | 14 |
|
15 | 15 |
[%- SET sub_file = "simple_system_setting/_" _ sub_form_template _ "_form.html"; |
16 | 16 |
INCLUDE $sub_file %] |
17 |
|
|
18 |
<p> |
|
19 |
[% L.hidden_tag("action", "SimpleSystemSetting/dispatch") %] |
|
20 |
[% L.submit_tag("action_" _ (SELF.object.id ? "update" : "create"), LxERP.t8("Save"), onclick="return kivi.validate_form('#form');") %] |
|
21 |
[%- IF SELF.object.id && (!SELF.object.can("orphaned") || SELF.object.orphaned) && (!SELF.object.can("can_be_deleted") || SELF.object.can_be_deleted) -%] |
|
22 |
[% L.submit_tag("action_delete", LxERP.t8("Delete"), confirm=LxERP.t8("Do you really want to delete this object?")) %] |
|
23 |
[%- END %] |
|
24 |
<a href="[% SELF.list_url %]">[%- LxERP.t8("Cancel") %]</a> |
|
25 |
</p> |
|
26 | 17 |
</form> |
templates/webpages/simple_system_setting/list.html | ||
---|---|---|
40 | 40 |
</tbody> |
41 | 41 |
</table> |
42 | 42 |
|
43 |
<hr height="3"> |
|
44 |
|
|
45 |
<p> |
|
46 |
<a href="[% SELF.url_for(action="new", type=SELF.type) %]">[%- "Add" | $T8 %]</a> |
|
47 |
</p> |
|
48 |
|
|
49 | 43 |
[% IF SELF.supports_reordering %] |
50 | 44 |
[% L.sortable_element("#object_list tbody", url=SELF.url_for(action="reorder", type=SELF.type), with="object_id") %] |
51 | 45 |
[% END %] |
Auch abrufbar als: Unified diff
ActionBar: Verwendung im »SimpleSystemSetting«-Controller