From f7027139b5a2403424817a929743c162a0880f6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 20 Jul 2016 15:18:03 +0200 Subject: [PATCH] TopQuickSearch: typisierte Suche gefixt --- SL/Controller/TopQuickSearch/Article.pm | 19 ++++++++++++------- SL/Controller/TopQuickSearch/Assembly.pm | 2 +- SL/Controller/TopQuickSearch/Part.pm | 2 +- SL/Controller/TopQuickSearch/Service.pm | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/SL/Controller/TopQuickSearch/Article.pm b/SL/Controller/TopQuickSearch/Article.pm index 9bedb436a..e19e7736e 100644 --- a/SL/Controller/TopQuickSearch/Article.pm +++ b/SL/Controller/TopQuickSearch/Article.pm @@ -44,23 +44,28 @@ sub do_search { my $objects = $self->models->get; return !@$objects ? () - : @$objects == 1 ? redirect_to_part($objects->[0]->id) - : redirect_to_search($::form->{term}); + : @$objects == 1 ? $self->redirect_to_part($objects->[0]->id) + : $self->redirect_to_search($::form->{term}); } sub redirect_to_search { + my ($self, $term) = @_; + SL::Controller::Base->new->url_for( - controller => 'ic.pl', - action => 'generate_report', - all => $_[0], + controller => 'ic.pl', + action => 'generate_report', + all => $term, + (searchitems => $self->type) x!!$self->type, ); } sub redirect_to_part { + my ($self, $term) = @_; + SL::Controller::Base->new->url_for( controller => 'ic.pl', action => 'edit', - id => $_[0], + id => $term, ); } @@ -76,7 +81,7 @@ sub init_models { model => 'Part', source => { filter => { - ($self->type), + (type => $self->type) x!!$self->type, 'all:substr:multi::ilike' => $::form->{term}, }, }, diff --git a/SL/Controller/TopQuickSearch/Assembly.pm b/SL/Controller/TopQuickSearch/Assembly.pm index bb7eccea1..7f7e9e2a2 100644 --- a/SL/Controller/TopQuickSearch/Assembly.pm +++ b/SL/Controller/TopQuickSearch/Assembly.pm @@ -11,6 +11,6 @@ sub description_config { t8('Assemblies') } sub description_field { t8('Assemblies') } -sub type { type => 'assembly' } +sub type { 'assembly' } 1; diff --git a/SL/Controller/TopQuickSearch/Part.pm b/SL/Controller/TopQuickSearch/Part.pm index d6b01e021..9d4c2f0d7 100644 --- a/SL/Controller/TopQuickSearch/Part.pm +++ b/SL/Controller/TopQuickSearch/Part.pm @@ -11,6 +11,6 @@ sub description_config { t8('Parts') } sub description_field { t8('Parts') } -sub type { type => 'part' } +sub type { 'part' } 1; diff --git a/SL/Controller/TopQuickSearch/Service.pm b/SL/Controller/TopQuickSearch/Service.pm index f1f1507e6..7a9859015 100644 --- a/SL/Controller/TopQuickSearch/Service.pm +++ b/SL/Controller/TopQuickSearch/Service.pm @@ -11,6 +11,6 @@ sub description_config { t8('Services') } sub description_field { t8('Services') } -sub type { type => 'service' } +sub type { 'service' } 1; -- 2.20.1