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 {
10 arg 'method' => $vp->method;
11 arg 'form_id' => $vp->location;
12 arg 'action' => $vp->has_action ? $vp->action : '';
15 implements fragment message {
16 return unless $_{viewport}->has_message;
17 arg message_string => $_{viewport}->message;
18 render 'message_layout';
21 implements fragment error_message {
22 return unless $_{viewport}->has_error_message;
23 arg message_string => $_{viewport}->error_message;
24 render 'error_message_layout';
27 implements fragment ok_button_fragment {
28 if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
29 arg 'event_id' => event_id 'ok';
30 arg 'label' => localized $_{viewport}->ok_label;
35 implements fragment apply_button_fragment {
36 if (grep { $_ eq 'apply' } $_{viewport}->accept_events) {
37 arg 'event_id' => event_id 'apply';
38 arg 'label' => localized $_{viewport}->apply_label;
39 render 'apply_button';
43 implements fragment cancel_button_fragment {
44 if (grep { $_ eq 'close' } $_{viewport}->accept_events) {
45 arg 'event_id' => event_id 'close';
46 arg 'label' => localized $_{viewport}->close_label;
47 render 'cancel_button';
51 implements fragment maybe_inner {
52 if( my $inner = $_{viewport}->inner ){
59 __PACKAGE__->meta->make_immutable;
68 Reaction::UI::Widget::Action
72 This is a subclass of L<Reaction::UI::Widget::Object::Mutable>.
78 Additionally provides the C<method> argument containing the value of
79 the viewport's C<method>.
83 Empty if the viewport's C<has_message> returns false. Otherwise sets
84 the C<message_string> argument to the viewport's C<message> and
85 renders the C<message_layout> fragment.
89 Same as the C<message> fragment above except that it checks
90 C<has_error_message>, sets C<message_string> to the viewport's
91 C<error_message> and renders C<error_message_layout>.
93 =head2 ok_button_fragment
95 Renders nothing unless the viewport accepts the C<ok> event.
97 If it does, it provides the following arguments before rendering C<ok_button>:
103 Is set to the event id C<ok>.
107 Is set to the localized C<ok_label> of the viewport.
111 =head2 apply_button_fragment
113 Renders nothing unless the viewport accepts the C<apply> event.
115 If it does, it provides the following arguments before rendering C<apply_button>:
121 Is set to the event id C<apply>.
125 Is set to the localized C<apply_label> of the viewport.
129 =head2 cancel_button_fragment
131 Renders nothing unless the viewport accepts the C<close> event.
133 If it does, it provides the following arguments before rendering C<cancel_button>:
139 Is set to the event id C<close>.
143 Is set to the localized C<close_label> of the viewport.
151 share/skin/base/layout/action.tt
153 The following layouts are provided:
159 Renders a C<div> element containing a C<form>. The C<form> element contains the rendered
160 C<header>, C<container_list>, C<buttons> and C<footer> fragments.
164 Renders the error message.
168 Simply renders the parent C<container_list>.
172 Simply renders the parent C<container>.
176 First renders the C<message> fragment, then the C<ok_button_fragment>, the C<apply_button_fragment>
177 and the C<cancel_button_fragment>.
181 Renders the C<message_string> argument in a C<span> element with an C<action_message> class.
183 =item error_message_layout
185 Renders the C<message_string> argument in a C<span> element with an C<action_error_message> class.
187 =item standard_button
189 Renders a submit button in a C<span> with the C<name> set to the C<event_id> argument, and the
190 value set to the C<label> argument.
194 Renders the C<standard_button> fragment.
198 Renders the C<standard_button> fragment.
202 Renders the C<standard_button> fragment.
212 share/skin/base/layout/action.tt
214 Extends the layout set of the same name in the parent skin.
216 The following layouts are provided:
222 Adds a C<br> element after the original C<container> fragment.
226 Adds a C<br> element after the original C<message_layout> fragment.
234 =item L<Reaction::UI::Widget::Object::Mutable>
240 See L<Reaction::Class> for authors.
244 See L<Reaction::Class> for the license.