my $taxzones = SL::DB::Manager::TaxZone->get_all_sorted();
+ $self->setup_list_action_bar;
$self->render('taxzones/list',
title => t8('List of tax zones'),
TAXZONES => $taxzones);
sub show_form {
my ($self, %params) = @_;
+ $self->setup_show_form_action_bar;
$self->render('taxzones/form', %params,
BUCHUNGSGRUPPEN => SL::DB::Manager::Buchungsgruppe->get_all_sorted);
}
sub init_defaults { SL::DB::Default->get };
+#
+# helpers
+#
+
+sub setup_show_form_action_bar {
+ my ($self) = @_;
+
+ my $is_new = !$self->config->id;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'Taxzones/' . ($is_new ? 'create' : 'update') } ],
+ checks => [ 'kivi.validate_form' ],
+ accesskey => 'enter',
+ ],
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'Taxzones/delete' } ],
+ confirm => t8('Do you really want to delete this object?'),
+ disabled => $is_new ? t8('This object has not been saved yet.')
+ : !$self->config->orphaned ? t8('The object is in use and cannot be deleted.')
+ : undef,
+ ],
+
+ link => [
+ t8('Abort'),
+ link => $self->url_for(action => 'list'),
+ ],
+ );
+ }
+}
+
+sub setup_list_action_bar {
+ my ($self) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ link => [
+ t8('Add'),
+ link => $self->url_for(action => 'new'),
+ ],
+ );
+ }
+}
+
1;
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]<h1>[% HTML.escape(title) %]</h1>
[% SET style="width: 400px" %]
-<form action="controller.pl" method="post">
+<form action="controller.pl" method="post" id="form">
[%- L.hidden_tag("id", SELF.config.id) %]
<table>
<tr>
<th align="right">[% 'Description' | $T8 %]</th>
- <td>[%- L.input_tag("config.description", SELF.config.description) %]</td>
+ <td>[%- L.input_tag("config.description", SELF.config.description, "data-validate"="required", "data-title"=LxERP.t8("Description")) %]</td>
</tr>
[%- FOREACH bg = BUCHUNGSGRUPPEN %]
<tr>
</table>
[% LxERP.t8('Obsolete') %]: [% L.checkbox_tag('config.obsolete', checked = SELF.config.obsolete, for_submit=1) %]
-
- <p>
- [% L.hidden_tag("action", "Taxzones/dispatch") %]
- [% L.submit_tag("action_" _ (SELF.config.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %]
- [%- IF SELF.config.id AND SELF.config.orphaned %]
- [% L.submit_tag("action_delete", LxERP.t8('Delete'), confirm=LxERP.t8('Are you sure?')) %]
- [%- END %]
- <a href="[% SELF.url_for(action='list') %]">[%- LxERP.t8("Cancel") %]</a>
- </p>
-
- <hr>
-
-<script type="text/javascript">
-<!--
-function check_prerequisites() {
- if ($('#config_description').val() === "") {
- alert(kivi.t8('The description is missing.'));
- return false;
- }
-
- return true;
-}
--->
-</script>
</form>