a8d97433a42d3421aa81f29f01a3da7a5a0174b4
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Collection / Grid.pm
1 package Reaction::UI::Widget::Collection::Grid;
2
3 use Reaction::UI::WidgetClass;
4
5 use namespace::clean -except => [ qw(meta) ];
6 extends 'Reaction::UI::Widget::Collection';
7
8 implements fragment header_cells {
9   arg 'labels' => $_{viewport}->field_labels;
10   render header_cell => over $_{viewport}->computed_field_order;
11   if ($_{viewport}->member_action_count) {
12     render 'header_action_cell';
13   }
14 };
15
16 implements fragment header_cell {
17   arg label => localized $_{labels}->{$_};
18 };
19
20 implements fragment header_action_cell {
21   arg col_count => $_{viewport}->member_action_count;
22 };
23
24 __PACKAGE__->meta->make_immutable;
25
26 1;
27
28 __END__;
29
30 =head1 NAME
31
32 Reaction::UI::Widget::Collection::Grid - A collection with header and footer
33
34 =head1 DESCRIPTION
35
36 This widget is a subclass of L<Reaction::UI::Widget::Collection>. Additionally
37 to its superclass, it provides abstract means of a header and a footer.
38
39 =head1 FRAGMENTS
40
41 =head2 header_cells
42
43 Will set the C<labels> argument to the viewport's C<field_labels> attribute
44 value.
45
46 Afterwards, the C<header_cell> fragment will be rendered once for every entry
47 in the viewport's C<computed_field_order>.
48
49 Additionally, the C<header_action_cell> will be rendered when the current
50 viewport's C<member_action_count> is larger than 0.
51
52 =head2 header_cell
53
54 Populates the C<label> argument with a localised value of the C<labels>
55 hash reference argument. The used key is extracted from the C<_> topic
56 argument.
57
58 =head2 header_action_cell
59
60 Populates the C<col_count> argument with the viewports C<member_action_count>
61 attribute value.
62
63 =head1 LAYOUT SETS
64
65 =head2 base
66
67   share/skin/base/layout/collection/grid.tt
68
69 The base grid layout set does not provide an markup, just abstract layouting.
70
71 The following layouts are provided:
72
73 =over 4
74
75 =item widget
76
77 Renders, in sequence, the C<header>, C<body> and C<footer> fragments.
78
79 =item header
80
81 Renders the C<header_row> fragment.
82
83 =item header_row
84
85 Renders the C<header_cells> fragment.
86
87 =item header_cell
88
89 Renders the C<header_cell_contents> fragment.
90
91 =item header_cell_contents
92
93 Renders the value of the C<label> argument.
94
95 =item header_action_cell
96
97 Renders the string C<Actions>.
98
99 =item body
100
101 Renders the C<members> fragment implemented in L<Reaction::UI::Widget::Collection>.
102
103 =back
104
105 =head2 default
106
107   share/skin/default/layout/collection/grid.tt
108
109 This layout set extends the C<NEXT> in the skin inheritance hierarchy.
110
111 It is meant to extend upon the layout set with the same name in the C<base> skin and
112 provides the same abstract structure but with a table based markup.
113
114 The following layouts are provided:
115
116 =over 4
117
118 =item widget
119
120 Renders the next skin's C<widget> fragment surrounded by a C<table> element with the
121 class attribute C<grid>.
122
123 =item header
124
125 Renders the next skin's C<header> fragment surrounded by a C<thead> element.
126
127 =item header_row
128
129 Wrap's the next skin's C<header_row> fragment in a C<tr> element.
130
131 =item header_cell
132
133 Wrap's the next skin's C<header_cell> fragment in a C<th> element.
134
135 =item header_action_cell
136
137 Wrap's the next skin's C<header_action_cell> fragment in a C<th> element with a C<colspan>
138 attribute set to the number of actions found in the C<col_count> attribute
139
140 =item body
141
142 Wrap's the next skin's C<body> fragment in a C<tbody> element.
143
144 =back
145
146 =head1 SEE ALSO
147
148 =over 4
149
150 =item * L<Reaction::UI::Widget::Collection>
151
152 =item * L<Reaction::UI::Widget::Collection::Grid::Member>
153
154 =back
155
156 =head1 AUTHORS
157
158 See L<Reaction::Class> for authors.
159
160 =head1 LICENSE
161
162 See L<Reaction::Class> for the license.
163
164 =cut