commit 5e8c9df6674e4174d3e9701a1ae1021ada07dac0
Author: Moritz Bunkus <m.bunkus@linet.de>
Date:   Tue Jan 31 11:41:55 2017 +0100

    ActionBar: Verwendung bei Buchungsgruppen

diff --git a/SL/Controller/Buchungsgruppen.pm b/SL/Controller/Buchungsgruppen.pm
index 4776bd640..55e0fab89 100644
--- a/SL/Controller/Buchungsgruppen.pm
+++ b/SL/Controller/Buchungsgruppen.pm
@@ -33,6 +33,7 @@ sub action_list {
       $chartlist{ $gruppe->id } = SL::DB::TaxzoneChart->get_all_accounts_by_buchungsgruppen_id($gruppe->id);
   }
 
+  $self->setup_list_action_bar;
   $::form->header;
   $self->render('buchungsgruppen/list',
                 title           => t8('Booking groups'),
@@ -51,6 +52,7 @@ sub action_new {
 sub show_form {
   my ($self, %params) = @_;
 
+  $self->setup_show_form_action_bar;
   $self->render('buchungsgruppen/form', %params,
                  TAXZONES       => SL::DB::Manager::TaxZone->get_all_sorted());
 }
@@ -188,4 +190,52 @@ sub create_or_update {
 
 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 => 'Buchungsgruppen/' . ($is_new ? 'create' : 'update') } ],
+        checks    => [ 'kivi.validate_form' ],
+        accesskey => 'enter',
+      ],
+
+      action => [
+        t8('Delete'),
+        submit   => [ '#form', { action => 'Buchungsgruppen/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;
diff --git a/templates/webpages/buchungsgruppen/form.html b/templates/webpages/buchungsgruppen/form.html
index ad9db1445..05b5e1a47 100644
--- a/templates/webpages/buchungsgruppen/form.html
+++ b/templates/webpages/buchungsgruppen/form.html
@@ -3,13 +3,13 @@
 
 <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) %]
 
 <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>
   <tr>
     <th align="right">[% 'Inventory Account' | $T8 %]</th>
@@ -44,27 +44,4 @@
   </tr>
 [%- END %]
 </table>
-
- <p>
-  [% L.hidden_tag("action", "Buchungsgruppen/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 %]
- </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>
diff --git a/templates/webpages/buchungsgruppen/list.html b/templates/webpages/buchungsgruppen/list.html
index 038b26511..319dcb927 100644
--- a/templates/webpages/buchungsgruppen/list.html
+++ b/templates/webpages/buchungsgruppen/list.html
@@ -31,11 +31,4 @@
  </table>
 </p>
 
-<hr height="3">
-
 [% L.sortable_element('#buchungsgruppen_list tbody', url=SELF.url_for(action='reorder'), with='bg_id') %]
-
-<p>
- <a href="[% SELF.url_for(action='new') %]">[%- 'Add' | $T8 %]</a>
-</p>
-
