ActionBar: leere ComboBoxen gar nicht anzeigen
[kivitendo-erp.git] / SL / Layout / ActionBar / ComboBox.pm
1 package SL::Layout::ActionBar::ComboBox;
2
3 use strict;
4 use parent qw(SL::Layout::ActionBar::Action);
5
6 use JSON;
7 use List::MoreUtils qw(none);
8
9 use Rose::Object::MakeMethods::Generic (
10   'scalar --get_set_init' => [ qw(actions) ],
11 );
12
13 sub from_params {
14   my ($class, $actions) = @_;
15
16   my $combobox = $class->new;
17   push @{ $combobox->actions }, SL::Layout::ActionBar->parse_actions(@{ $actions });
18
19   return $combobox;
20 }
21
22 sub render {
23   my ($first, @rest) = @{ $_[0]->actions };
24
25   return                if none { $_->callable } @{ $_[0]->actions };
26   return $first->render if !@rest;
27
28   $_[0]->p->html_tag('div',
29     $_[0]->p->html_tag('div', $first->render . $_[0]->p->html_tag('span'), class => 'layout-actionbar-combobox-head') .
30     $_[0]->p->html_tag('div', join('', map { $_->render } @rest), class => 'layout-actionbar-combobox-list'),
31     id    => $_[0]->id,
32     class => 'layout-actionbar-combobox',
33   );
34 }
35
36 sub script {
37   map { $_->script } @{ $_[0]->actions }
38 }
39
40 sub init_actions { [] }
41
42 1;