Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 28cda5b6

Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt

  • ID 28cda5b67bc9cef793911fa4e65b6aa9b81903e3
  • Vorgänger 3ce13f69
  • Nachfolger ee932f3f

Sorted-Controller-Helper: Hilfsfunktion zum Setzen der Parameter in einer ReportGenerator-Instanz

Unterschiede anzeigen:

SL/Controller/Helper/Sorted.pm
2 2

  
3 3
use strict;
4 4

  
5
use Carp;
6

  
5 7
use Exporter qw(import);
6
our @EXPORT = qw(make_sorted get_sort_spec get_current_sort_params _save_current_sort_params _get_models_handler_for_sorted _callback_handler_for_sorted);
8
our @EXPORT = qw(make_sorted get_sort_spec get_current_sort_params set_report_generator_sort_options
9
                 _save_current_sort_params _get_models_handler_for_sorted _callback_handler_for_sorted);
7 10

  
8 11
use constant PRIV => '__sortedhelperpriv';
9 12

  
......
72 75
  return %sort_params;
73 76
}
74 77

  
78
sub set_report_generator_sort_options {
79
  my ($self, %params) = @_;
80

  
81
  $params{$_} or croak("Missing parameter '$_'") for qw(report sortable_columns);
82

  
83
  my %current_sort_params = $self->get_current_sort_params;
84

  
85
  foreach my $col (@{ $params{sortable_columns} }) {
86
    $params{report}->{columns}->{$col}->{link} = $self->get_callback(
87
      sort_by  => $col,
88
      sort_dir => ($current_sort_params{by} eq $col ? 1 - $current_sort_params{dir} : $current_sort_params{dir}),
89
    );
90
  }
91

  
92
  $params{report}->set_sort_indicator($current_sort_params{by}, 1 - $current_sort_params{dir});
93
}
94

  
75 95
#
76 96
# private functions
77 97
#
......
320 340
to L<make_sorted> after normalization (hash reference construction,
321 341
applying default parameters etc).
322 342

  
343
=item C<set_report_generator_sort_options %params>
344

  
345
This function sets two things in an instance of
346
L<SL::ReportGenerator>: the sort indicator and the links for those
347
column headers that are sortable.
348

  
349
The report generator instance must be passed as the parameter
350
C<report>. The parameter C<sortable_columns> must be an array
351
reference of column names that are sortable.
352

  
353
The report generator instance must already have its columns set via a
354
call to its L<SL::ReportGenerator::set_columns> function.
355

  
323 356
=back
324 357

  
325 358
=head1 BUGS

Auch abrufbar als: Unified diff