]> wagnertech.de Git - kivitendo-erp.git/commitdiff
ActionBar: Auslassen von Actions über Parameter »only_if«/»not_if« steuern können
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 13 Jan 2017 09:22:12 +0000 (10:22 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 28 Feb 2017 09:43:59 +0000 (10:43 +0100)
Gedacht für Buttons, die z.B. aufgrund der Mandantenkonfiguration nie
angezeigt werden können. Nicht gedacht für Buttons, die nur aufgrund des
Belegzustands nicht benutzt werden können (z.B. »Löschen« bei einem noch
nicht gespeicherten Beleg).

SL/Layout/ActionBar/Action.pm
bin/mozilla/do.pl
bin/mozilla/ir.pl
bin/mozilla/is.pl
bin/mozilla/oe.pl

index bed33fe1c2e823afc56638beb6843387c948158b..b72314b4a79edfb0a17e1dcbfb5334616ea3fe7b 100644 (file)
@@ -25,6 +25,8 @@ sub from_params {
   my ($class, $data) = @_;
 
   my ($text, %params) = @$data;
   my ($class, $data) = @_;
 
   my ($text, %params) = @$data;
+  return if exists($params{only_if}) && !$params{only_if};
+  return if exists($params{not_if})  &&  $params{not_if};
   return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params);
 }
 
   return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params);
 }
 
