commit 1df575c423b18dfd12ba1e4da86b5bfb26239c41
Author: Moritz Bunkus <m.bunkus@linet.de>
Date:   Tue Feb 28 15:34:13 2017 +0100

    ActionBar: Verwendung bei »Aktuelle Hintergrund-Jobs anzeigen«

diff --git a/SL/Controller/BackgroundJob.pm b/SL/Controller/BackgroundJob.pm
index 3e89ecc02..33da8b138 100644
--- a/SL/Controller/BackgroundJob.pm
+++ b/SL/Controller/BackgroundJob.pm
@@ -28,6 +28,7 @@ __PACKAGE__->run_before('load_background_job', only => [ qw(edit update destroy
 sub action_list {
   my ($self) = @_;
 
+  $self->setup_list_action_bar;
   $self->render('background_job/list',
                 title           => $::locale->text('Background jobs'),
                 BACKGROUND_JOBS => $self->models->get,
@@ -38,6 +39,7 @@ sub action_new {
   my ($self) = @_;
 
   $self->background_job(SL::DB::BackgroundJob->new(cron_spec => '* * * * *',  package_name => 'Test'));
+  $self->setup_form_action_bar;
   $self->render('background_job/form',
                 title       => $::locale->text('Create a new background job'),
                 JOB_CLASSES => [ SL::BackgroundJob::Base->get_known_job_classes ]);
@@ -46,6 +48,7 @@ sub action_new {
 sub action_edit {
   my ($self) = @_;
 
+  $self->setup_form_action_bar;
   $self->render('background_job/form',
                 title       => $::locale->text('Edit background job'),
                 JOB_CLASSES => [ SL::BackgroundJob::Base->get_known_job_classes ]);
@@ -183,4 +186,66 @@ sub init_models {
   );
 }
 
+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'),
+        accesskey => 'enter',
+      ],
+      link => [
+        t8('Server control'),
+        link => $self->url_for(controller => 'TaskServer', action => 'show'),
+      ],
+      link => [
+        t8('Job history'),
+        link => $self->url_for(controller => 'BackgroundJobHistory', action => 'list'),
+      ],
+    );
+  }
+}
+
+sub setup_form_action_bar {
+  my ($self) = @_;
+
+  my $is_new = !$self->background_job->id;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      combobox => [
+        action => [
+          t8('Save'),
+          submit    => [ '#form', { action => 'BackgroundJob/' . ($is_new ? 'create' : 'update') } ],
+          accesskey => 'enter',
+        ],
+        action => [
+          t8('Save and execute'),
+          submit => [ '#form', { action => 'BackgroundJob/save_and_execute' } ],
+        ],
+      ], # end of combobox "Save"
+
+      action => [
+        t8('Delete'),
+        submit   => [ '#form', { action => 'BackgroundJob/delete' } ],
+        confirm  => t8('Do you really want to delete this object?'),
+        disabled => $is_new ? t8('This object has not been saved yet.') : undef,
+      ],
+
+      link => [
+        t8('Abort'),
+        link => $self->url_for(action => 'list'),
+      ],
+
+      link => [
+        t8('Job history'),
+        link     => $self->url_for(controller => 'BackgroundJobHistory', action => 'list', 'filter.package_name:substr::ilike' => $self->background_job->package_name),
+        disabled => $is_new ? t8('This object has not been saved yet.') : undef,
+      ],
+    );
+  }
+}
+
 1;
diff --git a/locale/de/all b/locale/de/all
index f5c5694cb..0f58ecbf5 100755
--- a/locale/de/all
+++ b/locale/de/all
@@ -300,7 +300,6 @@ $self->{texts} = {
   'Ar aging on %s'              => 'Offene Forderungen zum %s',
   'Are you sure to generate cb/ob transactions?' => 'Sollen die EB/SB Buchungen wirklich erzeugt werden?',
   'Are you sure you want to delete Invoice Number' => 'Soll die Rechnung mit folgender Nummer wirklich gelöscht werden:',
-  'Are you sure you want to delete this background job?' => 'Sind Sie sicher, dass Sie diesen Hintergrund-Job löschen möchten?',
   'Are you sure you want to delete this delivery term?' => 'Wollen Sie diese Lieferbedingungen wirklich löschen?',
   'Are you sure you want to delete this letter?' => 'Sind Sie sicher, dass Sie diesen Brief löschen wollen?',
   'Are you sure you want to delete this payment term?' => 'Wollen Sie diese Zahlungsbedingungen wirklich löschen?',
@@ -712,7 +711,6 @@ $self->{texts} = {
   'Create invoice'              => 'Buchung erstellen',
   'Create invoice?'             => 'Rechnung erstellen?',
   'Create new'                  => 'Neu erfassen',
-  'Create new background job'   => 'Neuen Hintergrund-Job anlegen',
   'Create new client #1'        => 'Neuen Mandanten #1 anlegen',
   'Create new delivery term'    => 'Neue Lieferbedingungen anlegen',
   'Create new payment term'     => 'Neue Zahlungsbedingung anlegen',
@@ -1274,7 +1272,6 @@ $self->{texts} = {
   'Exchangerate Difference'     => 'Wechselkursunterschied',
   'Exchangerate for payment missing!' => 'Es fehlt der Wechselkurs für die Bezahlung!',
   'Exchangerate missing!'       => 'Es fehlt der Wechselkurs!',
-  'Execute now'                 => 'Jetzt ausführen',
   'Executed'                    => 'Ausgeführt',
   'Execution date'              => 'Ausführungsdatum',
   'Execution date from'         => 'Ausführungsdatum von',
@@ -2598,6 +2595,7 @@ $self->{texts} = {
   'September'                   => 'September',
   'Serial No.'                  => 'Seriennummer',
   'Serial Number'               => 'Seriennummer',
+  'Server control'              => 'Serversteuerung',
   'Service'                     => 'Dienstleistung',
   'Service (typeabbreviation)'  => 'D',
   'Service Items'               => 'Dienstleistungen',
@@ -2664,7 +2662,6 @@ $self->{texts} = {
   'Show fields used for the best before date?' => 'Felder zur Eingabe des Mindesthaltbarkeitsdatums anzeigen?',
   'Show follow ups...'          => 'Zeige Wiedervorlagen...',
   'Show help text'              => 'Hilfetext anzeigen',
-  'Show history'                => 'Verlauf anzeigen',
   'Show images'                 => 'Bilder zeigen',
   'Show items from invoices individually' => 'Artikel aus Rechnungen anzeigen',
   'Show mappings (csv_import)'  => 'Spaltenzuordnungen anzeigen',
@@ -3485,7 +3482,6 @@ $self->{texts} = {
   'Versions'                    => 'Versionen',
   'View SEPA export'            => 'SEPA-Export-Details ansehen',
   'View background job execution result' => 'Verlauf der Hintergrund-Job-Ausführungen anzeigen',
-  'View background job history' => 'Hintergrund-Job-Verlauf anzeigen',
   'View background jobs'        => 'Hintergrund-Jobs anzeigen',
   'View sent email'             => 'Verschickte E-Mail anzeigen',
   'View warehouse content'      => 'Lagerbestand ansehen',
diff --git a/templates/webpages/background_job/form.html b/templates/webpages/background_job/form.html
index 81bf0e707..f7170ec4e 100644
--- a/templates/webpages/background_job/form.html
+++ b/templates/webpages/background_job/form.html
@@ -4,7 +4,10 @@
 
 [%- INCLUDE 'common/flash.html' %]
 
- <form method="post" action="controller.pl">
+ <form method="post" action="controller.pl" id="form">
+  [% L.hidden_tag("id", SELF.background_job.id) %]
+  [% L.hidden_tag("back_to", SELF.back_to) %]
+
   <table>
    <tr>
     <th align="right">[%- LxERP.t8('Active') %]</th>
@@ -38,21 +41,4 @@
    </tr>
 
   </table>
-
-  <p>
-   [% L.hidden_tag("id", SELF.background_job.id) %]
-   [% L.hidden_tag("back_to", SELF.back_to) %]
-   [% L.hidden_tag("action", "BackgroundJob/dispatch") %]
-   [% L.submit_tag("action_" _  (SELF.background_job.id ? "update" : "create"), LxERP.t8('Save')) %]
-   [%- IF SELF.background_job.id %]
-    [% L.submit_tag("action_execute", LxERP.t8("Execute now")) %]
-    [% L.submit_tag("action_destroy", LxERP.t8("Delete"), "confirm", LxERP.t8("Are you sure you want to delete this background job?")) %]
-   [%- ELSE %]
-    [% L.submit_tag("action_save_and_execute", LxERP.t8("Save and execute")) %]
-   [%- END %]
-   <a href="[% SELF.url_for(action => 'list') %]">[%- LxERP.t8('Abort') %]</a>
-   [%- IF SELF.background_job.id %]
-    <a href="[% SELF.url_for(controller='BackgroundJobHistory', action='list', 'filter.package_name:substr::ilike'=SELF.background_job.package_name) %]">[%- LxERP.t8('Show history') %]</a>
-   [%- END %]
-  </p>
  </form>
diff --git a/templates/webpages/background_job/list.html b/templates/webpages/background_job/list.html
index b3d53eaa4..f5668daa1 100644
--- a/templates/webpages/background_job/list.html
+++ b/templates/webpages/background_job/list.html
@@ -4,7 +4,6 @@
 
 [%- INCLUDE 'common/flash.html' %]
 
- <form method="post" action="controller.pl">
   [% IF !BACKGROUND_JOBS.size %]
    <p>
     [%- LxERP.t8('No background job has been created yet.') %]
@@ -64,14 +63,3 @@
   [%- END %]
 
   [% L.paginate_controls %]
-
-  <hr size="3" noshade>
-
-  <p>
-   <a href="[% SELF.url_for(action => 'new', back_to => SELF.get_callback) %]">[%- LxERP.t8('Create new background job') %]</a>
-   |
-   <a href="[% SELF.url_for(controller => 'BackgroundJobHistory', action => 'list') %]">[%- LxERP.t8('View background job history') %]</a>
-   |
-   <a href="[% SELF.url_for(controller => 'TaskServer', action => 'show') %]">[%- LxERP.t8('Task server control') %]</a>
-  </p>
- </form>
