ActionBar: Verwendung bei »Steuern«
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 31 Jan 2017 14:39:10 +0000 (15:39 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 28 Feb 2017 09:44:03 +0000 (10:44 +0100)
bin/mozilla/am.pl
templates/webpages/am/edit_tax.html
templates/webpages/am/list_tax.html

index a62fa15..30c7870 100644 (file)
@@ -1110,10 +1110,10 @@ sub add_tax {
   $form->{expense}    = 1;
   $form->{costs}      = 1;
 
+  setup_am_edit_tax_action_bar();
   $form->header();
 
   my $parameters_ref = {
-#    ChartTypeIsAccount         => $ChartTypeIsAccount,
     LANGUAGES => SL::DB::Manager::Language->get_all_sorted,
   };
 
@@ -1147,6 +1147,7 @@ sub edit_tax {
 
   $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
 
+  setup_am_edit_tax_action_bar();
   $form->header();
 
   my $parameters_ref = {
@@ -1177,13 +1178,11 @@ sub list_tax {
 
   $form->{title} = $locale->text('Tax-O-Matic');
 
+  setup_am_list_tax_action_bar();
   $form->header();
 
-  my $parameters_ref = {
-  };
-
   # Ausgabe des Templates
-  print($form->parse_html_template('am/list_tax', $parameters_ref));
+  print($form->parse_html_template('am/list_tax'));
 
   $main::lxdebug->leave_sub();
 }
@@ -1428,3 +1427,39 @@ sub setup_am_edit_account_action_bar {
     );
   }
 }
+
+sub setup_am_list_tax_action_bar {
+  my %params = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      link => [
+        t8('Add'),
+        link => 'am.pl?action=add_tax',
+      ],
+    );
+  }
+}
+
+sub setup_am_edit_tax_action_bar {
+  my %params = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Save'),
+        submit    => [ '#form', { action => "save_tax" } ],
+        accesskey => 'enter',
+      ],
+
+      action => [
+        t8('Delete'),
+        submit   => [ '#form', { action => "delete_tax" } ],
+        disabled => !$::form->{id}                                      ? t8('The object has not been saved yet.')
+                  : !$::form->{orphaned} || $::form->{tax_already_used} ? t8('The object is in use and cannot be deleted.')
+                  :                                                       undef,
+        confirm  => t8('Do you really want to delete this object?'),
+      ],
+    );
+  }
+}
index 46c45d8..616ac2d 100644 (file)
@@ -4,7 +4,7 @@
 [%- USE LxERP %]
 <h1>[% 'Tax-O-Matic' | $T8 %] [% title %]</h1>
 
- <form method="post" action="am.pl">
+ <form method="post" action="am.pl" id="form">
   <input type="hidden" name="id" value="[% HTML.escape(id) %]">
   <input type="hidden" name="type" value="tax">
 
   [% END %]
 
   <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
-
-  <input type="submit" class="submit" name="action" value="[% 'Save' | $T8 %]">
-
-  [% IF orphaned AND NOT tax_already_used %]
-  <input type="submit" class="submit" name="action" value="[% 'Delete' | $T8 %]">
-  [% END %]
-
 </form>
-
index 836cca3..4b8ed2d 100644 (file)
@@ -25,7 +25,3 @@
   </tr>
   [% END %]
  </table>
-
- <p>
-  <a href="am.pl?action=add&type=tax&callback=[% HTML.url(callback) %]">[%- 'Add' | $T8 %]</a>
- </p>