]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Layout/ActionBar/ComboBox.pm
ActionBar: by_description gefixt
[mfinanz.git] / SL / Layout / ActionBar / ComboBox.pm
diff --git a/SL/Layout/ActionBar/ComboBox.pm b/SL/Layout/ActionBar/ComboBox.pm
new file mode 100644 (file)
index 0000000..3416df8
--- /dev/null
@@ -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;