X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FHelper%2FFiltered.pm;h=c5b876f414d1f9736a764cbf52ef505529416d33;hb=35d63a9fdee45777535d7ec815bfbc76c5c1bdc9;hp=d248bf6f3547d9184f0d5058f2ac8fda37d95004;hpb=82053b457be3de2ee5285dc13633222f4d30802c;p=kivitendo-erp.git diff --git a/SL/Controller/Helper/Filtered.pm b/SL/Controller/Helper/Filtered.pm index d248bf6f3..c5b876f41 100644 --- a/SL/Controller/Helper/Filtered.pm +++ b/SL/Controller/Helper/Filtered.pm @@ -12,19 +12,19 @@ use constant PRIV => '__filteredhelper_priv'; my %controller_filter_spec; sub make_filtered { - my ($class, %specs) = @_; + my ($class, %specs) = @_; - $specs{MODEL} //= $class->controller_name; - $specs{MODEL} =~ s{ ^ SL::DB:: (?: .* :: )? }{}x; - $specs{FORM_PARAMS} //= 'filter'; - $specs{LAUNDER_TO} = '__INPLACE__' unless exists $specs{LAUNDER_TO}; - $specs{ONLY} //= []; - $specs{ONLY} = [ $specs{ONLY} ] if !ref $specs{ONLY}; - $specs{ONLY_MAP} = @{ $specs{ONLY} } ? { map { ($_ => 1) } @{ $specs{ONLY} } } : { '__ALL__' => 1 }; + $specs{MODEL} //= $class->controller_name; + $specs{MODEL} =~ s{ ^ SL::DB:: (?: .* :: )? }{}x; + $specs{FORM_PARAMS} //= 'filter'; + $specs{LAUNDER_TO} = '__INPLACE__' unless exists $specs{LAUNDER_TO}; + $specs{ONLY} //= []; + $specs{ONLY} = [ $specs{ONLY} ] if !ref $specs{ONLY}; + $specs{ONLY_MAP} = @{ $specs{ONLY} } ? { map { ($_ => 1) } @{ $specs{ONLY} } } : { '__ALL__' => 1 }; $controller_filter_spec{$class} = \%specs; - my %hook_params = @{ $specs{ONLY} } ? ( only => $specs{ONLY} ) : (); + my %hook_params = @{ $specs{ONLY} } ? ( only => $specs{ONLY} ) : (); $class->run_before('_save_current_filter_params', %hook_params); SL::Controller::Helper::GetModels::register_get_models_handlers( @@ -76,15 +76,15 @@ sub _make_current_filter_params { $calculated_params{query} = [ @{ $calculated_params{query} || [] }, - @{ $filter_args{query} || [] }, - @{ $params{query} || [] }, + @{ $filter_args{ query} || [] }, + @{ $params{ query} || [] }, ]; $calculated_params{with_objects} = [ uniq @{ $calculated_params{with_objects} || [] }, - @{ $filter_args{with_objects} || [] }, - @{ $params{with_objects} || [] }, + @{ $filter_args{ with_objects} || [] }, + @{ $params{ with_objects} || [] }, ]; if ($laundered) { @@ -114,11 +114,11 @@ sub disable_filtering { sub _get_filter_args { my ($self, $spec) = @_; - $spec ||= $self->get_filter_spec; + $spec ||= $self->get_filter_spec; - my %filter_args = ref($spec->{FILTER_ARGS}) eq 'CODE' ? %{ $spec->{FILTER_ARGS}->($self) } - : $spec->{FILTER_ARGS} ? do { my $sub = $spec->{FILTER_ARGS}; %{ $self->$sub() } } - : (); + my %filter_args = ref($spec->{FILTER_ARGS}) eq 'CODE' ? %{ $spec->{FILTER_ARGS}->($self) } + : $spec->{FILTER_ARGS} ? do { my $sub = $spec->{FILTER_ARGS}; %{ $self->$sub() } } + : (); } sub _save_current_filter_params { @@ -137,9 +137,9 @@ sub _callback_handler_for_filtered { my $priv = _priv($self); if (_is_enabled($self) && $priv->{filter}) { - my $filter_spec = $self->get_filter_spec; + my $filter_spec = $self->get_filter_spec; my ($flattened) = SL::Controller::Helper::ParseFilter::flatten($priv->{filter}, undef, $filter_spec->{FORM_PARAMS}); - %params = (%params, @$flattened); + %params = (%params, @$flattened); } # $::lxdebug->dump(0, "CB handler for filtered; params after flatten:", \%params); @@ -172,7 +172,6 @@ sub _is_enabled { return !_priv($self)->{disabled} && ($self->get_filter_spec->{ONLY_MAP}->{$self->action_name} || $self->get_filter_spec->{ONLY_MAP}->{'__ALL__'}); } - 1; __END__