From: Sven Schöling Date: Wed, 18 Sep 2013 12:56:17 +0000 (+0200) Subject: get_models callback entefrnt und in den finalize prozess integriert X-Git-Tag: release-3.1.0beta1~48 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d5cb059bfa6c56fb74bf2a89c5625cb0b442e48e;p=kivitendo-erp.git get_models callback entefrnt und in den finalize prozess integriert --- diff --git a/SL/Controller/Helper/GetModels.pm b/SL/Controller/Helper/GetModels.pm index 054bd0b35..7696fc1ea 100644 --- a/SL/Controller/Helper/GetModels.pm +++ b/SL/Controller/Helper/GetModels.pm @@ -23,7 +23,6 @@ use constant PRIV => '__getmodelshelperpriv'; sub get { my ($self) = @_; my %params = $self->finalize; - %params = $self->_run_handlers('get_models', %params); return $self->manager->get_all(%params); } @@ -160,7 +159,6 @@ sub _run_handlers { sub init_handlers { { callback => [], - get_models => [], } } diff --git a/SL/Controller/Helper/GetModels/Base.pm b/SL/Controller/Helper/GetModels/Base.pm index 97aa84d0c..6a9a9cda7 100644 --- a/SL/Controller/Helper/GetModels/Base.pm +++ b/SL/Controller/Helper/GetModels/Base.pm @@ -27,10 +27,10 @@ sub merge_args { $final_args->{$field} = [ map { @{ $_->{$field} || [] } } @args ]; } - for my $field (qw(page per_page sort_by sort_dir )) { + for my $field (qw(page per_page sort_by)) { for my $arg (@args) { - next unless defined $_->{$field}; - $final_args->{$field} //= $_->{$field}; + next unless defined $arg->{$field}; + $final_args->{$field} //= $arg->{$field}; } } diff --git a/SL/Controller/Helper/GetModels/Filtered.pm b/SL/Controller/Helper/GetModels/Filtered.pm index c89d44d6b..e60c793e2 100644 --- a/SL/Controller/Helper/GetModels/Filtered.pm +++ b/SL/Controller/Helper/GetModels/Filtered.pm @@ -70,7 +70,13 @@ sub read_params { sub finalize { my ($self, %params) = @_; - %params; + + my %filter_params; + %filter_params = $self->read_params(%params) if $self->is_enabled; + + # $::lxdebug->dump(0, "GM handler for filtered; params nach modif (is_enabled? " . $self->is_enabled . ")", \%params); + + return $self->merge_args(\%params, \%filter_params); } # @@ -98,19 +104,6 @@ sub _callback_handler_for_filtered { return %params; } -sub _get_models_handler_for_filtered { - my ($self, %params) = @_; - - # $::lxdebug->dump(0, "params in get_models_for_filtered", \%params); - - my %filter_params; - %filter_params = $self->read_params(%params) if $self->is_enabled; - - # $::lxdebug->dump(0, "GM handler for filtered; params nach modif (is_enabled? " . $self->is_enabled . ")", \%params); - - return $self->merge_args(\%params, \%filter_params); -} - sub init_form_params { 'filter' } diff --git a/SL/Controller/Helper/GetModels/Paginated.pm b/SL/Controller/Helper/GetModels/Paginated.pm index fc61ac573..7a6b80b0c 100644 --- a/SL/Controller/Helper/GetModels/Paginated.pm +++ b/SL/Controller/Helper/GetModels/Paginated.pm @@ -96,15 +96,6 @@ sub _callback_handler_for_paginated { return %params; } -sub _get_models_handler_for_paginated { - my ($self, %params) = @_; - - $self->get_models->manager->paginate(%{ $self->calculated_params }, args => \%params) if $self->is_enabled; - - # $::lxdebug->dump(0, "GM handler for paginated; params nach modif (is_enabled? " . _is_enabled($self) . ")", \%params); - return %params; -} - sub init_form_params { [ qw(page per_page) ] } diff --git a/SL/Controller/Helper/GetModels/Sorted.pm b/SL/Controller/Helper/GetModels/Sorted.pm index c154d753c..e35fdefea 100644 --- a/SL/Controller/Helper/GetModels/Sorted.pm +++ b/SL/Controller/Helper/GetModels/Sorted.pm @@ -73,6 +73,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,18 +124,15 @@ 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 _get_models_handler_for_sorted { +# my ($self, %params) = @_; +# +# +# +# # $::lxdebug->dump(0, "GM handler for sorted; params nach modif:", \%params); +# +# return %params; +#} sub init_form_params {