ActionBar: API-Umstellung fürs Hinzufügen
[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
8 use Rose::Object::MakeMethods::Generic (
9   'scalar --get_set_init' => [ qw(actions) ],
10 );
11
12 sub from_params {
13   my ($class, $actions) = @_;
14
15   my $combobox = $class->new;
16   push @{ $combobox->actions }, SL::Layout::ActionBar->parse_actions(@{ $actions });
17
18   return $combobox;
19 }
20
21 sub render {
22   my ($first, @rest) = @{ $_[0]->actions };
23   $_[0]->p->html_tag('div',
24     $_[0]->p->html_tag('div', $first->render . $_[0]->p->html_tag('span'), class => 'layout-actionbar-combobox-head') .
25     $_[0]->p->html_tag('div', join('', map { $_->render } @rest), class => 'layout-actionbar-combobox-list'),
26     id    => $_[0]->id,
27     class => 'layout-actionbar-combobox',
28   );
29 }
30
31 sub script {
32   map { $_->script } @{ $_[0]->actions }
33 }
34
35 sub init_actions { [] }
36
37 1;