X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/87599e477cc6e1df8dded5fda69f21d01278e71e..dd1ab30b7c2a6bec318dd75100e54c9bfa400e77:/SL/Layout/ActionBar/ComboBox.pm diff --git a/SL/Layout/ActionBar/ComboBox.pm b/SL/Layout/ActionBar/ComboBox.pm new file mode 100644 index 000000000..3416df84d --- /dev/null +++ b/SL/Layout/ActionBar/ComboBox.pm @@ -0,0 +1,37 @@ +package SL::Layout::ActionBar::ComboBox; + +use strict; +use parent qw(SL::Layout::ActionBar::Action); + +use JSON; + +use Rose::Object::MakeMethods::Generic ( + 'scalar --get_set_init' => [ qw(actions) ], +); + +sub parsed_actions { + $_[0]{parsed_actions} ||= + [ map { SL::Layout::ActionBar::Action->simple($_) } @{ $_[0]->actions || [] } ]; +} + +sub add_actions { + push @{$_[0]{actions} //= $_[0]->init_actions}, @_[1..$#_] +} + +sub render { + my ($first, @rest) = @{ $_[0]->parsed_actions }; + $_[0]->p->html_tag('div', + $_[0]->p->html_tag('div', $first->render, class => 'layout-actionbar-combobox-head') . + $_[0]->p->html_tag('div', join('', map { $_->render } @rest), class => 'layout-actionbar-combobox-list'), + id => $_[0]->id, + class => 'layout-actionbar-combobox', + ); +} + +sub script { + map { $_->script } @{ $_[0]->parsed_actions } +} + +sub init_actions { [] } + +1;