Kosmetik: Alignment, Einrückung
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 12 Jul 2013 11:33:30 +0000 (13:33 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 12 Jul 2013 11:36:54 +0000 (13:36 +0200)
SL/Controller/Helper/Filtered.pm
SL/Controller/Helper/Paginated.pm
SL/Controller/Helper/ParseFilter.pm
SL/Controller/Part.pm
SL/DB/Manager/Part.pm

index d248bf6..c5b876f 100644 (file)
@@ -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__
index 25c4efa..0db285f 100644 (file)
@@ -12,20 +12,20 @@ use List::Util qw(min);
 my %controller_paginate_spec;
 
 sub make_paginated {
-  my ($class, %specs)       = @_;
+  my ($class, %specs)               = @_;
 
-  $specs{MODEL}           ||=  $class->controller_name;
-  $specs{MODEL}             =~ s{ ^ SL::DB:: (?: .* :: )? }{}x;
-  $specs{PER_PAGE}        ||= "SL::DB::Manager::$specs{MODEL}"->default_objects_per_page;
-  $specs{FORM_PARAMS}     ||= [ qw(page per_page) ];
-  $specs{PAGINATE_ARGS}   ||= '__FILTER__';
-  $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{PER_PAGE}                ||= "SL::DB::Manager::$specs{MODEL}"->default_objects_per_page;
+  $specs{FORM_PARAMS}             ||= [ qw(page per_page) ];
+  $specs{PAGINATE_ARGS}           ||= '__FILTER__';
+  $specs{ONLY}                    ||= [];
+  $specs{ONLY}                      = [ $specs{ONLY} ] if !ref $specs{ONLY};
+  $specs{ONLY_MAP}                  = @{ $specs{ONLY} } ? { map { ($_ => 1) } @{ $specs{ONLY} } } : { '__ALL__' => 1 };
 
   $controller_paginate_spec{$class} = \%specs;
 
-  my %hook_params           = @{ $specs{ONLY} } ? ( only => $specs{ONLY} ) : ();
+  my %hook_params                   = @{ $specs{ONLY} } ? ( only => $specs{ONLY} ) : ();
   $class->run_before('_save_current_paginate_params', %hook_params);
 
   SL::Controller::Helper::GetModels::register_get_models_handlers(
index 8b26e88..1d0515c 100644 (file)
@@ -80,7 +80,7 @@ sub flatten {
     next if !defined $value || $value eq ''; # 0 is fine
     if ('HASH' eq ref $value) {
       my ($query, $more_objects) = flatten($value, _prefix($prefix, $key));
-      push @result,        @$query if $query;
+      push @result, @$query        if  $query;
       _add_uniq($with_objects, $_) for _prefix($prefix, $key), @$more_objects;
     } else {
       push @result, _prefix($prefix, $key) => $value;
index 904e6c5..38b3b55 100644 (file)
@@ -21,20 +21,20 @@ use Rose::Object::MakeMethods::Generic (
 __PACKAGE__->run_before(sub { $::auth->assert('part_service_assembly_edit') });
 
 __PACKAGE__->make_filtered(
-  ONLY          => [ qw(part_picker_search part_picker_result ajax_autocomplete) ],
-  LAUNDER_TO    => 'filter',
+  ONLY        => [ qw(part_picker_search part_picker_result ajax_autocomplete) ],
+  LAUNDER_TO  => 'filter',
 );
 __PACKAGE__->make_paginated(
-  ONLY          => [ qw(part_picker_search part_picker_result ajax_autocomplete) ],
+  ONLY        => [ qw(part_picker_search part_picker_result ajax_autocomplete) ],
 );
 
 __PACKAGE__->make_sorted(
-  ONLY              => [ qw(part_picker_search part_picker_result ajax_autocomplete) ],
+  ONLY        => [ qw(part_picker_search part_picker_result ajax_autocomplete) ],
 
-  DEFAULT_BY        => 'partnumber',
-  DEFAULT_DIR       => 1,
+  DEFAULT_BY  => 'partnumber',
+  DEFAULT_DIR => 1,
 
-  partnumber        => t8('Partnumber'),
+  partnumber  => t8('Partnumber'),
 );
 
 sub action_ajax_autocomplete {
index d286924..0b751bd 100644 (file)
@@ -43,21 +43,20 @@ sub type_filter {
 
   for my $type (@types) {
     if ($type =~ m/^part/) {
-      push @filter, (and => [ or                    => [ $prefix . assembly => 0, $prefix . assembly => undef ],
-                       "!${prefix}inventory_accno_id" => 0,
-                       "!${prefix}inventory_accno_id" => undef,
+      push @filter, (and => [ or                             => [ $prefix . assembly => 0, $prefix . assembly => undef ],
+                              "!${prefix}inventory_accno_id" => 0,
+                              "!${prefix}inventory_accno_id" => undef,
                      ]);
     } elsif ($type =~ m/^service/) {
       push @filter, (and => [ or => [ $prefix . assembly           => 0, $prefix . assembly           => undef ],
-                       or => [ $prefix . inventory_accno_id => 0, $prefix . inventory_accno_id => undef ],
+                              or => [ $prefix . inventory_accno_id => 0, $prefix . inventory_accno_id => undef ],
                      ]);
     } elsif ($type =~ m/^assembl/) {
       push @filter, ($prefix . assembly => 1);
     }
   }
 
-  return @filter > 2 ? (or => \@filter) :
-         @filter     ? @filter          : ();
+  return @filter > 2 ? (or => \@filter) : @filter;
 }
 
 sub get_ordered_qty {