r72883@cain (orig r423): edenc | 2007-12-17 18:43:38 +0000
[catagits/Reaction.git] / lib / Reaction / UI / Widget / ActionForm.pm
1 package Reaction::UI::Widget::ActionForm;
2
3 use Reaction::UI::WidgetClass;
4
5 class ActionForm, which {
6   fragment widget [ qw/header field_list buttons footer/ ]
7     => {id => sub { $_{viewport}->location } };
8
9   fragment field_list [field => over func('viewport','ordered_fields')];
10   fragment field  [ 'viewport' ];
11
12   #move button logic here
13   fragment buttons [ string {"DUMMY"} ],
14     { message => sub{ $_{viewport}->can('message') ? $_{viewport}->message : "" },
15       ok_label    => func(viewport => 'ok_label'),
16       close_label => func(viewport => 'close_label'),
17       apply_label => func(viewport => 'apply_label'),
18     };
19
20   fragment header  [ string {"DUMMY"} ];
21   fragment footer  [ string {"DUMMY"} ];
22
23   implements fragment ok_button_fragment {
24     if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
25       arg 'event_id' => event_id 'ok';
26       arg 'label' => $_{viewport}->ok_label;
27       render 'ok_button';
28     }
29   };
30
31   implements fragment apply_button_fragment {
32     if (grep { $_ eq 'apply' } $_{viewport}->accept_events) {
33       arg 'event_id' => event_id 'apply';
34       arg 'label' => $_{viewport}->apply_label;
35       render 'apply_button';
36     }
37   };
38
39   implements fragment cancel_button_fragment {
40     if (grep { $_ eq 'cancel' } $_{viewport}->accept_events) {
41       arg 'event_id' => event_id 'cancel';
42       arg 'label' => $_{viewport}->cancel_label;
43       render 'cancel_button';
44     }
45   };
46
47 };
48
49 1;
50
51 __END__;
52
53 =head1 NAME
54
55 Reaction::UI::Widget::ActionForm
56
57 =head1 DESCRIPTION
58
59 =head1 FRAGMENTS
60
61 =head2 widget
62
63 Additional variables available in topic hash: "viewport".
64
65 Renders "header", "field_list", "buttons" and "footer"
66
67 =head2 field_list
68
69 Sequentially renders the C<ordered_fields> of the viewport
70
71 =head2 buttons
72
73 Additional variables available in topic hash: "message"
74
75 =head2 header
76
77 Content is a dummy value
78
79 =head2 footer
80
81 Content is a dummy value
82
83 =head1 AUTHORS
84
85 See L<Reaction::Class> for authors.
86
87 =head1 LICENSE
88
89 See L<Reaction::Class> for the license.
90
91 =cut
92