ActionBar: Funktionierender Prototyp mit submit und actionbutton
[kivitendo-erp.git] / SL / Layout / ActionBar.pm
1 package SL::Layout::ActionBar;
2
3 use strict;
4 use parent qw(SL::Layout::Base);
5
6 use SL::Layout::ActionBar::Action;
7
8 use constant HTML_CLASS => 'layout-actionbar';
9
10 use Rose::Object::MakeMethods::Generic (
11   'scalar --get_set_init' => [ qw(actions) ],
12 );
13
14
15 ###### Layout overrides
16
17 sub pre_content {
18   my ($self) = @_;
19
20   my $content = join '', map { $_->render } @{ $self->actions };
21   $::request->presenter->html_tag('div', $content, class => HTML_CLASS);
22 }
23
24 sub javascripts_inline {
25   join '', map { $_->script } @{ $_[0]->actions };
26 }
27
28 sub javascripts {
29   'kivi.ActionBar.js'
30 }
31
32 ###### interface
33
34 sub add_actions {
35   my ($self, @actions) = @_;
36   push @{ $self->actions }, map {
37        !ref $_ ? SL::Layout::ActionBar::Action->from_descriptor($_)
38      :  ref $_ && 'ARRAY' eq ref $_ ? SL::Layout::ActionBar::Action->simple($_)
39      :  ref $_ && $_->isa('SL::Layout::Action') ? $_
40      : do { die 'invalid action' };
41   } @actions;
42 }
43
44 sub init_actions {
45   []
46 }
47
48
49
50
51 1;
52
53 __END__
54
55 =encoding utf-8
56
57 =head1 NAME
58
59 SL::Layout::ActionBar - Unified action buttons for controllers
60
61 =head1 CONCEPT
62
63 This is a layout block that does a unified action bar for any controller who
64 wants to use it. It's designed to be rendered above the content and to be
65 fixed when scrolling.
66
67 While it can be used as a generic widget container, it's designed to be able to
68 provide commonly used functionality as a short cut. These shortcuts include:
69
70 =over 4
71
72 =item *
73
74 Calling a controller with parameters
75
76 =item *
77
78 Submitting a form with added parameters
79
80 =item *
81
82 Arrangement utility
83
84 =back
85
86
87 =head1 METHODS
88
89 =over 4
90
91 =item C<add_actions LIST>
92
93 Dispatches each each argument to C<add_action>
94
95 =item C<add_action>
96
97
98 =item C<add_separator>
99
100 =item C<add_
101
102 =head1 ACCESS FROM CODE
103
104 This is accessable through
105
106   $::request->layout->get('actionbar')
107
108 =head1 DOM MODEL
109
110 The entire block is rendered into a div with the class 'layout-actionbar'.
111
112 =head1 ACTION WIDGETS
113
114 Each individual action must be an instance of C<SL::Layout::ActionBar::Action>.
115
116 =head1 BUGS
117
118 none yet. :)
119
120 =head1 AUTHOR
121
122 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>
123
124 =cut