Revision aae0ac79
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
SL/Controller/Helper/Sorted.pm | ||
---|---|---|
22 | 22 |
$spec->{model_column} ||= $column; |
23 | 23 |
} |
24 | 24 |
|
25 |
$specs{DEFAULT_DIR} = $specs{DEFAULT_DIR} || !defined($specs{DEFAULT_DIR}) ? 1 : 0; |
|
26 |
$specs{DEFAULT_BY} ||= { "SL::DB::Manager::$specs{MODEL}"->_sort_spec }->{default}->[0]; |
|
25 |
my %model_sort_spec = "SL::DB::Manager::$specs{MODEL}"->_sort_spec; |
|
26 |
$specs{DEFAULT_DIR} = $specs{DEFAULT_DIR} ? 1 : defined($specs{DEFAULT_DIR}) ? $specs{DEFAULT_DIR} * 1 : $model_sort_spec{default}->[1]; |
|
27 |
$specs{DEFAULT_BY} ||= $model_sort_spec{default}->[0]; |
|
27 | 28 |
$specs{FORM_PARAMS} ||= [ qw(sort_by sort_dir) ]; |
28 | 29 |
$specs{ONLY} ||= []; |
29 | 30 |
$specs{ONLY} = [ $specs{ONLY} ] if !ref $specs{ONLY}; |
... | ... | |
186 | 187 |
A template on the other hand can use the method |
187 | 188 |
C<sortable_table_header> from the layout helper module C<L>. |
188 | 189 |
|
190 |
This module requires that the Rose model managers use their C<Sorted> |
|
191 |
helper. |
|
192 |
|
|
189 | 193 |
The C<Sorted> helper hooks into the controller call to the action via |
190 | 194 |
a C<run_before> hook. This is done so that it can remember the sort |
191 | 195 |
parameters that were used in the current view. |
... | ... | |
207 | 211 |
second kind are also the indexes you use in a template when calling |
208 | 212 |
C<[% L.sorted_table_header(...) %]>. |
209 | 213 |
|
210 |
Control parameters include the following (all required parameters |
|
211 |
occur first): |
|
214 |
Control parameters include the following: |
|
212 | 215 |
|
213 | 216 |
=over 4 |
214 | 217 |
|
218 |
=item * C<MODEL> |
|
219 |
|
|
220 |
Optional. A string: the name of the Rose database model that is used |
|
221 |
as a default in certain cases. If this parameter is missing then it is |
|
222 |
derived from the controller's package (e.g. for the controller |
|
223 |
C<SL::Controller::BackgroundJobHistory> the C<MODEL> would default to |
|
224 |
C<BackgroundJobHistory>). |
|
225 |
|
|
215 | 226 |
=item * C<DEFAULT_BY> |
216 | 227 |
|
217 |
Required. A string: the index to sort by if the user hasn't clicked on
|
|
228 |
Optional. A string: the index to sort by if the user hasn't clicked on
|
|
218 | 229 |
any column yet (meaning: if the C<$::form> parameters for sorting do |
219 | 230 |
not contain a valid index). |
220 | 231 |
|
232 |
Defaults to the underlying database model's default sort column name. |
|
233 |
|
|
221 | 234 |
=item * C<DEFAULT_DIR> |
222 | 235 |
|
223 | 236 |
Optional. Default sort direction (ascending for trueish values, |
224 | 237 |
descrending for falsish values). |
225 | 238 |
|
226 |
Defaults to C<1> if missing. |
|
227 |
|
|
228 |
=item * C<MODEL> |
|
229 |
|
|
230 |
Optional. A string: the name of the Rose database model that is used |
|
231 |
as a default in certain cases. If this parameter is missing then it is |
|
232 |
derived from the controller's package (e.g. for the controller |
|
233 |
C<SL::Controller::BackgroundJobHistory> the C<MODEL> would default to |
|
234 |
C<BackgroundJobHistory>). |
|
239 |
Defaults to the underlying database model's default sort direction. |
|
235 | 240 |
|
236 | 241 |
=item * C<FORM_PARAMS> |
237 | 242 |
|
Auch abrufbar als: Unified diff
Default für Sort-Richtung aus Model-Manager-Sorted-Helper & Doku