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::Link;
 
  11 use SL::Layout::ActionBar::Separator;
 
  13 use constant HTML_CLASS => 'layout-actionbar';
 
  15 use Rose::Object::MakeMethods::Generic (
 
  16   'scalar --get_set_init' => [ qw(actions) ],
 
  19 my %class_descriptors = (
 
  20   action    => { class => 'SL::Layout::ActionBar::Action',    num_params => 1, },
 
  21   combobox  => { class => 'SL::Layout::ActionBar::ComboBox',  num_params => 1, },
 
  22   link      => { class => 'SL::Layout::ActionBar::Link',      num_params => 1, },
 
  23   separator => { class => 'SL::Layout::ActionBar::Separator', num_params => 0, },
 
  26 ###### Layout overrides
 
  31   my $content = join '', map { $_->render } @{ $self->actions };
 
  33   $::request->presenter->html_tag('div', $content, class => HTML_CLASS);
 
  36 sub javascripts_inline {
 
  37   join '', map { $_->script } @{ $_[0]->actions };
 
  47   my ($self, @actions) = @_;
 
  49   push @{ $self->actions }, $self->parse_actions(@actions);
 
  51   return $self->actions->[-1];
 
  55   my ($self_or_class, @actions) = @_;
 
  59   while (my $type = shift(@actions)) {
 
  60     if (blessed($type) && $type->isa('SL::Layout::ActionBar::Action')) {
 
  65     my $descriptor = $class_descriptors{lc $type} || croak("Unknown action type '${type}'");
 
  66     my @params     = splice(@actions, 0, $descriptor->{num_params});
 
  68     push @parsed, $descriptor->{class}->from_params(@params);
 
  86 SL::Layout::ActionBar - Unified action buttons for controllers
 
  90 This is a layout block that does a unified action bar for any controller who
 
  91 wants to use it. It's designed to be rendered above the content and to be
 
  94 While it can be used as a generic widget container, it's designed to be able to
 
  95 provide commonly used functionality as a short cut. These shortcuts include:
 
 101 Calling a controller with parameters
 
 105 Submitting a form with added parameters
 
 122 =head1 ACCESS FROM CODE
 
 124 This is accessable through
 
 126   $::request->layout->get('actionbar')
 
 130 The entire block is rendered into a div with the class 'layout-actionbar'.
 
 132 =head1 ACTION WIDGETS
 
 134 Each individual action must be an instance of C<SL::Layout::ActionBar::Action>.
 
 142 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>