index 7107017ab8c3edc63c1ac2ccbbf67cb4ca1393bb..a3c82130a82ca73e7eee26a86eb8eb4aedc16493 100644 (file)
@@ -239,6 +239,7 @@ sub prepare_order {
 sub setup_do_action_bar {
   my @transfer_qty   = qw(kivi.SalesPurchase.delivery_order_check_transfer_qty);
   my @req_trans_desc = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps;
 sub setup_do_action_bar {
   my @transfer_qty   = qw(kivi.SalesPurchase.delivery_order_check_transfer_qty);
   my @req_trans_desc = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps;
+  my $is_customer    = $::form->{vc} eq 'customer';
 
   for my $bar ($::request->layout->get('actionbar')) {
     $bar->add(
 
   for my $bar ($::request->layout->get('actionbar')) {
     $bar->add(
@@ -284,30 +285,34 @@ sub setup_do_action_bar {
       ],
 
       combobox => [
       ],
 
       combobox => [
-        (action => [
+        action => [
           t8('Transfer out'),
           submit   => [ '#form', { action => "transfer_out" } ],
           checks   => [ @req_trans_desc, @transfer_qty ],
           disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
           t8('Transfer out'),
           submit   => [ '#form', { action => "transfer_out" } ],
           checks   => [ @req_trans_desc, @transfer_qty ],
           disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
-        ]) x ($::form->{vc} eq 'customer'),
-        (action => [
+          only_if  => $is_customer,
+        ],
+        action => [
           t8('Transfer out via default'),
           submit   => [ '#form', { action => "transfer_out_default" } ],
           checks   => [ @req_trans_desc, @transfer_qty ],
           disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
           t8('Transfer out via default'),
           submit   => [ '#form', { action => "transfer_out_default" } ],
           checks   => [ @req_trans_desc, @transfer_qty ],
           disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
-        ]) x ($::form->{vc} eq 'customer' && $::instance_conf->get_transfer_default),
-        (action => [
+          only_if  => $is_customer && $::instance_conf->get_transfer_default,
+        ],
+        action => [
           t8('Transfer in'),
           submit   => [ '#form', { action => "transfer_in"> 1 } ],
           checks   => [ @req_trans_desc, @transfer_qty ],
           disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
           t8('Transfer in'),
           submit   => [ '#form', { action => "transfer_in"> 1 } ],
           checks   => [ @req_trans_desc, @transfer_qty ],
           disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
-        ]) x ($::form->{vc} eq 'vendor'),
-        (action => [
+          only_if  => !$is_customer,
+        ],
+        action => [
           t8('Transfer in via default'),
           submit   => [ '#form', { action => "transfer_in_default" } ],
           checks   => [ @req_trans_desc, @transfer_qty ],
           disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
           t8('Transfer in via default'),
           submit   => [ '#form', { action => "transfer_in_default" } ],
           checks   => [ @req_trans_desc, @transfer_qty ],
           disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
-        ]) x ($::form->{vc} eq 'vendor' && $::instance_conf->get_transfer_default),
+          only_if  => !$is_customer && $::instance_conf->get_transfer_default,
+        ],
       ], # end of combobox "Transfer out"
 
 
       ], # end of combobox "Transfer out"
 
 
index b9e79d6dedfdbc185e9dc18cdbfec047e68e499e..c649046a8b1567bf1dd4fa2ce96082af7be05ec9 100644 (file)
@@ -245,12 +245,13 @@ sub setup_ir_action_bar {
           submit   => [ '#form', { action => "post_payment" } ],
           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
         ],
           submit   => [ '#form', { action => "post_payment" } ],
           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
         ],
-        (action => [
+        action => [
           t8('Mark as paid'),
           submit   => [ '#form', { action => "mark_as_paid" } ],
           confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
           t8('Mark as paid'),
           submit   => [ '#form', { action => "mark_as_paid" } ],
           confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
-        ]) x !!$::instance_conf->get_ir_show_mark_as_paid,
+          only_if  => $::instance_conf->get_ir_show_mark_as_paid,
+        ],
       ], # end of combobox "Post"
 
       combobox => [
       ], # end of combobox "Post"
 
       combobox => [
index 6eae18e3964508ab4c6ef8a8379a78210962c4a2..6b958c25e332848794418bf7448d9101aa7d76cf 100644 (file)
@@ -285,11 +285,12 @@ sub setup_is_action_bar {
           checks   => [ @req_trans_desc ],
           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
         ],
           checks   => [ @req_trans_desc ],
           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
         ],
-        (action => [ t8('Mark as paid'),
+        action => [ t8('Mark as paid'),
           submit   => [ '#form', { action => "mark_as_paid" } ],
           confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
           submit   => [ '#form', { action => "mark_as_paid" } ],
           confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
-        ]) x !!$::instance_conf->get_is_show_mark_as_paid,
+          only_if  => $::instance_conf->get_is_show_mark_as_paid,
+        ],
       ], # end of combobox "Post"
 
       combobox => [
       ], # end of combobox "Post"
 
       combobox => [
index 2d89a05d749c5d89061e637c47f0ac6bddd174bd..dccfccbfb1d45a6487c39fcd26e8c0f8ca599c1d 100644 (file)
@@ -358,26 +358,30 @@ sub setup_oe_action_bar {
 
       combobox => [
         action => [ t8('Workflow') ],
 
       combobox => [
         action => [ t8('Workflow') ],
-        (action => [
+        action => [
           t8('Sales Order'),
           submit   => [ '#form', { action => "sales_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
           t8('Sales Order'),
           submit   => [ '#form', { action => "sales_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
-        ]) x !!$params{is_sales_quo},
-        (action => [
+          only_if  => $params{is_sales_quo},
+        ],
+        action => [
           t8('Purchase Order'),
           submit   => [ '#form', { action => "sales_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
           t8('Purchase Order'),
           submit   => [ '#form', { action => "sales_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
-        ]) x !!$params{is_req_quo},
-        (action => [
+          only_if  => $params{is_req_quo},
+        ],
+        action => [
           t8('Delivery Order'),
           submit   => [ '#form', { action => "delivery_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
           t8('Delivery Order'),
           submit   => [ '#form', { action => "delivery_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
-        ]) x ($params{is_sales_ord} || $params{is_pur_ord}),
-        (action => [
+          only_if  => $params{is_sales_ord} || $params{is_pur_ord},
+        ],
+        action => [
           t8('Invoice'),
           submit   => [ '#form', { action => "invoice" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
           t8('Invoice'),
           submit   => [ '#form', { action => "invoice" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
-        ]) x !!$allow_invoice,
+          only_if  => $allow_invoice,
+        ],
         action => [
           t8('Quotation'),
           submit   => [ '#form', { action => "quotation" } ],
         action => [
           t8('Quotation'),
           submit   => [ '#form', { action => "quotation" } ],