1 package SL::Layout::ActionBar;
4 use parent qw(SL::Layout::Base);
7 use Scalar::Util qw(blessed);
8 use SL::Layout::ActionBar::Action;
9 use SL::Layout::ActionBar::ComboBox;
10 use SL::Layout::ActionBar::Separator;
12 use constant HTML_CLASS => 'layout-actionbar';
14 use Rose::Object::MakeMethods::Generic (
15 'scalar --get_set_init' => [ qw(actions) ],
18 my %class_descriptors = (
19 action => { class => 'SL::Layout::ActionBar::Action', num_params => 1, },
20 combobox => { class => 'SL::Layout::ActionBar::ComboBox', num_params => 1, },
21 separator => { class => 'SL::Layout::ActionBar::Separator', num_params => 0, },
24 ###### Layout overrides
29 my $content = join '', map { $_->render } @{ $self->actions };
31 $::request->presenter->html_tag('div', $content, class => HTML_CLASS);
34 sub javascripts_inline {
35 join '', map { $_->script } @{ $_[0]->actions };
45 my ($self, @actions) = @_;
47 push @{ $self->actions }, $self->parse_actions(@actions);
49 return $self->actions->[-1];
53 my ($self_or_class, @actions) = @_;
57 while (my $type = shift(@actions)) {
58 if (blessed($type) && $type->isa('SL::Layout::ActionBar::Action')) {
63 my $descriptor = $class_descriptors{lc $type} || croak("Unknown action type '${type}'");
64 my @params = splice(@actions, 0, $descriptor->{num_params});
66 push @parsed, $descriptor->{class}->from_params(@params);
84 SL::Layout::ActionBar - Unified action buttons for controllers
88 This is a layout block that does a unified action bar for any controller who
89 wants to use it. It's designed to be rendered above the content and to be
92 While it can be used as a generic widget container, it's designed to be able to
93 provide commonly used functionality as a short cut. These shortcuts include:
99 Calling a controller with parameters
103 Submitting a form with added parameters
116 =item C<add_actions LIST>
118 Dispatches each each argument to C<add_action>
123 =item C<add_separator>
127 =head1 ACCESS FROM CODE
129 This is accessable through
131 $::request->layout->get('actionbar')
135 The entire block is rendered into a div with the class 'layout-actionbar'.
137 =head1 ACTION WIDGETS
139 Each individual action must be an instance of C<SL::Layout::ActionBar::Action>.
147 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>