1 package SL::Controller::TopQuickSearch::Article;
4 use parent qw(Rose::Object);
6 use SL::Locale::String qw(t8);
8 use SL::Controller::Helper::GetModels;
9 use SL::Controller::Base;
11 use Rose::Object::MakeMethods::Generic (
12 'scalar --get_set_init' => [ qw(parts models part) ],
15 sub auth { 'part_service_assembly_edit' }
17 sub name { 'article' }
19 sub description_config { t8('Articles') }
21 sub description_field { t8('Articles') }
23 sub query_autocomplete {
26 my $objects = $self->models->get;
30 value => $_->displayable_name,
31 label => $_->displayable_name,
37 sub select_autocomplete {
38 redirect_to_part($::form->{id});
44 my $objects = $self->models->get;
46 return !@$objects ? ()
47 : @$objects == 1 ? $self->redirect_to_part($objects->[0]->id)
48 : $self->redirect_to_search($::form->{term});
51 sub redirect_to_search {
52 my ($self, $term) = @_;
54 SL::Controller::Base->new->url_for(
55 controller => 'ic.pl',
56 action => 'generate_report',
58 (searchitems => $self->type) x!!$self->type,
62 sub redirect_to_part {
63 my ($self, $term) = @_;
65 SL::Controller::Base->new->url_for(
66 controller => 'ic.pl',
79 SL::Controller::Helper::GetModels->new(
84 (type => $self->type) x!!$self->type,
85 'all:substr:multi::ilike' => $::form->{term},
93 partnumber => t8('Partnumber'),