From 2d587c41fc70f959556d33b11a10618b35da1b22 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 13 Jan 2017 10:29:47 +0100 Subject: [PATCH] ActionBar: leere ComboBoxen gar nicht anzeigen --- SL/Layout/ActionBar/Action.pm | 4 +++- SL/Layout/ActionBar/ComboBox.pm | 2 ++ SL/Layout/ActionBar/Link.pm | 2 ++ SL/Layout/ActionBar/Submit.pm | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/SL/Layout/ActionBar/Action.pm b/SL/Layout/ActionBar/Action.pm index b72314b4a..3707dcf8b 100644 --- a/SL/Layout/ActionBar/Action.pm +++ b/SL/Layout/ActionBar/Action.pm @@ -4,7 +4,7 @@ use strict; use parent qw(Rose::Object); use SL::Presenter; - require SL::Layout::ActionBar::Submit; +require SL::Layout::ActionBar::Submit; use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => [ qw(id params text) ], @@ -30,6 +30,8 @@ sub from_params { return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params); } +sub callable { 0 } + # shortcut for presenter sub p { diff --git a/SL/Layout/ActionBar/ComboBox.pm b/SL/Layout/ActionBar/ComboBox.pm index 555ae69b2..0ff0bc10d 100644 --- a/SL/Layout/ActionBar/ComboBox.pm +++ b/SL/Layout/ActionBar/ComboBox.pm @@ -4,6 +4,7 @@ use strict; use parent qw(SL::Layout::ActionBar::Action); use JSON; +use List::MoreUtils qw(none); use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => [ qw(actions) ], @@ -21,6 +22,7 @@ sub from_params { sub render { my ($first, @rest) = @{ $_[0]->actions }; + return if none { $_->callable } @{ $_[0]->actions }; return $first->render if !@rest; $_[0]->p->html_tag('div', diff --git a/SL/Layout/ActionBar/Link.pm b/SL/Layout/ActionBar/Link.pm index 8eb890662..31560c4be 100644 --- a/SL/Layout/ActionBar/Link.pm +++ b/SL/Layout/ActionBar/Link.pm @@ -20,4 +20,6 @@ sub render { ); } +sub callable { 1 } + 1; diff --git a/SL/Layout/ActionBar/Submit.pm b/SL/Layout/ActionBar/Submit.pm index a277e3be2..a130209e9 100644 --- a/SL/Layout/ActionBar/Submit.pm +++ b/SL/Layout/ActionBar/Submit.pm @@ -10,4 +10,9 @@ sub render { ); } +sub callable { + my ($self) = @_; + return $self->params->{submit} || $self->params->{call} || $self->params->{link}; +} + 1; -- 2.20.1