X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/0f4915834072e2f689ad80709b0801f46d786de9..8a5a3e9c4f991f278171843a6335bcb4724bd03f:/SL/Controller/Helper/GetModels/Sorted.pm diff --git a/SL/Controller/Helper/GetModels/Sorted.pm b/SL/Controller/Helper/GetModels/Sorted.pm index c154d753c..14e733d45 100644 --- a/SL/Controller/Helper/GetModels/Sorted.pm +++ b/SL/Controller/Helper/GetModels/Sorted.pm @@ -37,7 +37,6 @@ sub init { $self->get_models->register_handlers( callback => sub { shift; $self->_callback_handler_for_sorted(@_) }, - get_models => sub { shift; $self->_get_models_handler_for_sorted(@_) }, ); # $::lxdebug->dump(0, "CONSPEC", \%specs); @@ -73,6 +72,12 @@ sub read_params { sub finalize { my ($self, %params) = @_; + + my %sort_params = $self->read_params; + my $sort_spec = $self->specs->{ $sort_params{sort_by} }; + + $params{sort_by} = "SL::DB::Manager::$sort_spec->{model}"->make_sort_string(sort_by => $sort_spec->{model_column}, sort_dir => $sort_params{sort_dir}); + %params; } @@ -118,20 +123,6 @@ sub _callback_handler_for_sorted { return %params; } -sub _get_models_handler_for_sorted { - my ($self, %params) = @_; - - my %sort_params = $self->read_params; - my $sort_spec = $self->specs->{ $sort_params{sort_by} }; - - $params{sort_by} = "SL::DB::Manager::$sort_spec->{model}"->make_sort_string(sort_by => $sort_spec->{model_column}, sort_dir => $sort_params{sort_dir}); - - # $::lxdebug->dump(0, "GM handler for sorted; params nach modif:", \%params); - - return %params; -} - - sub init_form_params { [ qw(sort_by sort_dir) ] } @@ -155,7 +146,7 @@ In a controller: use SL::Controller::Helper::GetModels; use SL::Controller::Helper::Sorted; - __PACKAGE__->make_sorted( + __PACKAGE__->make_sorted( # update this DEFAULT_BY => 'run_at', DEFAULT_DIR => 1, MODEL => 'BackgroundJobHistory', @@ -179,7 +170,7 @@ In said template: - + # models @@ -199,7 +190,7 @@ This specialized helper module enables controllers to display a sortable list of database models with as few lines as possible. For this to work the controller has to provide the information which -indexes are eligible for sorting etc. by a call to L at +indexes are eligible for sorting etc. by a call to L at #not compiletime compile time. The underlying functionality that enables the use of more than just @@ -223,7 +214,7 @@ parameters that were used in the current view. =over 4 -=item C +=item C # meh complete rewrite This function must be called by a controller at compile time. It is uesd to set the various parameters required for this helper to do its
[% L.sortable_table_header('package_name') %][% L.sortable_table_header('package_name') %][% L.sortable_table_header('run_at') %] [% L.sortable_table_header('error') %]