X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FController%2FHelper%2FGetModels.pm;h=5ea9413fb9b88f3fc38c8ad6d01e9fbcfaf9727e;hb=feb6f563968f53e59511578429b1dd61fda52008;hp=861834b83c9091748423c69e63fe5fa0d605d0e2;hpb=7ff7dd017542c32a8f8111167fda69857de50910;p=kivitendo-erp.git diff --git a/SL/Controller/Helper/GetModels.pm b/SL/Controller/Helper/GetModels.pm index 861834b83..5ea9413fb 100644 --- a/SL/Controller/Helper/GetModels.pm +++ b/SL/Controller/Helper/GetModels.pm @@ -11,7 +11,7 @@ use Scalar::Util qw(weaken); use Rose::Object::MakeMethods::Generic ( scalar => [ qw(controller model query with_objects filtered sorted paginated finalized final_params) ], - 'scalar --get_set_init' => [ qw(handlers source additional_url_params) ], + 'scalar --get_set_init' => [ qw(handlers source list_action additional_url_params) ], array => [ qw(plugins) ], ); @@ -95,7 +95,9 @@ sub init { my @plugins; for my $plugin (qw(filtered sorted paginated)) { - next unless my $spec = delete $params{$plugin} // {}; + next if exists($params{$plugin}) && !$params{$plugin}; + + my $spec = delete $params{$plugin} // {}; my $plugin_class = "SL::Controller::Helper::GetModels::" . ucfirst $plugin; push @plugins, $self->$plugin($plugin_class->new(%$spec, get_models => $self)); } @@ -160,7 +162,7 @@ sub get_models_url_params { sub get_callback_params { my ($self, %override_params) = @_; - my %default_params = $self->_run_handlers('callback', action => $self->controller->action_name); + my %default_params = $self->_run_handlers('callback', action => $self->list_action); } sub get_callback { @@ -206,6 +208,10 @@ sub init_source { $::form } +sub init_list_action { + $_[0]->controller->action_name +} + sub init_additional_url_params { +{} } 1; @@ -298,7 +304,7 @@ set by the registered handlers. Enable or disable the specified plugin. Useful to disable paginating for exports for example. C can be used to check the current -state fo a plugin. +state of a plugin. Must not be finalized to use this. @@ -400,6 +406,13 @@ The creating controller. Currently this is mandatory. The name of the model for this GetModels instance. If none is given, the model is inferred from the name of the controller class. +=item list_action ACTION + +If callbacks are generated, use this action instead of the current action. +Usually you can omit this. In case the reporting is done without redirecting +from a mutating action, this is necessary to have callbacks for paginating and +sorting point to the correct action. + =item sorted PARAMS =item paginated PARAMS