Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a99a31d6

Von Moritz Bunkus vor mehr als 12 Jahren hinzugefügt

  • ID a99a31d6e4bb41691a28ddb1ce9f20e5219ec4e1
  • Vorgänger 29637d3f
  • Nachfolger 5e45f456

Paginate-Controller-Helper: Parameterübergabe für Berechnung Objektanzahl ermöglichen

Unterschiede anzeigen:

SL/Controller/Helper/Paginated.pm
54 54
    per_page            => ($params{per_page} * 1) || $spec->{PER_PAGE},
55 55
  );
56 56

  
57
  my $calculated_params = "SL::DB::Manager::$spec->{MODEL}"->paginate(%paginate_params, args => {});
57
  my $paginate_args     = ref($spec->{PAGINATE_ARGS}) eq 'CODE' ? $spec->{PAGINATE_ARGS}->($self)
58
                        :     $spec->{PAGINATE_ARGS}            ? do { my $sub = $spec->{PAGINATE_ARGS}; $self->$sub() }
59
                        :                                         {};
60
  my $calculated_params = "SL::DB::Manager::$spec->{MODEL}"->paginate(%paginate_params, args => $paginate_args);
58 61
  %paginate_params      = (
59 62
    %paginate_params,
60 63
    num_pages    => $calculated_params->{max},
......
211 214
C<SL::Controller::BackgroundJobHistory> the C<MODEL> would default to
212 215
C<BackgroundJobHistory>).
213 216

  
217
=item * C<PAGINATE_ARGS>
218

  
219
Optional. Either a code reference or the name of function to be called
220
on the controller importing this helper.
221

  
222
If this funciton is given then the paginate helper calls it whenever
223
it has to count the total number of models for calculating the number
224
of pages to display. The function must return a hash reference with
225
elements suitable for passing to a Rose model manager's C<get_all>
226
function.
227

  
228
This can be used e.g. when filtering is used.
229

  
214 230
=item * C<PER_PAGE>
215 231

  
216 232
Optional. An integer: the number of models to return per page.

Auch abrufbar als: Unified diff