From: Moritz Bunkus Date: Tue, 4 Sep 2012 13:26:20 +0000 (+0200) Subject: Paginate-Controller-Helper: Parameterübergabe für Berechnung Objektanzahl ermöglichen X-Git-Tag: release-3.0.0beta1~249^2~14 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a99a31d6e4bb41691a28ddb1ce9f20e5219ec4e1;p=kivitendo-erp.git Paginate-Controller-Helper: Parameterübergabe für Berechnung Objektanzahl ermöglichen --- diff --git a/SL/Controller/Helper/Paginated.pm b/SL/Controller/Helper/Paginated.pm index 0e2560d76..5792f6336 100644 --- a/SL/Controller/Helper/Paginated.pm +++ b/SL/Controller/Helper/Paginated.pm @@ -54,7 +54,10 @@ sub get_current_paginate_params { per_page => ($params{per_page} * 1) || $spec->{PER_PAGE}, ); - my $calculated_params = "SL::DB::Manager::$spec->{MODEL}"->paginate(%paginate_params, args => {}); + my $paginate_args = ref($spec->{PAGINATE_ARGS}) eq 'CODE' ? $spec->{PAGINATE_ARGS}->($self) + : $spec->{PAGINATE_ARGS} ? do { my $sub = $spec->{PAGINATE_ARGS}; $self->$sub() } + : {}; + my $calculated_params = "SL::DB::Manager::$spec->{MODEL}"->paginate(%paginate_params, args => $paginate_args); %paginate_params = ( %paginate_params, num_pages => $calculated_params->{max}, @@ -211,6 +214,19 @@ derived from the controller's package (e.g. for the controller C the C would default to C). +=item * C + +Optional. Either a code reference or the name of function to be called +on the controller importing this helper. + +If this funciton is given then the paginate helper calls it whenever +it has to count the total number of models for calculating the number +of pages to display. The function must return a hash reference with +elements suitable for passing to a Rose model manager's C +function. + +This can be used e.g. when filtering is used. + =item * C Optional. An integer: the number of models to return per page.