1 package Reaction::UI::Widget::Action;
3 use Reaction::UI::WidgetClass;
5 use namespace::clean -except => [ qw(meta) ];
6 extends 'Reaction::UI::Widget::Object::Mutable';
8 after fragment widget {
9 arg 'method' => $_{viewport}->method;
12 implements fragment message {
13 return unless $_{viewport}->has_message;
14 arg message_string => $_{viewport}->message;
15 render 'message_layout';
18 implements fragment error_message {
19 return unless $_{viewport}->has_error_message;
20 arg message_string => $_{viewport}->error_message;
21 render 'error_message_layout';
24 implements fragment ok_button_fragment {
25 if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
26 arg 'event_id' => event_id 'ok';
27 arg 'label' => localized $_{viewport}->ok_label;
32 implements fragment apply_button_fragment {
33 if (grep { $_ eq 'apply' } $_{viewport}->accept_events) {
34 arg 'event_id' => event_id 'apply';
35 arg 'label' => localized $_{viewport}->apply_label;
36 render 'apply_button';
40 implements fragment cancel_button_fragment {
41 if (grep { $_ eq 'close' } $_{viewport}->accept_events) {
42 arg 'event_id' => event_id 'close';
43 arg 'label' => localized $_{viewport}->close_label;
44 render 'cancel_button';
48 __PACKAGE__->meta->make_immutable;
57 Reaction::UI::Widget::Action
61 This is a subclass of L<Reaction::UI::Widget::Object::Mutable>.
67 Additionally provides the C<method> argument containing the value of
68 the viewport's C<method>.
72 Empty if the viewport's C<has_message> returns false. Otherwise sets
73 the C<message_string> argument to the viewport's C<message> and
74 renders the C<message_layout> fragment.
78 Same as the C<message> fragment above except that it checks
79 C<has_error_message>, sets C<message_string> to the viewport's
80 C<error_message> and renders C<error_message_layout>.
82 =head2 ok_button_fragment
84 Renders nothing unless the viewport accepts the C<ok> event.
86 If it does, it provides the following arguments before rendering C<ok_button>:
92 Is set to the event id C<ok>.
96 Is set to the localized C<ok_label> of the viewport.
100 =head2 apply_button_fragment
102 Renders nothing unless the viewport accepts the C<apply> event.
104 If it does, it provides the following arguments before rendering C<apply_button>:
110 Is set to the event id C<apply>.
114 Is set to the localized C<apply_label> of the viewport.
118 =head2 cancel_button_fragment
120 Renders nothing unless the viewport accepts the C<close> event.
122 If it does, it provides the following arguments before rendering C<cancel_button>:
128 Is set to the event id C<close>.
132 Is set to the localized C<close_label> of the viewport.
140 share/skin/base/layout/action.tt
142 The following layouts are provided:
148 Renders a C<div> element containing a C<form>. The C<form> element contains the rendered
149 C<header>, C<container_list>, C<buttons> and C<footer> fragments.
153 Renders the error message.
157 Simply renders the parent C<container_list>.
161 Simply renders the parent C<container>.
165 First renders the C<message> fragment, then the C<ok_button_fragment>, the C<apply_button_fragment>
166 and the C<cancel_button_fragment>.
170 Renders the C<message_string> argument in a C<span> element with an C<action_message> class.
172 =item error_message_layout
174 Renders the C<message_string> argument in a C<span> element with an C<action_error_message> class.
176 =item standard_button
178 Renders a submit button in a C<span> with the C<name> set to the C<event_id> argument, and the
179 value set to the C<label> argument.
183 Renders the C<standard_button> fragment.
187 Renders the C<standard_button> fragment.
191 Renders the C<standard_button> fragment.
201 share/skin/base/layout/action.tt
203 Extends the layout set of the same name in the parent skin.
205 The following layouts are provided:
211 Adds a C<br> element after the original C<container> fragment.
215 Adds a C<br> element after the original C<message_layout> fragment.
223 =item L<Reaction::UI::Widget::Object::Mutable>
229 See L<Reaction::Class> for authors.
233 See L<Reaction::Class> for the license.