From 36c8af5266db4c2894cd37df798212c2e7f06f68 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 13 Jan 2017 10:22:12 +0100 Subject: [PATCH] =?utf8?q?ActionBar:=20Auslassen=20von=20Actions=20=C3=BCb?= =?utf8?q?er=20Parameter=20=C2=BBonly=5Fif=C2=AB/=C2=BBnot=5Fif=C2=AB=20st?= =?utf8?q?euern=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 2 ++ bin/mozilla/do.pl | 21 +++++++++++++-------- bin/mozilla/ir.pl | 5 +++-- bin/mozilla/is.pl | 5 +++-- bin/mozilla/oe.pl | 20 ++++++++++++-------- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/SL/Layout/ActionBar/Action.pm b/SL/Layout/ActionBar/Action.pm index bed33fe1c..b72314b4a 100644 --- a/SL/Layout/ActionBar/Action.pm +++ b/SL/Layout/ActionBar/Action.pm @@ -25,6 +25,8 @@ sub from_params { 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); } diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 7107017ab..a3c82130a 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -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; + my $is_customer = $::form->{vc} eq 'customer'; for my $bar ($::request->layout->get('actionbar')) { $bar->add( @@ -284,30 +285,34 @@ sub setup_do_action_bar { ], 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, - ]) 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, - ]) 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, - ]) 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, - ]) x ($::form->{vc} eq 'vendor' && $::instance_conf->get_transfer_default), + only_if => !$is_customer && $::instance_conf->get_transfer_default, + ], ], # end of combobox "Transfer out" diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index b9e79d6de..c649046a8 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -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, ], - (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, - ]) x !!$::instance_conf->get_ir_show_mark_as_paid, + only_if => $::instance_conf->get_ir_show_mark_as_paid, + ], ], # end of combobox "Post" combobox => [ diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 6eae18e39..6b958c25e 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -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, ], - (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, - ]) x !!$::instance_conf->get_is_show_mark_as_paid, + only_if => $::instance_conf->get_is_show_mark_as_paid, + ], ], # end of combobox "Post" combobox => [ diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 2d89a05d7..dccfccbfb 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -358,26 +358,30 @@ sub setup_oe_action_bar { 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, - ]) 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, - ]) 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, - ]) 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, - ]) x !!$allow_invoice, + only_if => $allow_invoice, + ], action => [ t8('Quotation'), submit => [ '#form', { action => "quotation" } ], -- 2.20.1