From aae0ac792d23a44a894fe876fed5159ca593d550 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 31 Aug 2012 18:05:22 +0200 Subject: [PATCH] =?utf8?q?Default=20f=C3=BCr=20Sort-Richtung=20aus=20Model?= =?utf8?q?-Manager-Sorted-Helper=20&=20Doku?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Helper/Sorted.pm | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/SL/Controller/Helper/Sorted.pm b/SL/Controller/Helper/Sorted.pm index 817f80319..959dff9bd 100644 --- a/SL/Controller/Helper/Sorted.pm +++ b/SL/Controller/Helper/Sorted.pm @@ -22,8 +22,9 @@ sub make_sorted { $spec->{model_column} ||= $column; } - $specs{DEFAULT_DIR} = $specs{DEFAULT_DIR} || !defined($specs{DEFAULT_DIR}) ? 1 : 0; - $specs{DEFAULT_BY} ||= { "SL::DB::Manager::$specs{MODEL}"->_sort_spec }->{default}->[0]; + my %model_sort_spec = "SL::DB::Manager::$specs{MODEL}"->_sort_spec; + $specs{DEFAULT_DIR} = $specs{DEFAULT_DIR} ? 1 : defined($specs{DEFAULT_DIR}) ? $specs{DEFAULT_DIR} * 1 : $model_sort_spec{default}->[1]; + $specs{DEFAULT_BY} ||= $model_sort_spec{default}->[0]; $specs{FORM_PARAMS} ||= [ qw(sort_by sort_dir) ]; $specs{ONLY} ||= []; $specs{ONLY} = [ $specs{ONLY} ] if !ref $specs{ONLY}; @@ -186,6 +187,9 @@ calls to e.g. C. A template on the other hand can use the method C from the layout helper module C. +This module requires that the Rose model managers use their C +helper. + The C helper hooks into the controller call to the action via a C hook. This is done so that it can remember the sort parameters that were used in the current view. @@ -207,31 +211,32 @@ that can be used for sorting (similar to database column names). The second kind are also the indexes you use in a template when calling C<[% L.sorted_table_header(...) %]>. -Control parameters include the following (all required parameters -occur first): +Control parameters include the following: =over 4 +=item * C + +Optional. A string: the name of the Rose database model that is used +as a default in certain cases. If this parameter is missing then it is +derived from the controller's package (e.g. for the controller +C the C would default to +C). + =item * C -Required. A string: the index to sort by if the user hasn't clicked on +Optional. A string: the index to sort by if the user hasn't clicked on any column yet (meaning: if the C<$::form> parameters for sorting do not contain a valid index). +Defaults to the underlying database model's default sort column name. + =item * C Optional. Default sort direction (ascending for trueish values, descrending for falsish values). -Defaults to C<1> if missing. - -=item * C - -Optional. A string: the name of the Rose database model that is used -as a default in certain cases. If this parameter is missing then it is -derived from the controller's package (e.g. for the controller -C the C would default to -C). +Defaults to the underlying database model's default sort direction. =item * C -- 2.20.1