]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Layout/ActionBar/ComboBox.pm
ActionBar: Auslassen von Actions über Parameter »only_if«/»not_if« steuern können
[mfinanz.git] / SL / Layout / ActionBar / ComboBox.pm
index 3416df84d8ec69eea2de072cfd6a0d4b1a239b62..9a545392f37cdd33e69995d4944a47d9735fb6ed 100644 (file)
@@ -9,19 +9,19 @@ 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 from_params {
+  my ($class, $actions) = @_;
+
+  my $combobox = $class->new;
+  push @{ $combobox->actions }, SL::Layout::ActionBar->parse_actions(@{ $actions });
 
-sub add_actions {
-  push @{$_[0]{actions} //= $_[0]->init_actions}, @_[1..$#_]
+  return $combobox;
 }
 
 sub render {
-  my ($first, @rest) = @{ $_[0]->parsed_actions };
+  my ($first, @rest) = @{ $_[0]->actions };
   $_[0]->p->html_tag('div',
-    $_[0]->p->html_tag('div', $first->render, class => 'layout-actionbar-combobox-head') .
+    $_[0]->p->html_tag('div', $first->render . $_[0]->p->html_tag('span'), 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',
@@ -29,7 +29,7 @@ sub render {
 }
 
 sub script {
-  map { $_->script } @{ $_[0]->parsed_actions }
+  map { $_->script } @{ $_[0]->actions }
 }
 
 sub init_actions { [] }