From e3d226231a8cec1c598cf7fbef6710672cd2b6bf Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 5 Sep 2012 17:41:56 +0200 Subject: [PATCH] =?utf8?q?Sorted-Controller-Helper:=20Hilfsfunktion=20f?= =?utf8?q?=C3=BCr=20ReportGenerator?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Helper/Sorted.pm | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/SL/Controller/Helper/Sorted.pm b/SL/Controller/Helper/Sorted.pm index 57fb5e0bc..8699f00c7 100644 --- a/SL/Controller/Helper/Sorted.pm +++ b/SL/Controller/Helper/Sorted.pm @@ -3,6 +3,7 @@ package SL::Controller::Helper::Sorted; use strict; use Carp; +use List::MoreUtils qw(uniq); use Exporter qw(import); our @EXPORT = qw(make_sorted get_sort_spec get_current_sort_params set_report_generator_sort_options @@ -90,6 +91,13 @@ sub set_report_generator_sort_options { } $params{report}->set_sort_indicator($current_sort_params{by}, 1 - $current_sort_params{dir}); + + if ($params{report}->{export}) { + $params{report}->{export}->{variable_list} = [ uniq( + @{ $params{report}->{export}->{variable_list} }, + @{ $self->get_sort_spec->{FORM_PARAMS} } + )]; + } } # @@ -342,16 +350,28 @@ applying default parameters etc). =item C -This function sets two things in an instance of -L: the sort indicator and the links for those -column headers that are sortable. +This function does three things with an instance of +L: + +=over 4 + +=item 1. it sets the sort indicator, + +=item 2. it sets the the links for those column headers that are +sortable and + +=item 3. it adds the C fields to the list of variables in +the report generator's export options. + +=back The report generator instance must be passed as the parameter C. The parameter C must be an array reference of column names that are sortable. -The report generator instance must already have its columns set via a -call to its L function. +The report generator instance must already have its columns and export +options set via calls to its L and +L functions. =back -- 2.20.1