From 95f9f85a003a94c70a8daaaef7aef91522050fa6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 18 Sep 2013 15:09:31 +0200 Subject: [PATCH] =?utf8?q?paginating=20im=20druck=20gefixt.=20debugmeldung?= =?utf8?q?en=20aufger=C3=A4umt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/DeliveryPlan.pm | 10 +++++--- SL/Controller/Helper/GetModels.pm | 1 + SL/Controller/Helper/GetModels/Paginated.pm | 27 ++++++++++++--------- SL/Controller/Helper/GetModels/Sorted.pm | 11 --------- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/SL/Controller/DeliveryPlan.pm b/SL/Controller/DeliveryPlan.pm index f5d5b4e34..348b55341 100644 --- a/SL/Controller/DeliveryPlan.pm +++ b/SL/Controller/DeliveryPlan.pm @@ -138,15 +138,11 @@ sub prepare_report { $column_defs{$_}->{text} = $sort_columns{$_} for keys %column_defs; - $self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i; - $self->models->finalize; # for filter laundering $report->set_options( std_column_visibility => 1, controller_class => 'DeliveryPlan', output_format => 'HTML', top_info_text => $::locale->text('Delivery Plan for currently outstanding sales orders'), - raw_top_info_text => $self->render('delivery_plan/report_top', { output => 0 }), - raw_bottom_info_text => $self->render('delivery_plan/report_bottom', { output => 0 }, models => $self->models), title => $::locale->text('Delivery Plan'), allow_pdf_export => 1, allow_csv_export => 1, @@ -155,7 +151,13 @@ sub prepare_report { $report->set_column_order(@columns); $report->set_export_options(qw(list filter)); $report->set_options_from_form; + $self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i; + $self->models->finalize; # for filter laundering $self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable); + $report->set_options( + raw_top_info_text => $self->render('delivery_plan/report_top', { output => 0 }), + raw_bottom_info_text => $self->render('delivery_plan/report_bottom', { output => 0 }, models => $self->models), + ); } sub make_filter_summary { diff --git a/SL/Controller/Helper/GetModels.pm b/SL/Controller/Helper/GetModels.pm index 7696fc1ea..a4cd973b8 100644 --- a/SL/Controller/Helper/GetModels.pm +++ b/SL/Controller/Helper/GetModels.pm @@ -31,6 +31,7 @@ sub disable_plugin { my ($self, $plugin) = @_; die 'cannot change internal state after finalize was called' if $self->finalized; die 'unsupported plugin' unless $self->can($plugin) && $self->$plugin && $self->$plugin->isa('SL::Controller::Helper::GetModels::Base'); + $self->$plugin->disabled(1); } diff --git a/SL/Controller/Helper/GetModels/Paginated.pm b/SL/Controller/Helper/GetModels/Paginated.pm index a632fc0a1..871f4b5c1 100644 --- a/SL/Controller/Helper/GetModels/Paginated.pm +++ b/SL/Controller/Helper/GetModels/Paginated.pm @@ -50,23 +50,26 @@ sub read_params { sub finalize { my ($self, %args) = @_; -# return () unless $self->is_enabled; - my %paginate_params = $self->read_params; - # try to use Filtered if available and nothing else is configured, but don't - # blow up if the controller does not use Filtered - my %paginate_args = ref($self->paginate_args) eq 'CODE' ? %{ $self->paginate_args->($self) } - : $self->paginate_args eq '__FILTER__' - && $self->get_models->filtered ? $self->get_models->filtered->read_params - : $self->paginate_args ne '__FILTER__' ? do { my $sub = $self->paginate_args; %{ $self->get_models->controller->$sub() } } - : (); + if ($self->is_enabled) { + my %paginate_params = $self->read_params; - %args = $self->merge_args(\%args, \%paginate_args); + # try to use Filtered if available and nothing else is configured, but don't + # blow up if the controller does not use Filtered + my %paginate_args = ref($self->paginate_args) eq 'CODE' ? %{ $self->paginate_args->($self) } + : $self->paginate_args eq '__FILTER__' + && $self->get_models->filtered ? $self->get_models->filtered->read_params + : $self->paginate_args ne '__FILTER__' ? do { my $sub = $self->paginate_args; %{ $self->get_models->controller->$sub() } } + : (); - my $calculated_params = $self->get_models->manager->paginate(%paginate_params, args => \%args); + %args = $self->merge_args(\%args, \%paginate_args); + + my $calculated_params = $self->get_models->manager->paginate(%paginate_params, args => \%args); + + $self->calculated_params($calculated_params); + } $self->paginated_args(\%args); - $self->calculated_params($calculated_params); return %args; } diff --git a/SL/Controller/Helper/GetModels/Sorted.pm b/SL/Controller/Helper/GetModels/Sorted.pm index defa67507..dee86810f 100644 --- a/SL/Controller/Helper/GetModels/Sorted.pm +++ b/SL/Controller/Helper/GetModels/Sorted.pm @@ -123,17 +123,6 @@ sub _callback_handler_for_sorted { 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 { [ qw(sort_by sort_dir) ] } -- 2.20.1