X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FHelper%2FSorted.pm;h=2bdc51b6b6ec067031552363acdcb50dafe0fb63;hb=0f0f42639c9a9c31a86521a9347f910fe0f0c3e0;hp=c9e5779116db5c66cd585dad8cef6866d27a2ad0;hpb=87b0de4c742e6032bcb6bf8750b1d8144e1a9860;p=kivitendo-erp.git diff --git a/SL/Controller/Helper/Sorted.pm b/SL/Controller/Helper/Sorted.pm index c9e577911..2bdc51b6b 100644 --- a/SL/Controller/Helper/Sorted.pm +++ b/SL/Controller/Helper/Sorted.pm @@ -11,7 +11,7 @@ our @EXPORT = qw(make_sorted get_sort_spec get_current_sort_params set_report_ge use constant PRIV => '__sortedhelperpriv'; -my $controller_sort_spec; +my %controller_sort_spec; sub make_sorted { my ($class, %specs) = @_; @@ -35,7 +35,7 @@ sub make_sorted { $specs{ONLY} ||= []; $specs{ONLY} = [ $specs{ONLY} ] if !ref $specs{ONLY}; - $controller_sort_spec = \%specs; + $controller_sort_spec{$class} = \%specs; my %hook_params = @{ $specs{ONLY} } ? ( only => $specs{ONLY} ) : (); $class->run_before('_save_current_sort_params', %hook_params); @@ -53,7 +53,7 @@ sub make_sorted { sub get_sort_spec { my ($class_or_self) = @_; - return $controller_sort_spec; + return $controller_sort_spec{ref($class_or_self) || $class_or_self}; } sub get_current_sort_params { @@ -108,9 +108,10 @@ sub _save_current_sort_params { my ($self) = @_; my $sort_spec = $self->get_sort_spec; + my $dir_idx = $sort_spec->{FORM_PARAMS}->[1]; $self->{PRIV()} = { by => $::form->{ $sort_spec->{FORM_PARAMS}->[0] }, - dir => !!$::form->{ $sort_spec->{FORM_PARAMS}->[1] } * 1, + dir => defined($::form->{$dir_idx}) ? $::form->{$dir_idx} * 1 : undef, }; # $::lxdebug->message(0, "saving current sort params to " . $self->{PRIV()}->{by} . ' / ' . $self->{PRIV()}->{dir});