kivitendo/SL/Layout/ActionBar/ComboBox.pm @ dfe28d97
dd1ab30b | Sven Schöling | package SL::Layout::ActionBar::ComboBox;
|
||
use strict;
|
||||
use parent qw(SL::Layout::ActionBar::Action);
|
||||
use JSON;
|
||||
2d587c41 | Moritz Bunkus | use List::MoreUtils qw(none);
|
||
5a55ac86 | Sven Schöling | use SL::Presenter::Tag qw(html_tag);
|
||
dd1ab30b | Sven Schöling | |||
use Rose::Object::MakeMethods::Generic (
|
||||
'scalar --get_set_init' => [ qw(actions) ],
|
||||
);
|
||||
ff424b75 | Moritz Bunkus | sub from_params {
|
||
my ($class, $actions) = @_;
|
||||
my $combobox = $class->new;
|
||||
push @{ $combobox->actions }, SL::Layout::ActionBar->parse_actions(@{ $actions });
|
||||
dd1ab30b | Sven Schöling | |||
ff424b75 | Moritz Bunkus | return $combobox;
|
||
dd1ab30b | Sven Schöling | }
|
||
sub render {
|
||||
ff424b75 | Moritz Bunkus | my ($first, @rest) = @{ $_[0]->actions };
|
||
3cc1ebb7 | Moritz Bunkus | |||
2d587c41 | Moritz Bunkus | return if none { $_->callable } @{ $_[0]->actions };
|
||
3cc1ebb7 | Moritz Bunkus | return $first->render if !@rest;
|
||
5a55ac86 | Sven Schöling | html_tag('div',
|
||
html_tag('div', $first->render . html_tag('span'), class => 'layout-actionbar-combobox-head') .
|
||||
html_tag('div', join('', map { $_->render } @rest), class => 'layout-actionbar-combobox-list'),
|
||||
dd1ab30b | Sven Schöling | id => $_[0]->id,
|
||
class => 'layout-actionbar-combobox',
|
||||
);
|
||||
}
|
||||
sub script {
|
||||
ff424b75 | Moritz Bunkus | map { $_->script } @{ $_[0]->actions }
|
||
dd1ab30b | Sven Schöling | }
|
||
sub init_actions { [] }
|
||||
1;
|