my $configs = SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => $self->module ]);
+ $self->setup_list_action_bar;
$::form->header;
$self->render('custom_variable_config/list',
title => t8('List of custom variables'),
$params{all_partsgroups} = SL::DB::Manager::PartsGroup->get_all();
$::request->layout->use_javascript("${_}.js") for qw(jquery.selectboxes jquery.multiselect2side);
+ $self->setup_form_action_bar;
$self->render('custom_variable_config/form', %params);
}
}
}
+sub setup_list_action_bar {
+ my ($self) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Add'),
+ link => $self->url_for(action => 'new', module => $self->module),
+ ],
+ );
+ }
+}
+
+sub setup_form_action_bar {
+ my ($self) = @_;
+
+ my $is_new = !$self->config->id;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ combobox => [
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'CustomVariableConfig/' . ($is_new ? 'create' : 'update') } ],
+ checks => [ 'check_prerequisites' ],
+ accesskey => 'enter',
+ ],
+
+ action => [
+ t8('Save as new'),
+ submit => [ '#form', { action => 'CustomVariableConfig/create'} ],
+ checks => [ 'check_prerequisites' ],
+ not_if => $is_new,
+ ],
+ ], # end of combobox "Save"
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'CustomVariableConfig/destroy' } ],
+ confirm => t8('Do you really want to delete this object?'),
+ disabled => $is_new ? t8('This object has not been saved yet.') : undef,
+ ],
+
+ 'separator',
+
+ link => [
+ t8('Abort'),
+ link => $self->url_for(action => 'list', module => $self->module),
+ ],
+ );
+ }
+}
+
1;
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]<h1>[% HTML.escape(title) %]</h1>
-<form action="controller.pl" method="post">
+<form action="controller.pl" method="post" id="form">
[%- L.hidden_tag("id", SELF.config.id) %]
<p>
</table>
</p>
- <p>
- [% L.hidden_tag("action", "CustomVariableConfig/dispatch") %]
- [% L.submit_tag("action_" _ (SELF.config.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %]
- [%- IF SELF.config.id %]
- [% L.submit_tag("action_create", LxERP.t8('Save as new'), onclick="return check_prerequisites();") %]
- [% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Are you sure?')) %]
- [%- END %]
- <a href="[% SELF.url_for(action='list', module=SELF.module) %]">[%- LxERP.t8("Cancel") %]</a>
- </p>
-
<hr>
<h3>[% 'Annotations' | $T8 %]</h3>