widget documentation
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Action.pm
CommitLineData
2f670e13 1package Reaction::UI::Widget::Action;
9de685fc 2
3use Reaction::UI::WidgetClass;
4
bae75bee 5use namespace::clean -except => [ qw(meta) ];
599c1172 6extends 'Reaction::UI::Widget::Object::Mutable';
bae75bee 7
8after fragment widget {
9 arg 'method' => $_{viewport}->method;
10};
11
e29819c4 12implements fragment message {
13 return unless $_{viewport}->has_message;
14 arg message_string => $_{viewport}->message;
15 render 'message_layout';
16};
17
18implements fragment error_message {
19 return unless $_{viewport}->has_error_message;
20 arg message_string => $_{viewport}->error_message;
21 render 'error_message_layout';
22};
23
bae75bee 24implements fragment ok_button_fragment {
25 if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
26 arg 'event_id' => event_id 'ok';
d219104c 27 arg 'label' => localized $_{viewport}->ok_label;
bae75bee 28 render 'ok_button';
29 }
30};
31
32implements fragment apply_button_fragment {
33 if (grep { $_ eq 'apply' } $_{viewport}->accept_events) {
34 arg 'event_id' => event_id 'apply';
d219104c 35 arg 'label' => localized $_{viewport}->apply_label;
bae75bee 36 render 'apply_button';
37 }
38};
39
40implements fragment cancel_button_fragment {
41 if (grep { $_ eq 'close' } $_{viewport}->accept_events) {
42 arg 'event_id' => event_id 'close';
d219104c 43 arg 'label' => localized $_{viewport}->close_label;
bae75bee 44 render 'cancel_button';
45 }
9de685fc 46};
47
bae75bee 48__PACKAGE__->meta->make_immutable;
49
50
9de685fc 511;
52
53__END__;
54
5a1a893e 55=head1 NAME
9de685fc 56
2f670e13 57Reaction::UI::Widget::Action
9de685fc 58
5a1a893e 59=head1 DESCRIPTION
9de685fc 60
f9b32c83 61This is a subclass of L<Reaction::UI::Widget::Object::Mutable>.
62
5a1a893e 63=head1 FRAGMENTS
9de685fc 64
f9b32c83 65=head2 widget
66
67Additionally provides the C<method> argument containing the value of
68the viewport's C<method>.
69
70=head2 message
71
72Empty if the viewport's C<has_message> returns false. Otherwise sets
73the C<message_string> argument to the viewport's C<message> and
74renders the C<message_layout> fragment.
75
76=head2 error_message
77
78Same as the C<message> fragment above except that it checks
79C<has_error_message>, sets C<message_string> to the viewport's
80C<error_message> and renders C<error_message_layout>.
81
cc44a337 82=head2 ok_button_fragment
5a1a893e 83
f9b32c83 84Renders nothing unless the viewport accepts the C<ok> event.
85
86If it does, it provides the following arguments before rendering C<ok_button>:
87
88=over 4
89
90=item event_id
91
92Is set to the event id C<ok>.
93
94=item label
95
96Is set to the localized C<ok_label> of the viewport.
97
98=back
99
cc44a337 100=head2 apply_button_fragment
5a1a893e 101
f9b32c83 102Renders nothing unless the viewport accepts the C<apply> event.
103
104If it does, it provides the following arguments before rendering C<apply_button>:
105
106=over 4
107
108=item event_id
109
110Is set to the event id C<apply>.
111
112=item label
113
114Is set to the localized C<apply_label> of the viewport.
115
116=back
117
cc44a337 118=head2 cancel_button_fragment
5a1a893e 119
f9b32c83 120Renders nothing unless the viewport accepts the C<close> event.
121
122If it does, it provides the following arguments before rendering C<cancel_button>:
123
124=over 4
125
126=item event_id
127
128Is set to the event id C<close>.
129
130=item label
131
132Is set to the localized C<close_label> of the viewport.
133
134=back
135
136=head1 LAYOUT SETS
137
138=head2 base
139
140 share/skin/base/layout/action.tt
141
142The following layouts are provided:
143
144=over 4
145
146=item widget
147
148Renders a C<div> element containing a C<form>. The C<form> element contains the rendered
149C<header>, C<container_list>, C<buttons> and C<footer> fragments.
150
151=item header
152
153Renders the error message.
154
155=item container_list
156
157Simply renders the parent C<container_list>.
158
159=item container
160
161Simply renders the parent C<container>.
162
163=item buttons
164
165First renders the C<message> fragment, then the C<ok_button_fragment>, the C<apply_button_fragment>
166and the C<cancel_button_fragment>.
167
168=item message_layout
169
170Renders the C<message_string> argument in a C<span> element with an C<action_message> class.
171
172=item error_message_layout
173
174Renders the C<message_string> argument in a C<span> element with an C<action_error_message> class.
175
176=item standard_button
177
178Renders a submit button in a C<span> with the C<name> set to the C<event_id> argument, and the
179value set to the C<label> argument.
180
181=item ok_button
182
183Renders the C<standard_button> fragment.
184
185=item apply_button
186
187Renders the C<standard_button> fragment.
188
189=item cancel_button
190
191Renders the C<standard_button> fragment.
192
193=item footer
194
195Empty by default.
196
197=back
198
199=head2 default
200
201 share/skin/base/layout/action.tt
202
203Extends the layout set of the same name in the parent skin.
204
205The following layouts are provided:
206
207=over 4
208
209=item container
210
211Adds a C<br> element after the original C<container> fragment.
212
213=item message_layout
214
215Adds a C<br> element after the original C<message_layout> fragment.
216
217=back
218
219=head1 SEE ALSO
220
221=over 4
222
223=item L<Reaction::UI::Widget::Object::Mutable>
224
225=back
226
5a1a893e 227=head1 AUTHORS
228
229See L<Reaction::Class> for authors.
230
231=head1 LICENSE
232
233See L<Reaction::Class> for the license.
9de685fc 234
235=cut
5a1a893e 236